Lines 26-32
Link Here
|
26 |
int VirtualCursor::First() { |
26 |
int VirtualCursor::First() { |
27 |
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
27 |
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
28 |
inner_decoders_.clear(); |
28 |
inner_decoders_.clear(); |
29 |
leaf_decoder_ = nullptr; |
29 |
leaf_decoder_.Reset(); |
30 |
|
30 |
|
31 |
AppendPageDecoder(table_->root_page_id()); |
31 |
AppendPageDecoder(table_->root_page_id()); |
32 |
return Next(); |
32 |
return Next(); |
Lines 36-53
Link Here
|
36 |
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
36 |
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
37 |
record_reader_.Reset(); |
37 |
record_reader_.Reset(); |
38 |
|
38 |
|
39 |
while (!inner_decoders_.empty() || leaf_decoder_.get()) { |
39 |
while (!inner_decoders_.empty() || leaf_decoder_.IsValid()) { |
40 |
if (leaf_decoder_.get()) { |
40 |
if (leaf_decoder_.IsValid()) { |
41 |
if (!leaf_decoder_->CanAdvance()) { |
41 |
if (!leaf_decoder_.CanAdvance()) { |
42 |
// The leaf has been exhausted. Remove it from the DFS stack. |
42 |
// The leaf has been exhausted. Remove it from the DFS stack. |
43 |
leaf_decoder_ = nullptr; |
43 |
leaf_decoder_.Reset(); |
44 |
continue; |
44 |
continue; |
45 |
} |
45 |
} |
46 |
if (!leaf_decoder_->TryAdvance()) |
46 |
if (!leaf_decoder_.TryAdvance()) |
47 |
continue; |
47 |
continue; |
48 |
|
48 |
|
49 |
if (!payload_reader_.Initialize(leaf_decoder_->last_record_size(), |
49 |
if (!payload_reader_.Initialize(leaf_decoder_.last_record_size(), |
50 |
leaf_decoder_->last_record_offset())) { |
50 |
leaf_decoder_.last_record_offset())) { |
51 |
continue; |
51 |
continue; |
52 |
} |
52 |
} |
53 |
if (!record_reader_.Initialize()) |
53 |
if (!record_reader_.Initialize()) |
Lines 99-111
Link Here
|
99 |
int64_t VirtualCursor::RowId() { |
99 |
int64_t VirtualCursor::RowId() { |
100 |
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
100 |
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
101 |
DCHECK(record_reader_.IsInitialized()); |
101 |
DCHECK(record_reader_.IsInitialized()); |
102 |
DCHECK(leaf_decoder_.get()); |
102 |
DCHECK(leaf_decoder_.IsValid()); |
103 |
return leaf_decoder_->last_record_rowid(); |
103 |
return leaf_decoder_.last_record_rowid(); |
104 |
} |
104 |
} |
105 |
|
105 |
|
106 |
void VirtualCursor::AppendPageDecoder(int page_id) { |
106 |
void VirtualCursor::AppendPageDecoder(int page_id) { |
107 |
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
107 |
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
108 |
DCHECK(leaf_decoder_.get() == nullptr) |
108 |
DCHECK(!leaf_decoder_.IsValid()) |
109 |
<< __func__ |
109 |
<< __func__ |
110 |
<< " must only be called when the current path has no leaf decoder"; |
110 |
<< " must only be called when the current path has no leaf decoder"; |
111 |
|
111 |
|
Lines 113-119
Link Here
|
113 |
return; |
113 |
return; |
114 |
|
114 |
|
115 |
if (LeafPageDecoder::IsOnValidPage(&db_reader_)) { |
115 |
if (LeafPageDecoder::IsOnValidPage(&db_reader_)) { |
116 |
leaf_decoder_ = std::make_unique<LeafPageDecoder>(&db_reader_); |
116 |
leaf_decoder_.Initialize(&db_reader_); |
117 |
return; |
117 |
return; |
118 |
} |
118 |
} |
119 |
|
119 |
|