proto_table_reader.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 = default;
  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. explicit TLenvalProtoTableReader(
  40. ::TIntrusivePtr<TRawTableReader> input);
  41. ~TLenvalProtoTableReader() override = default;
  42. void ReadRow(Message* row) override;
  43. bool IsValid() const override;
  44. void Next() override;
  45. ui32 GetTableIndex() const override;
  46. ui32 GetRangeIndex() const override;
  47. ui64 GetRowIndex() const override;
  48. void NextKey() override;
  49. TMaybe<size_t> GetReadByteCount() const override;
  50. bool IsEndOfStream() const override;
  51. bool IsRawReaderExhausted() const override;
  52. protected:
  53. void SkipRow() override;
  54. private:
  55. bool ValidateProtoDescriptor_;
  56. TVector<const ::google::protobuf::Descriptor*> Descriptors_;
  57. };
  58. // Sometime useful outside mapreduce/yt
  59. void ReadMessageFromNode(const TNode& node, Message* row);
  60. ////////////////////////////////////////////////////////////////////////////////
  61. } // namespace NYT