Skip to content

Commit

Permalink
catch edge cases for above
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisStaratzis committed Aug 28, 2024
1 parent 737d8e8 commit b1e0520
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/src/unit-cppapi-max-fragment-size.cc
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ TEST_CASE(

TEST_CASE(
"Setting max_fragment_size in Dense consolidation",
"[global-order-writer]") {
"[global-order-writer][max-frag-size-consolidation]") {
std::string array_name = "cpp_max_fragment_size_bug";
Context ctx;

Expand Down Expand Up @@ -600,7 +600,7 @@ TEST_CASE(

TEST_CASE(
"Setting max_fragment_size in Dense consolidation one dim",
"[global-order-writer]") {
"[global-order-writer][max-frag-size-consolidation]") {
std::string array_name = "cpp_max_fragment_size_bug";
Context ctx;

Expand Down
13 changes: 11 additions & 2 deletions tiledb/sm/query/writers/global_order_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,15 @@ NDRange GlobalOrderWriter::ndranges_after_split(
// Calculate how many rows we will write in the current fragment
uint64_t rows_of_tiles_to_write =
(num - tiles_in_current_row_) / tiles_per_row;
uint64_t remainder_of_tiles = (num - tiles_in_current_row_) % tiles_per_row;
uint64_t remainder_of_tiles = 0;
bool moved_row = true;

if (rows_of_tiles_to_write == 0) {
remainder_of_tiles += num;
moved_row = false;
} else {
remainder_of_tiles = (num - tiles_in_current_row_) % tiles_per_row;
}
tiles_in_current_row_ = remainder_of_tiles;

// If we have not written a full row and we have reached the end of the
Expand Down Expand Up @@ -1517,7 +1525,8 @@ NDRange GlobalOrderWriter::ndranges_after_split(
}
uint64_t end = start_ + (rows_of_tiles_to_write * tile_extent) - 1;

if (tiles_in_current_row_ != 0 && !reached_end_of_fragment && end < end_) {
if (tiles_in_current_row_ != 0 && !reached_end_of_fragment && end < end_ &&
moved_row) {
end++;
}

Expand Down

0 comments on commit b1e0520

Please sign in to comment.