diff --git a/tiledb/sm/query/readers/dense_reader.cc b/tiledb/sm/query/readers/dense_reader.cc index 5149a712163..57c4b045e13 100644 --- a/tiledb/sm/query/readers/dense_reader.cc +++ b/tiledb/sm/query/readers/dense_reader.cc @@ -1339,13 +1339,6 @@ Status DenseReader::process_aggregates( const auto& tile_coords = subarray.tile_coords(); const auto global_order = layout_ == Layout::GLOBAL_ORDER; - std::vector 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(), @@ -1378,7 +1371,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)); } @@ -1883,7 +1876,7 @@ Status DenseReader::aggregate_tiles( const Subarray& tile_subarray, const uint64_t global_cell_offset, const std::vector>& range_info, - std::vector& aggregate_bitmap, + const std::vector& qc_result, const uint64_t range_thread_idx, const uint64_t num_range_threads) { // For easy reference @@ -1929,6 +1922,14 @@ Status DenseReader::aggregate_tiles( cell_offset = iter.dest_offset_row_col(); } + std::vector 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. @@ -1956,7 +1957,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); } @@ -1972,7 +1973,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); } @@ -1984,7 +1985,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; } } diff --git a/tiledb/sm/query/readers/dense_reader.h b/tiledb/sm/query/readers/dense_reader.h index 5e6e90d0f65..808b9a206dc 100644 --- a/tiledb/sm/query/readers/dense_reader.h +++ b/tiledb/sm/query/readers/dense_reader.h @@ -409,7 +409,7 @@ class DenseReader : public ReaderBase, public IQueryStrategy { const Subarray& tile_subarray, const uint64_t global_cell_offset, const std::vector>& range_info, - std::vector& aggregate_bitmap, + const std::vector& qc_result, const uint64_t range_thread_idx, const uint64_t num_range_threads);