5353#include " tiledb/sm/tile/tile_metadata_generator.h"
5454#include " tiledb/sm/tile/writer_tile_tuple.h"
5555#include " tiledb/storage_format/uri/generate_uri.h"
56+ #include " tiledb/type/apply_with_type.h"
5657
5758using namespace tiledb ;
5859using namespace tiledb ::common;
@@ -1442,17 +1443,32 @@ uint64_t GlobalOrderWriter::num_tiles_per_row() {
14421443 // other dimensions
14431444 auto dim{array_schema_.dimension_ptr (d)};
14441445 auto dim_dom = dim->domain ();
1445- ret *= dim->domain_range (dim_dom) / dim->tile_extent ().rvalue_as <int32_t >();
1446+ auto l = [&](auto T) {
1447+ return static_cast <uint64_t >(dim->tile_extent ().rvalue_as <decltype (T)>());
1448+ };
1449+
1450+ ret *= dim->domain_range (dim_dom) / apply_with_type (l, dim->type ());
14461451 // todo consider cases where the above calculation has a remainder. Also
14471452 // consider other types
14481453 }
14491454 return ret;
14501455}
14511456
14521457NDRange 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+ // }
1462+
14531463 uint64_t tiles_per_row = num_tiles_per_row ();
14541464 auto dim_num = array_schema_.dim_num ();
1455- uint64_t cells_in_tile = array_schema_.domain ().cell_num_per_tile ();
1465+ auto dim{array_schema_.dimension_ptr (0 )};
1466+
1467+ auto l = [&](auto T) {
1468+ return static_cast <uint64_t >(dim->tile_extent ().rvalue_as <decltype (T)>());
1469+ };
1470+
1471+ uint64_t tile_extent = apply_with_type (l, dim->type ());
14561472 NDRange nd;
14571473 nd.reserve (dim_num);
14581474
@@ -1467,9 +1483,8 @@ NDRange GlobalOrderWriter::ndranges_after_split(uint64_t num) {
14671483 uint64_t rows_of_tiles_to_write = num / tiles_per_row;
14681484
14691485 // Create the range for the index dim (first).
1470- int start =
1471- rows_written_ * cells_in_tile; // todo start from the dim_dom start
1472- int end = start + (rows_of_tiles_to_write * cells_in_tile) - 1 ;
1486+ int start = rows_written_ * tile_extent; // todo start from the dim_dom start
1487+ int end = start + (rows_of_tiles_to_write * tile_extent) - 1 ;
14731488 Range range (&start, &end, sizeof (int ));
14741489 nd.emplace_back (range);
14751490
0 commit comments