Skip to content

Commit 29ddb05

Browse files
committed
remove Block::row_same_bit
1 parent 8136701 commit 29ddb05

File tree

15 files changed

+80
-154
lines changed

15 files changed

+80
-154
lines changed

be/src/olap/iterators.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ struct CompactionSampleInfo {
159159
int64_t group_data_size;
160160
};
161161

162+
struct BlockWithSameBit {
163+
vectorized::Block* block;
164+
std::vector<bool>& same_bit;
165+
166+
bool empty() const { return block->rows() == 0; }
167+
};
168+
162169
class RowwiseIterator;
163170
using RowwiseIteratorUPtr = std::unique_ptr<RowwiseIterator>;
164171
class RowwiseIterator {
@@ -187,7 +194,11 @@ class RowwiseIterator {
187194
return Status::NotSupported("to be implemented");
188195
}
189196

190-
virtual Status next_block_view(vectorized::BlockView* block_view) {
197+
virtual Status next_batch(BlockWithSameBit* block_with_same_bit) {
198+
return Status::NotSupported("to be implemented");
199+
}
200+
201+
virtual Status next_batch(vectorized::BlockView* block_view) {
191202
return Status::NotSupported("to be implemented");
192203
}
193204

be/src/olap/rowset/beta_rowset_reader.cpp

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -348,60 +348,6 @@ Status BetaRowsetReader::_init_iterator() {
348348
return Status::OK();
349349
}
350350

351-
Status BetaRowsetReader::next_block(vectorized::Block* block) {
352-
RETURN_IF_ERROR(_init_iterator_once());
353-
SCOPED_RAW_TIMER(&_stats->block_fetch_ns);
354-
if (_empty) {
355-
return Status::Error<END_OF_FILE>("BetaRowsetReader is empty");
356-
}
357-
358-
RuntimeState* runtime_state = nullptr;
359-
if (_read_context != nullptr) {
360-
runtime_state = _read_context->runtime_state;
361-
}
362-
363-
do {
364-
auto s = _iterator->next_batch(block);
365-
if (!s.ok()) {
366-
if (!s.is<END_OF_FILE>()) {
367-
LOG(WARNING) << "failed to read next block: " << s.to_string();
368-
}
369-
return s;
370-
}
371-
372-
if (runtime_state != nullptr && runtime_state->is_cancelled()) [[unlikely]] {
373-
return runtime_state->cancel_reason();
374-
}
375-
} while (block->empty());
376-
377-
return Status::OK();
378-
}
379-
380-
Status BetaRowsetReader::next_block_view(vectorized::BlockView* block_view) {
381-
RETURN_IF_ERROR(_init_iterator_once());
382-
SCOPED_RAW_TIMER(&_stats->block_fetch_ns);
383-
RuntimeState* runtime_state = nullptr;
384-
if (_read_context != nullptr) {
385-
runtime_state = _read_context->runtime_state;
386-
}
387-
388-
do {
389-
auto s = _iterator->next_block_view(block_view);
390-
if (!s.ok()) {
391-
if (!s.is<END_OF_FILE>()) {
392-
LOG(WARNING) << "failed to read next block view: " << s.to_string();
393-
}
394-
return s;
395-
}
396-
397-
if (runtime_state != nullptr && runtime_state->is_cancelled()) [[unlikely]] {
398-
return runtime_state->cancel_reason();
399-
}
400-
} while (block_view->empty());
401-
402-
return Status::OK();
403-
}
404-
405351
bool BetaRowsetReader::_should_push_down_value_predicates() const {
406352
// if unique table with rowset [0-x] or [0-1] [2-y] [...],
407353
// value column predicates can be pushdown on rowset [0-x] or [2-y], [2-y]

be/src/olap/rowset/beta_rowset_reader.h

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ class BetaRowsetReader : public RowsetReader {
5353
std::vector<RowwiseIteratorUPtr>* out_iters,
5454
bool use_cache = false) override;
5555
void reset_read_options() override;
56-
Status next_block(vectorized::Block* block) override;
57-
Status next_block_view(vectorized::BlockView* block_view) override;
56+
Status next_batch(vectorized::Block* block) override { return _next_batch(block); }
57+
Status next_batch(vectorized::BlockView* block_view) override {
58+
return _next_batch(block_view);
59+
}
60+
Status next_batch(BlockWithSameBit* block_with_same_bit) override {
61+
return _next_batch(block_with_same_bit);
62+
}
5863
bool support_return_data_by_ref() override { return _is_merge_iterator(); }
5964

6065
bool delete_flag() override { return _rowset->delete_flag(); }
@@ -89,6 +94,36 @@ class BetaRowsetReader : public RowsetReader {
8994
OlapReaderStatistics* get_stats() { return _stats; }
9095

9196
private:
97+
template <typename T>
98+
Status _next_batch(T* block) {
99+
RETURN_IF_ERROR(_init_iterator_once());
100+
SCOPED_RAW_TIMER(&_stats->block_fetch_ns);
101+
if (_empty) {
102+
return Status::Error<ErrorCode::END_OF_FILE>("BetaRowsetReader is empty");
103+
}
104+
105+
RuntimeState* runtime_state = nullptr;
106+
if (_read_context != nullptr) {
107+
runtime_state = _read_context->runtime_state;
108+
}
109+
110+
do {
111+
Status s = _iterator->next_batch(block);
112+
if (!s.ok()) {
113+
if (!s.is<ErrorCode::END_OF_FILE>()) {
114+
LOG(WARNING) << "failed to read next block: " << s.to_string();
115+
}
116+
return s;
117+
}
118+
119+
if (runtime_state != nullptr && runtime_state->is_cancelled()) [[unlikely]] {
120+
return runtime_state->cancel_reason();
121+
}
122+
} while (block->empty());
123+
124+
return Status::OK();
125+
}
126+
92127
[[nodiscard]] Status _init_iterator_once();
93128
[[nodiscard]] Status _init_iterator();
94129
bool _should_push_down_value_predicates() const;

be/src/olap/rowset/rowset_reader.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ class RowsetReader {
6161
bool use_cache = false) = 0;
6262
virtual void reset_read_options() = 0;
6363

64-
virtual Status next_block(vectorized::Block* block) = 0;
65-
66-
virtual Status next_block_view(vectorized::BlockView* block_view) = 0;
64+
virtual Status next_batch(vectorized::Block* block) = 0;
65+
virtual Status next_batch(vectorized::BlockView* block_view) = 0;
66+
virtual Status next_batch(BlockWithSameBit* block_view) = 0;
6767
virtual bool support_return_data_by_ref() { return false; }
6868

6969
virtual bool delete_flag() = 0;

be/src/olap/schema_change.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ Status VSchemaChangeDirectly::_inner_process(RowsetReaderSharedPtr rowset_reader
554554
auto new_block = vectorized::Block::create_unique(new_tablet_schema->create_block());
555555
auto ref_block = vectorized::Block::create_unique(base_tablet_schema->create_block());
556556

557-
auto st = rowset_reader->next_block(ref_block.get());
557+
auto st = rowset_reader->next_batch(ref_block.get());
558558
if (!st) {
559559
if (st.is<ErrorCode::END_OF_FILE>()) {
560560
if (ref_block->rows() == 0) {
@@ -622,7 +622,7 @@ Status VBaseSchemaChangeWithSorting::_inner_process(RowsetReaderSharedPtr rowset
622622
bool eof = false;
623623
do {
624624
auto ref_block = vectorized::Block::create_unique(base_tablet_schema->create_block());
625-
auto st = rowset_reader->next_block(ref_block.get());
625+
auto st = rowset_reader->next_batch(ref_block.get());
626626
if (!st) {
627627
if (st.is<ErrorCode::END_OF_FILE>()) {
628628
if (ref_block->rows() == 0) {

be/src/vec/core/block.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,6 @@ void Block::erase_tail(size_t start) {
244244
++it;
245245
}
246246
}
247-
if (start < row_same_bit.size()) {
248-
row_same_bit.erase(row_same_bit.begin() + start, row_same_bit.end());
249-
}
250247
}
251248

252249
void Block::erase(size_t position) {
@@ -278,9 +275,6 @@ void Block::erase_impl(size_t position) {
278275
}
279276
}
280277
}
281-
if (position < row_same_bit.size()) {
282-
row_same_bit.erase(row_same_bit.begin() + position);
283-
}
284278
}
285279

286280
void Block::erase(const String& name) {
@@ -433,9 +427,6 @@ void Block::set_num_rows(size_t length) {
433427
elem.column = elem.column->shrink(length);
434428
}
435429
}
436-
if (length < row_same_bit.size()) {
437-
row_same_bit.resize(length);
438-
}
439430
}
440431
}
441432

@@ -450,9 +441,6 @@ void Block::skip_num_rows(int64_t& length) {
450441
elem.column = elem.column->cut(length, origin_rows - length);
451442
}
452443
}
453-
if (length < row_same_bit.size()) {
454-
row_same_bit.assign(row_same_bit.begin() + length, row_same_bit.end());
455-
}
456444
}
457445
}
458446

@@ -783,7 +771,6 @@ DataTypes Block::get_data_types() const {
783771
void Block::clear() {
784772
data.clear();
785773
index_by_name.clear();
786-
row_same_bit.clear();
787774
}
788775

789776
void Block::clear_column_data(int64_t column_size) noexcept {
@@ -802,7 +789,6 @@ void Block::clear_column_data(int64_t column_size) noexcept {
802789
(*std::move(d.column)).assume_mutable()->clear();
803790
}
804791
}
805-
row_same_bit.clear();
806792
}
807793

808794
void Block::erase_tmp_columns() noexcept {
@@ -836,14 +822,12 @@ void Block::swap(Block& other) noexcept {
836822
SCOPED_SKIP_MEMORY_CHECK();
837823
data.swap(other.data);
838824
index_by_name.swap(other.index_by_name);
839-
row_same_bit.swap(other.row_same_bit);
840825
}
841826

842827
void Block::swap(Block&& other) noexcept {
843828
SCOPED_SKIP_MEMORY_CHECK();
844829
data = std::move(other.data);
845830
index_by_name = std::move(other.index_by_name);
846-
row_same_bit = std::move(other.row_same_bit);
847831
}
848832

849833
void Block::shuffle_columns(const std::vector<int>& result_column_ids) {
@@ -1167,9 +1151,6 @@ void MutableBlock::erase(const String& name) {
11671151
++it;
11681152
}
11691153
}
1170-
// if (position < row_same_bit.size()) {
1171-
// row_same_bit.erase(row_same_bit.begin() + position);
1172-
// }
11731154
}
11741155

11751156
Block MutableBlock::to_block(int start_column) {

be/src/vec/core/block.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class Block {
7676
using IndexByName = phmap::flat_hash_map<String, size_t>;
7777
Container data;
7878
IndexByName index_by_name;
79-
std::vector<bool> row_same_bit;
8079

8180
int64_t _decompress_time_ns = 0;
8281
int64_t _decompressed_bytes = 0;
@@ -367,21 +366,6 @@ class Block {
367366
int64_t get_decompressed_bytes() const { return _decompressed_bytes; }
368367
int64_t get_compress_time() const { return _compress_time_ns; }
369368

370-
void set_same_bit(std::vector<bool>::const_iterator begin,
371-
std::vector<bool>::const_iterator end) {
372-
row_same_bit.insert(row_same_bit.end(), begin, end);
373-
374-
DCHECK_EQ(row_same_bit.size(), rows());
375-
}
376-
377-
bool get_same_bit(size_t position) {
378-
if (position >= row_same_bit.size()) {
379-
return false;
380-
}
381-
return row_same_bit[position];
382-
}
383-
384-
void clear_same_bit() { row_same_bit.clear(); }
385369

386370
// remove tmp columns in block
387371
// in inverted index apply logic, in order to optimize query performance,

be/src/vec/exec/scan/scanner.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ Status Scanner::get_block(RuntimeState* state, Block* block, bool* eof) {
106106

107107
{
108108
do {
109-
// if step 2 filter all rows of block, and block will be reused to get next rows,
110-
// must clear row_same_bit of block, or will get wrong row_same_bit.size() which not equal block.rows()
111-
block->clear_same_bit();
112109
// 1. Get input block from scanner
113110
{
114111
// get block time

be/src/vec/olap/block_reader.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ Status BlockReader::_agg_key_next_block(Block* block, bool* eof) {
309309
return res;
310310
}
311311

312-
if (!_get_next_row_same()) {
312+
if (!_next_row.is_same) {
313313
if (target_block_row == _reader_context.batch_size) {
314314
break;
315315
}
@@ -530,13 +530,5 @@ void BlockReader::_update_agg_value(MutableColumns& columns, int begin, int end,
530530
}
531531
}
532532

533-
bool BlockReader::_get_next_row_same() {
534-
if (_next_row.is_same) {
535-
return true;
536-
} else {
537-
auto* block = _next_row.block.get();
538-
return block->get_same_bit(_next_row.row_pos);
539-
}
540-
}
541533
#include "common/compile_check_end.h"
542534
} // namespace doris::vectorized

be/src/vec/olap/block_reader.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ class BlockReader final : public TabletReader {
8484

8585
void _update_agg_value(MutableColumns& columns, int begin, int end, bool is_close = true);
8686

87-
bool _get_next_row_same();
88-
8987
// return false if keys of rowsets are mono ascending and disjoint
9088
bool _rowsets_not_mono_asc_disjoint(const ReaderParams& read_params);
9189

0 commit comments

Comments
 (0)