Skip to content

Commit

Permalink
[Enhancement] make some proc in BinaryColumn vectorized (StarRocks#55418
Browse files Browse the repository at this point in the history
)

Signed-off-by: stdpain <drfeng08@gmail.com>
  • Loading branch information
stdpain authored Jan 26, 2025
1 parent af3d78f commit 380af2d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions be/src/column/binary_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ void BinaryColumnBase<T>::_build_slices() const {
_slices_cache = false;
_slices.clear();

_slices.reserve(_offsets.size() - 1);
_slices.resize(_offsets.size() - 1);

for (size_t i = 0; i < _offsets.size() - 1; ++i) {
_slices.emplace_back(_bytes.data() + _offsets[i], _offsets[i + 1] - _offsets[i]);
_slices[i] = {_bytes.data() + _offsets[i], _offsets[i + 1] - _offsets[i]};
}

_slices_cache = true;
Expand Down Expand Up @@ -528,12 +528,11 @@ int BinaryColumnBase<T>::compare_at(size_t left, size_t right, const Column& rhs
template <typename T>
uint32_t BinaryColumnBase<T>::max_one_element_serialize_size() const {
uint32_t max_size = 0;
T prev_offset = _offsets[0];
for (size_t i = 0; i < _offsets.size() - 1; ++i) {
T curr_offset = _offsets[i + 1];
size_t length = _offsets.size() - 1;
for (size_t i = 0; i < length; ++i) {
// it's safe to cast, because max size of one string is 2^32
max_size = std::max(max_size, static_cast<uint32_t>(curr_offset - prev_offset));
prev_offset = curr_offset;
uint32_t curr_length = _offsets[i + 1] - _offsets[i];
max_size = std::max(max_size, curr_length);
}
// TODO: may be overflow here, i will solve it later
return max_size + sizeof(uint32_t);
Expand Down

0 comments on commit 380af2d

Please sign in to comment.