proto_table_reader.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include "lenval_table_reader.h"
  3. #include <yt/cpp/mapreduce/interface/io.h>
  4. namespace NYT {
  5. class TRawTableReader;
  6. class TNodeTableReader;
  7. ////////////////////////////////////////////////////////////////////////////////
  8. class TProtoTableReader
  9. : public IProtoReaderImpl
  10. {
  11. public:
  12. explicit TProtoTableReader(
  13. ::TIntrusivePtr<TRawTableReader> input,
  14. TVector<const ::google::protobuf::Descriptor*>&& descriptors);
  15. ~TProtoTableReader() override;
  16. void ReadRow(Message* row) override;
  17. bool IsValid() const override;
  18. void Next() override;
  19. ui32 GetTableIndex() const override;
  20. ui32 GetRangeIndex() const override;
  21. ui64 GetRowIndex() const override;
  22. void NextKey() override;
  23. TMaybe<size_t> GetReadByteCount() const override;
  24. bool IsEndOfStream() const override;
  25. bool IsRawReaderExhausted() const override;
  26. private:
  27. THolder<TNodeTableReader> NodeReader_;
  28. TVector<const ::google::protobuf::Descriptor*> Descriptors_;
  29. };
  30. ////////////////////////////////////////////////////////////////////////////////
  31. class TLenvalProtoTableReader
  32. : public IProtoReaderImpl
  33. , public TLenvalTableReader
  34. {
  35. public:
  36. explicit TLenvalProtoTableReader(
  37. ::TIntrusivePtr<TRawTableReader> input,
  38. TVector<const ::google::protobuf::Descriptor*>&& descriptors);
  39. ~TLenvalProtoTableReader() override;
  40. void ReadRow(Message* row) override;
  41. bool IsValid() const override;
  42. void Next() override;
  43. ui32 GetTableIndex() const override;
  44. ui32 GetRangeIndex() const override;
  45. ui64 GetRowIndex() const override;
  46. void NextKey() override;
  47. TMaybe<size_t> GetReadByteCount() const override;
  48. bool IsEndOfStream() const override;
  49. bool IsRawReaderExhausted() const override;
  50. protected:
  51. void SkipRow() override;
  52. private:
  53. TVector<const ::google::protobuf::Descriptor*> Descriptors_;
  54. };
  55. // Sometime useful outside mapreduce/yt
  56. void ReadMessageFromNode(const TNode& node, Message* row);
  57. ////////////////////////////////////////////////////////////////////////////////
  58. } // namespace NYT