blob: cfece052c5cc11a185b61785090562bc4fa9d9c2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#pragma once
#include "counting_raw_reader.h"
#include <yt/cpp/mapreduce/interface/io.h>
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
class TLenvalTableReader
{
public:
explicit TLenvalTableReader(::TIntrusivePtr<TRawTableReader> input);
virtual ~TLenvalTableReader();
protected:
bool IsValid() const;
void Next();
ui32 GetTableIndex() const;
ui32 GetRangeIndex() const;
ui64 GetRowIndex() const;
void NextKey();
TMaybe<size_t> GetReadByteCount() const;
bool IsEndOfStream() const;
bool IsRawReaderExhausted() const;
void CheckValidity() const;
bool Retry();
template <class T>
bool ReadInteger(T* result, bool acceptEndOfStream = false)
{
size_t count = Input_.Load(result, sizeof(T));
if (acceptEndOfStream && count == 0) {
Finished_ = true;
Valid_ = false;
return false;
}
Y_ENSURE(count == sizeof(T), "Premature end of stream");
return true;
}
virtual void SkipRow() = 0;
protected:
NDetail::TCountingRawTableReader Input_;
bool Valid_ = true;
bool Finished_ = false;
ui32 TableIndex_ = 0;
TMaybe<ui64> RowIndex_;
TMaybe<ui32> RangeIndex_;
ui32 RangeIndexShift_ = 0;
TMaybe<ui64> TabletIndex_;
bool IsEndOfStream_ = false;
bool AtStart_ = true;
bool RowTaken_ = true;
ui32 Length_ = 0;
private:
bool PrepareRetry();
};
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
|