Skip to content

Commit 35b0e9d

Browse files
use domain expanded to the closest tiles
1 parent 86fc717 commit 35b0e9d

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

tiledb/sm/query/writers/global_order_writer.cc

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,15 +1432,15 @@ uint64_t GlobalOrderWriter::num_tiles_to_write(
14321432
return tile_num - start;
14331433
}
14341434

1435-
uint64_t GlobalOrderWriter::num_tiles_per_row() {
1436-
auto dim_num = array_schema_.dim_num();
1435+
uint64_t GlobalOrderWriter::num_tiles_per_row(const Domain& domain) {
1436+
auto dim_num = domain.dim_num();
14371437
uint64_t ret = 1;
14381438

14391439
for (unsigned d = 1; d < dim_num; ++d) {
14401440
// Skip first dim. We want to calculate how many tiles can fit in one row.
14411441
// To do that we skip the first dim and multiply the range / extend of the
14421442
// other dimensions
1443-
auto dim{array_schema_.dimension_ptr(d)};
1443+
auto dim{domain.dimension_ptr(d)};
14441444
auto dim_dom = dim->domain();
14451445
auto l = [&](auto T) {
14461446
return static_cast<uint64_t>(dim->tile_extent().rvalue_as<decltype(T)>());
@@ -1454,14 +1454,17 @@ uint64_t GlobalOrderWriter::num_tiles_per_row() {
14541454
}
14551455

14561456
NDRange GlobalOrderWriter::ndranges_after_split(uint64_t num) {
1457-
// if (disable_checks_consolidation_) {
1458-
// auto expanded_subarray = subarray_.ndrange(0);
1459-
// domain.expand_to_tiles(&expanded_subarray);
1460-
// }
1457+
// Expand domain to full tiles
1458+
auto& domain{array_schema_.domain()};
1459+
if (disable_checks_consolidation_) {
1460+
auto expanded_subarray = subarray_.ndrange(0);
1461+
domain.expand_to_tiles(&expanded_subarray);
1462+
}
14611463

1462-
uint64_t tiles_per_row = num_tiles_per_row();
1463-
auto dim_num = array_schema_.dim_num();
1464-
auto dim{array_schema_.dimension_ptr(0)};
1464+
// Calculate how many tiles each row can hold
1465+
uint64_t tiles_per_row = num_tiles_per_row(domain);
1466+
auto dim_num = domain.dim_num();
1467+
auto dim{domain.dimension_ptr(0)};
14651468

14661469
auto l = [&](auto T) {
14671470
return static_cast<uint64_t>(dim->tile_extent().rvalue_as<decltype(T)>());
@@ -1482,7 +1485,7 @@ NDRange GlobalOrderWriter::ndranges_after_split(uint64_t num) {
14821485
uint64_t rows_of_tiles_to_write = num / tiles_per_row;
14831486

14841487
// Create the range for the index dim (first).
1485-
int start = rows_written_ * tile_extent; // todo start from the dim_dom start
1488+
int start = rows_written_ * tile_extent;
14861489
int end = start + (rows_of_tiles_to_write * tile_extent) - 1;
14871490
Range range(&start, &end, sizeof(int));
14881491
nd.emplace_back(range);

tiledb/sm/query/writers/global_order_writer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,11 @@ class GlobalOrderWriter : public WriterBase {
403403
* Return the number of tiles a single row can hold. More specifically, the
404404
* number of tiles all dimensions except the first can hold.
405405
*
406+
* @param domain The domain
407+
*
406408
* @return Number of tiles.
407409
*/
408-
uint64_t num_tiles_per_row();
410+
uint64_t num_tiles_per_row(const Domain& domain);
409411

410412
/**
411413
* Close the current fragment and start a new one. The closed fragment will

0 commit comments

Comments
 (0)