skiff_table_reader.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include "counting_raw_reader.h"
  3. #include <yt/cpp/mapreduce/interface/io.h>
  4. #include <yt/cpp/mapreduce/skiff/wire_type.h>
  5. #include <yt/cpp/mapreduce/skiff/unchecked_parser.h>
  6. #include <util/stream/buffered.h>
  7. namespace NYT {
  8. namespace NDetail {
  9. ////////////////////////////////////////////////////////////////////////////////
  10. class TSkiffTableReader
  11. : public INodeReaderImpl
  12. {
  13. public:
  14. TSkiffTableReader(
  15. ::TIntrusivePtr<TRawTableReader> input,
  16. const std::shared_ptr<NSkiff::TSkiffSchema>& schema);
  17. ~TSkiffTableReader() override;
  18. virtual const TNode& GetRow() const override;
  19. virtual void MoveRow(TNode* row) override;
  20. bool IsValid() const override;
  21. void Next() override;
  22. ui32 GetTableIndex() const override;
  23. ui32 GetRangeIndex() const override;
  24. ui64 GetRowIndex() const override;
  25. void NextKey() override;
  26. TMaybe<size_t> GetReadByteCount() const override;
  27. bool IsRawReaderExhausted() const override;
  28. private:
  29. struct TSkiffTableSchema;
  30. private:
  31. void EnsureValidity() const;
  32. void ReadRow();
  33. static TVector<TSkiffTableSchema> CreateSkiffTableSchemas(const std::shared_ptr<NSkiff::TSkiffSchema>& schema);
  34. private:
  35. NDetail::TCountingRawTableReader Input_;
  36. TBufferedInput BufferedInput_;
  37. std::optional<NSkiff::TUncheckedSkiffParser> Parser_;
  38. TVector<TSkiffTableSchema> Schemas_;
  39. TNode Row_;
  40. bool Valid_ = true;
  41. bool AfterKeySwitch_ = false;
  42. bool Finished_ = false;
  43. TMaybe<ui64> RangeIndex_;
  44. ui64 RangeIndexShift_ = 0;
  45. TMaybe<ui64> RowIndex_;
  46. ui32 TableIndex_ = 0;
  47. };
  48. ////////////////////////////////////////////////////////////////////////////////
  49. } // namespace NDetail
  50. } // namespace NYT