Skip to content

Commit 598e84e

Browse files
authored
Improve large dense aggregate reads with tile metadata only. (#4657)
The dense reader was creating a bitmap to compute all aggregate results at the top level of the read. For large aggregate reads where we don't need to load any tiles, this could be quite large. It also would turn out to be completely unnecessary. This fix moves the bitmap to the lower level of the read, where a smaller bitmap can be created only if necessary. --- TYPE: IMPROVEMENT DESC: Improve large dense aggregate reads with tile metadata only.
1 parent 8b6501e commit 598e84e

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

tiledb/sm/query/readers/dense_reader.cc

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,13 +1319,6 @@ Status DenseReader::process_aggregates(
13191319
const auto& tile_coords = subarray.tile_coords();
13201320
const auto global_order = layout_ == Layout::GLOBAL_ORDER;
13211321

1322-
std::vector<uint8_t> aggregate_bitmap;
1323-
if (condition_.has_value()) {
1324-
aggregate_bitmap = qc_result;
1325-
} else {
1326-
aggregate_bitmap.resize(subarray.cell_num(), 1);
1327-
}
1328-
13291322
// Process values in parallel.
13301323
auto status = parallel_for_2d(
13311324
storage_manager_->compute_tp(),
@@ -1358,7 +1351,7 @@ Status DenseReader::process_aggregates(
13581351
tile_subarrays[t],
13591352
global_order ? tile_offsets[t] : 0,
13601353
range_info,
1361-
aggregate_bitmap,
1354+
qc_result,
13621355
range_thread_idx,
13631356
num_range_threads));
13641357
}
@@ -1863,7 +1856,7 @@ Status DenseReader::aggregate_tiles(
18631856
const Subarray& tile_subarray,
18641857
const uint64_t global_cell_offset,
18651858
const std::vector<RangeInfo<DimType>>& range_info,
1866-
std::vector<uint8_t>& aggregate_bitmap,
1859+
const std::vector<uint8_t>& qc_result,
18671860
const uint64_t range_thread_idx,
18681861
const uint64_t num_range_threads) {
18691862
// For easy reference
@@ -1909,6 +1902,14 @@ Status DenseReader::aggregate_tiles(
19091902
cell_offset = iter.dest_offset_row_col();
19101903
}
19111904

1905+
std::vector<uint8_t> aggregate_bitmap(iter.cell_slab_length(), 1);
1906+
if (condition_.has_value()) {
1907+
memcpy(
1908+
aggregate_bitmap.data(),
1909+
qc_result.data() + cell_offset,
1910+
iter.cell_slab_length());
1911+
}
1912+
19121913
// Iterate through all fragment domains and copy data.
19131914
for (uint64_t fd = 0; fd < frag_domains.size(); fd++) {
19141915
// If the cell slab overlaps this fragment domain range, copy data.
@@ -1936,7 +1937,7 @@ Status DenseReader::aggregate_tiles(
19361937
iter.pos_in_tile() + start,
19371938
iter.pos_in_tile() + end + 1,
19381939
tile_tuples[fd],
1939-
&aggregate_bitmap[cell_offset + start])};
1940+
aggregate_bitmap.data() + start)};
19401941
for (auto& aggregate : aggregates) {
19411942
aggregate->aggregate_data(aggregate_buffer);
19421943
}
@@ -1952,7 +1953,7 @@ Status DenseReader::aggregate_tiles(
19521953
start_cell,
19531954
start_cell + 1,
19541955
tile_tuples[fd],
1955-
&aggregate_bitmap[cell_offset + start + i])};
1956+
aggregate_bitmap.data() + start + i)};
19561957
for (auto& aggregate : aggregates) {
19571958
aggregate->aggregate_data(aggregate_buffer);
19581959
}
@@ -1964,7 +1965,7 @@ Status DenseReader::aggregate_tiles(
19641965
// fragments.
19651966
if (fd != frag_domains.size() - 1) {
19661967
for (uint64_t c = start; c <= end; c++) {
1967-
aggregate_bitmap[cell_offset + c] = 0;
1968+
aggregate_bitmap[c] = 0;
19681969
}
19691970
}
19701971

tiledb/sm/query/readers/dense_reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ class DenseReader : public ReaderBase, public IQueryStrategy {
400400
const Subarray& tile_subarray,
401401
const uint64_t global_cell_offset,
402402
const std::vector<RangeInfo<DimType>>& range_info,
403-
std::vector<uint8_t>& aggregate_bitmap,
403+
const std::vector<uint8_t>& qc_result,
404404
const uint64_t range_thread_idx,
405405
const uint64_t num_range_threads);
406406

0 commit comments

Comments
 (0)