Skip to content

Commit

Permalink
cs/segment_meta_cstore: use frame is_applicable() to retrieve hint
Browse files Browse the repository at this point in the history
this check is a superset of the previous version. now base offset is
checked to be in the range of the frame
  • Loading branch information
andijcr committed Dec 5, 2023
1 parent 7ca2519 commit d8c3fdb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/v/cloud_storage/segment_meta_cstore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -567,18 +567,19 @@ class column_store
}

auto& hint_vec = hint_it->second.value();
auto hint_threshold = base_offset_iter.get_frame_initial_value();
auto hint_initial
= hint_vec.at(static_cast<size_t>(segment_meta_ix::base_offset))
.initial;
auto hint_bo = hint_vec.at(
static_cast<size_t>(segment_meta_ix::base_offset));

// The hint can only be applied within the same column_store_frame
// instance. If the hint belongs to the previous frame we need to
// materialize without optimization.
if (hint_initial < hint_threshold) {
return std::nullopt;
if (_base_offset
.get_frame_iterator_by_element_index(base_offset_iter.index())
->is_applicable(hint_bo)) {
return hint_vec;
}
return hint_vec;

return std::nullopt;
}();

if (!maybe_hint) {
Expand Down
2 changes: 1 addition & 1 deletion src/v/cloud_storage/segment_meta_cstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ class segment_meta_column_impl
}

protected:
auto get_frame_iterator_by_element_index(size_t ix) {
auto get_frame_iterator_by_element_index(size_t ix) const {
return std::find_if(
_frames.begin(), _frames.end(), [ix](frame_t const& f) mutable {
if (f.size() > ix) {
Expand Down

0 comments on commit d8c3fdb

Please sign in to comment.