Skip to content

Commit 86fc717

Browse files
add support for multi typed dimensions
1 parent e8a26c8 commit 86fc717

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

tiledb/sm/query/writers/global_order_writer.cc

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "tiledb/sm/tile/tile_metadata_generator.h"
5353
#include "tiledb/sm/tile/writer_tile_tuple.h"
5454
#include "tiledb/storage_format/uri/generate_uri.h"
55+
#include "tiledb/type/apply_with_type.h"
5556

5657
using namespace tiledb;
5758
using namespace tiledb::common;
@@ -1441,17 +1442,32 @@ uint64_t GlobalOrderWriter::num_tiles_per_row() {
14411442
// other dimensions
14421443
auto dim{array_schema_.dimension_ptr(d)};
14431444
auto dim_dom = dim->domain();
1444-
ret *= dim->domain_range(dim_dom) / dim->tile_extent().rvalue_as<int32_t>();
1445+
auto l = [&](auto T) {
1446+
return static_cast<uint64_t>(dim->tile_extent().rvalue_as<decltype(T)>());
1447+
};
1448+
1449+
ret *= dim->domain_range(dim_dom) / apply_with_type(l, dim->type());
14451450
// todo consider cases where the above calculation has a remainder. Also
14461451
// consider other types
14471452
}
14481453
return ret;
14491454
}
14501455

14511456
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+
// }
1461+
14521462
uint64_t tiles_per_row = num_tiles_per_row();
14531463
auto dim_num = array_schema_.dim_num();
1454-
uint64_t cells_in_tile = array_schema_.domain().cell_num_per_tile();
1464+
auto dim{array_schema_.dimension_ptr(0)};
1465+
1466+
auto l = [&](auto T) {
1467+
return static_cast<uint64_t>(dim->tile_extent().rvalue_as<decltype(T)>());
1468+
};
1469+
1470+
uint64_t tile_extent = apply_with_type(l, dim->type());
14551471
NDRange nd;
14561472
nd.reserve(dim_num);
14571473

@@ -1466,9 +1482,8 @@ NDRange GlobalOrderWriter::ndranges_after_split(uint64_t num) {
14661482
uint64_t rows_of_tiles_to_write = num / tiles_per_row;
14671483

14681484
// Create the range for the index dim (first).
1469-
int start =
1470-
rows_written_ * cells_in_tile; // todo start from the dim_dom start
1471-
int end = start + (rows_of_tiles_to_write * cells_in_tile) - 1;
1485+
int start = rows_written_ * tile_extent; // todo start from the dim_dom start
1486+
int end = start + (rows_of_tiles_to_write * tile_extent) - 1;
14721487
Range range(&start, &end, sizeof(int));
14731488
nd.emplace_back(range);
14741489

0 commit comments

Comments
 (0)