Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: update range end when merging overlapping subarray ranges. #5268

Merged
merged 6 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tiledb/sm/subarray/range_subset.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2023 TileDB, Inc.
* @copyright Copyright (c) 2017-2024 TileDB, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -169,7 +169,10 @@ struct MergeStrategy<
tail->start_as<T>() <= head_end;

if (can_merge) {
head->set_end_fixed(tail->end_fixed());
// Only update the end if the merging end is greater.
if (tail->end_as<T>() > head->end_as<T>()) {
head->set_end_fixed(tail->end_fixed());
}
merged_cells++;
} else {
head++;
Expand Down
30 changes: 30 additions & 0 deletions tiledb/sm/subarray/test/unit_range_subset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,36 @@ TEMPLATE_TEST_CASE_SIG(
check_subset_range_values(range_subset, 3, data3[0], data3[1]);
}
}

SECTION("Overlapping, encompassing ranges") {
// Note: this test is intended to duplicate regression test sc-53970,
// validating that a range which is fully encompassed within another
// will merge as expected.

// Add ranges.
T data1[2] = {3, 3};
T data2[2] = {1, 10};
std::vector<Range> ranges = {
Range(data1, 2 * sizeof(T)), Range(data2, 2 * sizeof(T))};
for (auto range : ranges) {
range_subset.add_range(range);
}
CHECK(range_subset.num_ranges() == 2);

// Sort and merge ranges.
ThreadPool pool{2};
range_subset.sort_and_merge_ranges(&pool, merge);

// Check range results.
if (merge) {
CHECK(range_subset.num_ranges() == 1);
check_subset_range_values(range_subset, 0, data2[0], data2[1]);
} else {
CHECK(range_subset.num_ranges() == 2);
check_subset_range_values(range_subset, 0, data2[0], data2[1]);
check_subset_range_values(range_subset, 1, data1[0], data1[1]);
}
}
}

TEST_CASE(
Expand Down
Loading