@@ -453,6 +453,9 @@ Status DenseReader::dense_read() {
453
453
// processing.
454
454
if (qc_coords_mode_) {
455
455
t_start = t_end;
456
+ if (compute_task.valid ()) {
457
+ throw_if_not_ok (compute_task.wait ());
458
+ }
456
459
continue ;
457
460
}
458
461
@@ -769,8 +772,8 @@ DenseReader::compute_result_space_tiles(
769
772
const auto fragment_num = (unsigned )frag_tile_domains.size ();
770
773
const auto & tile_coords = subarray.tile_coords ();
771
774
772
- // Keep track of the required memory to load the result space tiles. Split up
773
- // filtered versus unfiltered. The memory budget is combined for all
775
+ // Keep track of the required memory to load the result space tiles. Split
776
+ // up filtered versus unfiltered. The memory budget is combined for all
774
777
// query condition attributes.
775
778
uint64_t required_memory_query_condition_unfiltered = 0 ;
776
779
std::vector<uint64_t > required_memory_unfiltered (
@@ -786,28 +789,28 @@ DenseReader::compute_result_space_tiles(
786
789
aggregate_only_field[n - condition_names.size ()] = aggregate_only (name);
787
790
}
788
791
789
- // Here we estimate the size of the tile structures. First, we have to account
790
- // the size of the space tile structure. We could go deeper in the class to
791
- // account for other things but for now we keep it simpler. Second, we try to
792
- // account for the tile subarray (DenseTileSubarray). This class will have a
793
- // vector of ranges per dimensions, so 1 + dim_num * sizeof(vector). Here we
794
- // choose 32 for the size of the vector to anticipate the conversion to a PMR
795
- // vector. We also add dim_num * 2 * sizeof(DimType) to account for at least
796
- // one range per dimension (this should be improved by accounting for the
797
- // exact number of ranges). Finally for the original range index member, we
798
- // have to add 1 + dim_num * sizeof(vector) as well and one uint64_t per
799
- // dimension (this can also be improved by accounting for the
800
- // exact number of ranges).
792
+ // Here we estimate the size of the tile structures. First, we have to
793
+ // account the size of the space tile structure. We could go deeper in the
794
+ // class to account for other things but for now we keep it simpler. Second,
795
+ // we try to account for the tile subarray (DenseTileSubarray). This class
796
+ // will have a vector of ranges per dimensions, so 1 + dim_num *
797
+ // sizeof(vector). Here we choose 32 for the size of the vector to
798
+ // anticipate the conversion to a PMR vector. We also add dim_num * 2 *
799
+ // sizeof(DimType) to account for at least one range per dimension (this
800
+ // should be improved by accounting for the exact number of ranges). Finally
801
+ // for the original range index member, we have to add 1 + dim_num *
802
+ // sizeof(vector) as well and one uint64_t per dimension (this can also be
803
+ // improved by accounting for the exact number of ranges).
801
804
uint64_t est_tile_structs_size =
802
805
sizeof (ResultSpaceTile<DimType>) + (1 + dim_num) * 2 * 32 +
803
806
dim_num * (2 * sizeof (DimType) + sizeof (uint64_t ));
804
807
805
808
// Create the vector of result tiles to operate on. We stop once we reach
806
- // the end or the memory budget. We either reach the tile upper memory limit,
807
- // which is only for unfiltered data, or the limit of the available budget,
808
- // which is for filtered data, unfiltered data and the tile structs. We try to
809
- // process two tile batches at a time so the available memory is half of what
810
- // we have available.
809
+ // the end or the memory budget. We either reach the tile upper memory
810
+ // limit, which is only for unfiltered data, or the limit of the available
811
+ // budget, which is for filtered data, unfiltered data and the tile structs.
812
+ // We try to process two tile batches at a time so the available memory is
813
+ // half of what we have available.
811
814
uint64_t t_end = t_start;
812
815
bool wait_compute_task_before_read = false ;
813
816
bool done = false ;
@@ -895,8 +898,8 @@ DenseReader::compute_result_space_tiles(
895
898
uint64_t tile_memory_filtered = 0 ;
896
899
uint64_t r_idx = n - condition_names.size ();
897
900
898
- // We might not need to load this tile into memory at all for aggregation
899
- // only.
901
+ // We might not need to load this tile into memory at all for
902
+ // aggregation only.
900
903
if (aggregate_only_field[r_idx] &&
901
904
can_aggregate_tile_with_frag_md (
902
905
names[n], result_space_tile, tiles_cell_num[t_end])) {
@@ -953,13 +956,14 @@ DenseReader::compute_result_space_tiles(
953
956
required_memory_unfiltered[r_idx] +
954
957
est_tile_structs_size;
955
958
956
- // Disable the multiple iterations if the tiles don't fit in the iteration
957
- // budget.
959
+ // Disable the multiple iterations if the tiles don't fit in the
960
+ // iteration budget.
958
961
if (total_memory > available_memory_iteration) {
959
962
wait_compute_task_before_read = true ;
960
963
}
961
964
962
- // If a single tile doesn't fit in the available memory, we can't proceed.
965
+ // If a single tile doesn't fit in the available memory, we can't
966
+ // proceed.
963
967
if (total_memory > available_memory) {
964
968
throw DenseReaderException (
965
969
" Cannot process a single tile requiring " +
@@ -1003,7 +1007,8 @@ std::vector<ResultTile*> DenseReader::result_tiles_to_load(
1003
1007
const auto & tile_coords = subarray.tile_coords ();
1004
1008
const bool agg_only = name.has_value () && aggregate_only (name.value ());
1005
1009
1006
- // If the result is already loaded in query condition, return the empty list;
1010
+ // If the result is already loaded in query condition, return the empty
1011
+ // list;
1007
1012
std::vector<ResultTile*> ret;
1008
1013
if (name.has_value () && condition_names.count (name.value ()) != 0 ) {
1009
1014
return ret;
@@ -1033,8 +1038,8 @@ std::vector<ResultTile*> DenseReader::result_tiles_to_load(
1033
1038
1034
1039
/* *
1035
1040
* Apply the query condition. The computation will be pushed on the compute
1036
- * thread pool in `compute_task`. Callers should wait on this task before using
1037
- * the results of the query condition.
1041
+ * thread pool in `compute_task`. Callers should wait on this task before
1042
+ * using the results of the query condition.
1038
1043
*/
1039
1044
template <class DimType , class OffType >
1040
1045
Status DenseReader::apply_query_condition (
0 commit comments