Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-2.20] Improve large dense aggregate reads with tile metadata only. #4662

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions tiledb/sm/query/readers/dense_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1319,13 +1319,6 @@ Status DenseReader::process_aggregates(
const auto& tile_coords = subarray.tile_coords();
const auto global_order = layout_ == Layout::GLOBAL_ORDER;

std::vector<uint8_t> aggregate_bitmap;
if (condition_.has_value()) {
aggregate_bitmap = qc_result;
} else {
aggregate_bitmap.resize(subarray.cell_num(), 1);
}

// Process values in parallel.
auto status = parallel_for_2d(
storage_manager_->compute_tp(),
Expand Down Expand Up @@ -1358,7 +1351,7 @@ Status DenseReader::process_aggregates(
tile_subarrays[t],
global_order ? tile_offsets[t] : 0,
range_info,
aggregate_bitmap,
qc_result,
range_thread_idx,
num_range_threads));
}
Expand Down Expand Up @@ -1863,7 +1856,7 @@ Status DenseReader::aggregate_tiles(
const Subarray& tile_subarray,
const uint64_t global_cell_offset,
const std::vector<RangeInfo<DimType>>& range_info,
std::vector<uint8_t>& aggregate_bitmap,
const std::vector<uint8_t>& qc_result,
const uint64_t range_thread_idx,
const uint64_t num_range_threads) {
// For easy reference
Expand Down Expand Up @@ -1909,6 +1902,14 @@ Status DenseReader::aggregate_tiles(
cell_offset = iter.dest_offset_row_col();
}

std::vector<uint8_t> aggregate_bitmap(iter.cell_slab_length(), 1);
if (condition_.has_value()) {
memcpy(
aggregate_bitmap.data(),
qc_result.data() + cell_offset,
iter.cell_slab_length());
}

// Iterate through all fragment domains and copy data.
for (uint64_t fd = 0; fd < frag_domains.size(); fd++) {
// If the cell slab overlaps this fragment domain range, copy data.
Expand Down Expand Up @@ -1936,7 +1937,7 @@ Status DenseReader::aggregate_tiles(
iter.pos_in_tile() + start,
iter.pos_in_tile() + end + 1,
tile_tuples[fd],
&aggregate_bitmap[cell_offset + start])};
aggregate_bitmap.data() + start)};
for (auto& aggregate : aggregates) {
aggregate->aggregate_data(aggregate_buffer);
}
Expand All @@ -1952,7 +1953,7 @@ Status DenseReader::aggregate_tiles(
start_cell,
start_cell + 1,
tile_tuples[fd],
&aggregate_bitmap[cell_offset + start + i])};
aggregate_bitmap.data() + start + i)};
for (auto& aggregate : aggregates) {
aggregate->aggregate_data(aggregate_buffer);
}
Expand All @@ -1964,7 +1965,7 @@ Status DenseReader::aggregate_tiles(
// fragments.
if (fd != frag_domains.size() - 1) {
for (uint64_t c = start; c <= end; c++) {
aggregate_bitmap[cell_offset + c] = 0;
aggregate_bitmap[c] = 0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/query/readers/dense_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class DenseReader : public ReaderBase, public IQueryStrategy {
const Subarray& tile_subarray,
const uint64_t global_cell_offset,
const std::vector<RangeInfo<DimType>>& range_info,
std::vector<uint8_t>& aggregate_bitmap,
const std::vector<uint8_t>& qc_result,
const uint64_t range_thread_idx,
const uint64_t num_range_threads);

Expand Down
Loading