skiff_row_table_reader.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #include "counting_raw_reader.h"
  3. #include <yt/cpp/mapreduce/client/skiff.h>
  4. #include <yt/cpp/mapreduce/interface/io.h>
  5. #include <yt/cpp/mapreduce/skiff/unchecked_parser.h>
  6. #include <util/stream/buffered.h>
  7. namespace NYT {
  8. ////////////////////////////////////////////////////////////////////////////////
  9. class TSkiffRowTableReader
  10. : public ISkiffRowReaderImpl
  11. {
  12. public:
  13. explicit TSkiffRowTableReader(
  14. ::TIntrusivePtr<TRawTableReader> input,
  15. const NSkiff::TSkiffSchemaPtr& schema,
  16. TVector<ISkiffRowSkipperPtr>&& skippers,
  17. NDetail::TCreateSkiffSchemaOptions&& options);
  18. ~TSkiffRowTableReader() override;
  19. void ReadRow(const ISkiffRowParserPtr& parser) 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 IsEndOfStream() const override;
  28. bool IsRawReaderExhausted() const override;
  29. private:
  30. bool Retry(const std::exception_ptr& error);
  31. void SkipRow();
  32. void CheckValidity() const;
  33. bool PrepareRetry(const std::exception_ptr& error);
  34. private:
  35. NDetail::TCountingRawTableReader Input_;
  36. TBufferedInput BufferedInput_;
  37. std::optional<NSkiff::TCheckedInDebugSkiffParser> Parser_;
  38. TVector<ISkiffRowSkipperPtr> Skippers_;
  39. NDetail::TCreateSkiffSchemaOptions Options_;
  40. bool RowTaken_ = true;
  41. bool Valid_ = true;
  42. bool Finished_ = false;
  43. bool AfterKeySwitch_ = false;
  44. bool IsEndOfStream_ = false;
  45. TMaybe<ui64> RowIndex_;
  46. TMaybe<ui32> RangeIndex_;
  47. ui32 RangeIndexShift_ = 0;
  48. ui32 TableIndex_ = 0;
  49. };
  50. ////////////////////////////////////////////////////////////////////////////////
  51. } // namespace NYT