@@ -1436,14 +1436,14 @@ GlobalOrderWriter::identify_fragment_tile_boundaries(
14361436 uint64_t running_tiles_size = current_fragment_size_;
14371437 uint64_t fragment_size = current_fragment_size_;
14381438
1439- uint64_t fragment_start = 0 ;
1440- std::optional<uint64_t > fragment_end;
1439+ uint64_t fragment_start = 0 , fragment_end = 0 ;
14411440 std::vector<std::pair<uint64_t , uint64_t >> fragments;
14421441
1443- const uint64_t hyperrow_num_tiles =
1444- (dense () ? compute_hyperrow_num_tiles (
1445- array_schema_.domain (), subarray_.ndrange (0 )) :
1446- 1 );
1442+ std::optional<uint64_t > hyperrow_num_tiles;
1443+ if (dense ()) {
1444+ hyperrow_num_tiles = compute_hyperrow_num_tiles (
1445+ array_schema_.domain (), subarray_.ndrange (0 ));
1446+ }
14471447
14481448 // Make sure we don't write more than the desired fragment size.
14491449 for (uint64_t t = 0 ; t < tile_num; t++) {
@@ -1477,7 +1477,7 @@ GlobalOrderWriter::identify_fragment_tile_boundaries(
14771477 if (running_tiles_size == 0 ) {
14781478 throw GlobalOrderWriterException (
14791479 " Fragment size is too small to write a single tile" );
1480- } else if (! fragment_end. has_value () ) {
1480+ } else if (fragment_end == 0 ) {
14811481 throw GlobalOrderWriterException (
14821482 " Fragment size is too small to subdivide dense subarray into "
14831483 " multiple fragments" );
@@ -1488,11 +1488,11 @@ GlobalOrderWriter::identify_fragment_tile_boundaries(
14881488 iassert (running_tiles_size >= fragment_size);
14891489 running_tiles_size -= fragment_size;
14901490
1491- fragment_start = fragment_end. value () ;
1492- fragment_end. reset () ;
1491+ fragment_start = fragment_end;
1492+ fragment_end = 0 ;
14931493 }
14941494
1495- if ((( t + 1 ) - fragment_start ) % hyperrow_num_tiles == 0 ) {
1495+ if (!hyperrow_num_tiles. has_value () || (( t + 1 ) - 10 ) % 8 == 0 ) {
14961496 fragment_size = running_tiles_size + tile_size;
14971497 fragment_end = t + 1 ;
14981498 }
0 commit comments