Skip to content

Commit

Permalink
[refactor](array) remove depandancy of ColumnBlock, ColumnBlockView
Browse files Browse the repository at this point in the history
change to vectorized::MutableColumnPtr
  • Loading branch information
eldenmoon committed Jan 17, 2023
1 parent b6d9e73 commit 66e743e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
14 changes: 10 additions & 4 deletions be/src/olap/rowset/segment_v2/bitshuffle_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ class BitShufflePageDecoder : public PageDecoder {
return Status::OK();
}

Status next_batch(size_t* n, vectorized::MutableColumnPtr& dst) override {
template <bool forward_index = true>
Status next_batch(size_t* n, vectorized::MutableColumnPtr& dst) {
DCHECK(_parsed);
if (PREDICT_FALSE(*n == 0 || _cur_index >= _num_elements)) {
*n = 0;
Expand All @@ -393,13 +394,18 @@ class BitShufflePageDecoder : public PageDecoder {
size_t max_fetch = std::min(*n, static_cast<size_t>(_num_elements - _cur_index));

dst->insert_many_fix_len_data(get_data(_cur_index), max_fetch);

*n = max_fetch;
_cur_index += max_fetch;
if constexpr (forward_index) {
_cur_index += max_fetch;
}

return Status::OK();
};

Status next_batch(size_t* n, vectorized::MutableColumnPtr& dst) override {
return next_batch<>(n, dst);
};

Status read_by_rowids(const rowid_t* rowids, ordinal_t page_first_ordinal, size_t* n,
vectorized::MutableColumnPtr& dst) override {
DCHECK(_parsed);
Expand All @@ -426,7 +432,7 @@ class BitShufflePageDecoder : public PageDecoder {
return Status::OK();
}

Status peek_next_batch(size_t* n, ColumnBlockView* dst) override {
Status peek_next_batch(size_t* n, vectorized::MutableColumnPtr& dst) override {
return next_batch<false>(n, dst);
}

Expand Down
14 changes: 5 additions & 9 deletions be/src/olap/rowset/segment_v2/column_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,21 +486,17 @@ Status ArrayFileColumnIterator::init(const ColumnIteratorOptions& opts) {
if (_array_reader->is_nullable()) {
RETURN_IF_ERROR(_null_iterator->init(opts));
}
const auto* offset_type_info = get_scalar_type_info<OLAP_FIELD_TYPE_UNSIGNED_BIGINT>();
RETURN_IF_ERROR(
ColumnVectorBatch::create(1024, false, offset_type_info, nullptr, &_length_batch));
return Status::OK();
}

Status ArrayFileColumnIterator::_peek_one_offset(ordinal_t* offset) {
if (_offset_iterator->get_current_page()->has_remaining()) {
PageDecoder* offset_page_decoder = _offset_iterator->get_current_page()->data_decoder;
ColumnBlock ordinal_block(_length_batch.get(), nullptr);
ColumnBlockView ordinal_view(&ordinal_block);
size_t i = 1;
RETURN_IF_ERROR(offset_page_decoder->peek_next_batch(&i, &ordinal_view)); // not null
DCHECK(i == 1);
*offset = *reinterpret_cast<uint64_t*>(_length_batch->data());
vectorized::MutableColumnPtr offset_col = vectorized::ColumnUInt64::create();
size_t n = 1;
RETURN_IF_ERROR(offset_page_decoder->peek_next_batch(&n, offset_col)); // not null
DCHECK(offset_col->size() == 1);
*offset = offset_col->get_uint(0);
} else {
*offset = _offset_iterator->get_current_page()->next_array_item_ordinal;
}
Expand Down
1 change: 0 additions & 1 deletion be/src/olap/rowset/segment_v2/column_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ class ArrayFileColumnIterator final : public ColumnIterator {
std::unique_ptr<FileColumnIterator> _offset_iterator;
std::unique_ptr<ColumnIterator> _null_iterator;
std::unique_ptr<ColumnIterator> _item_iterator;
std::unique_ptr<ColumnVectorBatch> _length_batch;

Status _peek_one_offset(ordinal_t* offset);
Status _seek_by_offsets(ordinal_t ord);
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/rowset/segment_v2/frame_of_reference_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ class FrameOfReferencePageDecoder : public PageDecoder {
return Status::NotSupported("frame page not implement vec op now");
};

Status peek_next_batch(size_t* n, ColumnBlockView* dst) override {
return next_batch<false>(n, dst);
Status peek_next_batch(size_t* n, vectorized::MutableColumnPtr& dst) override {
return Status::NotSupported("frame page not implement vec op now");
}

size_t count() const override { return _num_elements; }
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/rowset/segment_v2/page_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class PageDecoder {
// Same as `next_batch` except for not moving forward the cursor.
// When read array's ordinals in `ArrayFileColumnIterator`, we want to read one extra ordinal
// but do not want to move forward the cursor.
virtual Status peek_next_batch(size_t* n, ColumnBlockView* dst) {
return Status::NotSupported("peek_next_batch");
virtual Status peek_next_batch(size_t* n, vectorized::MutableColumnPtr& dst) {
return Status::NotSupported("not implement vec op now");
}

// Return the number of elements in this page.
Expand Down
4 changes: 0 additions & 4 deletions be/src/olap/rowset/segment_v2/plain_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ class PlainPageDecoder : public PageDecoder {
return Status::OK();
}

Status peek_next_batch(size_t* n, ColumnBlockView* dst) override {
return next_batch<false>(n, dst);
}

size_t count() const override {
DCHECK(_parsed);
return _num_elems;
Expand Down

0 comments on commit 66e743e

Please sign in to comment.