proto_table_writer.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma once
  2. #include <yt/cpp/mapreduce/interface/io.h>
  3. namespace NYT {
  4. class IProxyOutput;
  5. class TNodeTableWriter;
  6. ////////////////////////////////////////////////////////////////////////////////
  7. class TProtoTableWriter
  8. : public IProtoWriterImpl
  9. {
  10. public:
  11. TProtoTableWriter(
  12. THolder<IProxyOutput> output,
  13. TVector<const ::google::protobuf::Descriptor*>&& descriptors);
  14. ~TProtoTableWriter() override;
  15. void AddRow(const Message& row, size_t tableIndex) override;
  16. void AddRow(Message&& row, size_t tableIndex) override;
  17. size_t GetBufferMemoryUsage() const override;
  18. size_t GetTableCount() const override;
  19. void FinishTable(size_t) override;
  20. void Abort() override;
  21. private:
  22. THolder<TNodeTableWriter> NodeWriter_;
  23. TVector<const ::google::protobuf::Descriptor*> Descriptors_;
  24. };
  25. ////////////////////////////////////////////////////////////////////////////////
  26. class TLenvalProtoTableWriter
  27. : public IProtoWriterImpl
  28. {
  29. public:
  30. TLenvalProtoTableWriter(
  31. THolder<IProxyOutput> output,
  32. TVector<const ::google::protobuf::Descriptor*>&& descriptors);
  33. ~TLenvalProtoTableWriter() override;
  34. void AddRow(const Message& row, size_t tableIndex) override;
  35. void AddRow(Message&& row, size_t tableIndex) override;
  36. size_t GetBufferMemoryUsage() const override;
  37. size_t GetTableCount() const override;
  38. void FinishTable(size_t) override;
  39. void Abort() override;
  40. protected:
  41. THolder<IProxyOutput> Output_;
  42. TVector<const ::google::protobuf::Descriptor*> Descriptors_;
  43. };
  44. /// [Deprecated] Create TNode from protobuf message
  45. ///
  46. /// @deprecated This function works only in simple cases. On nontrivial messages its interpretation
  47. /// of protobuf messages might significantly differ from YT interpretation.
  48. ///
  49. /// This function doesn't support composite types and many attributes supported by protobuf Reader/Writer.
  50. TNode MakeNodeFromMessage(const ::google::protobuf::Message& row);
  51. ////////////////////////////////////////////////////////////////////////////////
  52. class TLenvalProtoSingleTableWriter
  53. : public TLenvalProtoTableWriter
  54. {
  55. public:
  56. TLenvalProtoSingleTableWriter(
  57. THolder<IProxyOutput> output,
  58. const ::google::protobuf::Descriptor* descriptor);
  59. ~TLenvalProtoSingleTableWriter() override = default;
  60. void AddRow(const Message& row, size_t tableIndex) override;
  61. };
  62. ////////////////////////////////////////////////////////////////////////////////
  63. } // namespace NYT