Skip to content

Commit

Permalink
[BugFix] Fix multiget not support out-of-order column_ids (#50162)
Browse files Browse the repository at this point in the history
Signed-off-by: Binglin Chang <[email protected]>
  • Loading branch information
decster authored Aug 23, 2024
1 parent d7bd21c commit 4d4ad5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
18 changes: 14 additions & 4 deletions be/src/storage/local_tablet_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,27 @@ Status LocalTabletReader::multi_get(const Chunk& keys, const std::vector<uint32_
plan_read_by_rssid(rowids, found, rowids_by_rssid, idxes);

auto read_column_schema = ChunkHelper::convert_schema(tablet_schema, value_column_ids);
std::vector<std::unique_ptr<Column>> read_columns(value_column_ids.size());
vector<std::pair<uint32_t, uint32_t>> value_column_ids_by_order_with_orig_idx;
for (uint32_t i = 0; i < value_column_ids.size(); ++i) {
value_column_ids_by_order_with_orig_idx.emplace_back(value_column_ids[i], i);
}
std::sort(value_column_ids_by_order_with_orig_idx.begin(), value_column_ids_by_order_with_orig_idx.end());
vector<uint32_t> value_column_ids_by_order;
for (const auto& p : value_column_ids_by_order_with_orig_idx) {
value_column_ids_by_order.push_back(p.first);
}
std::vector<std::unique_ptr<Column>> read_columns(value_column_ids_by_order.size());
for (uint32_t i = 0; i < read_columns.size(); ++i) {
read_columns[i] = ChunkHelper::column_from_field(*read_column_schema.field(i).get())->clone_empty();
}
RETURN_IF_ERROR(_tablet->updates()->get_column_values(value_column_ids, _version, false, rowids_by_rssid,
RETURN_IF_ERROR(_tablet->updates()->get_column_values(value_column_ids_by_order, _version, false, rowids_by_rssid,
&read_columns, nullptr, tablet_schema));

// reorder read values to input keys' order and put into values output parameter
values.reset();
for (size_t col_idx = 0; col_idx < value_column_ids.size(); col_idx++) {
values.get_column_by_index(col_idx)->append_selective(*read_columns[col_idx], idxes.data(), 0, idxes.size());
for (size_t col_idx = 0; col_idx < value_column_ids_by_order.size(); col_idx++) {
values.get_column_by_index(value_column_ids_by_order_with_orig_idx[col_idx].second)
->append_selective(*read_columns[col_idx], idxes.data(), 0, idxes.size());
}
int64_t t_end = MonotonicMillis();
LOG(INFO) << strings::Substitute("multi_get tablet:$0 version:$1 #columns:$2 #rows:$3 found:$4 time:$5ms",
Expand Down
1 change: 1 addition & 0 deletions be/src/storage/tablet_updates.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class TabletUpdates {
// - logs
Status clear_meta();

// Note: values in column_ids must be valid, unique and increasing, do not support out-of-order column_ids
// get column values by rssids and rowids, at currently applied version
// for example:
// get_column_values with
Expand Down

0 comments on commit 4d4ad5f

Please sign in to comment.