Skip to content

Commit cccbe44

Browse files
use domain expanded to the closest tiles
1 parent b093b0d commit cccbe44

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
@@ -1433,15 +1433,15 @@ uint64_t GlobalOrderWriter::num_tiles_to_write(
14331433
return tile_num - start;
14341434
}
14351435

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

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

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

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

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

14851488
// Create the range for the index dim (first).
1486-
int start = rows_written_ * tile_extent; // todo start from the dim_dom start
1489+
int start = rows_written_ * tile_extent;
14871490
int end = start + (rows_of_tiles_to_write * tile_extent) - 1;
14881491
Range range(&start, &end, sizeof(int));
14891492
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)