Skip to content

Commit 44df040

Browse files
committed
Silently ignore reversed ranges in AddRange for consistency
Replace the std::invalid_argument throw with a silent return on reversed ranges (pos_start > pos_end), consistent with how Add() handles invalid positions. The clamping already reduces the range to empty when start > end after clamping, so the explicit throw is removed entirely.
1 parent 9c06f42 commit 44df040

3 files changed

Lines changed: 5 additions & 11 deletions

File tree

src/iceberg/deletes/roaring_position_bitmap.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <cstring>
2323
#include <exception>
2424
#include <limits>
25-
#include <stdexcept>
2625
#include <utility>
2726
#include <vector>
2827

@@ -129,11 +128,6 @@ void RoaringPositionBitmap::Add(int64_t pos) {
129128
}
130129

131130
void RoaringPositionBitmap::AddRange(int64_t pos_start, int64_t pos_end) {
132-
if (pos_start > pos_end) {
133-
throw std::invalid_argument("AddRange requires pos_start <= pos_end, got [" +
134-
std::to_string(pos_start) + ", " +
135-
std::to_string(pos_end) + ")");
136-
}
137131
pos_start = std::max(pos_start, int64_t{0});
138132
pos_end = std::min(pos_end, kMaxPosition + 1);
139133
if (pos_start >= pos_end) {

src/iceberg/deletes/roaring_position_bitmap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class ICEBERG_EXPORT RoaringPositionBitmap {
6767
/// \brief Sets a range of positions [pos_start, pos_end).
6868
/// \param pos_start the start of the range (inclusive), clamped to 0
6969
/// \param pos_end the end of the range (exclusive), clamped to kMaxPosition + 1
70-
/// \throws std::invalid_argument if pos_start > pos_end
71-
/// \note If pos_start == pos_end, this method does nothing.
70+
/// \note If pos_start > pos_end, the call is silently ignored.
71+
/// If pos_start == pos_end, this method does nothing.
7272
/// Positions outside [0, kMaxPosition] are silently ignored.
7373
void AddRange(int64_t pos_start, int64_t pos_end);
7474

src/iceberg/test/roaring_position_bitmap_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <fstream>
2626
#include <random>
2727
#include <set>
28-
#include <stdexcept>
2928
#include <string>
3029
#include <vector>
3130

@@ -211,9 +210,10 @@ INSTANTIATE_TEST_SUITE_P(
211210
return info.param.name;
212211
});
213212

214-
TEST(RoaringPositionBitmapTest, TestAddRangeReversedThrows) {
213+
TEST(RoaringPositionBitmapTest, TestAddRangeReversedIsNoOp) {
215214
RoaringPositionBitmap bitmap;
216-
ASSERT_THROW(bitmap.AddRange(100, 50), std::invalid_argument);
215+
bitmap.AddRange(100, 50);
216+
ASSERT_TRUE(bitmap.IsEmpty());
217217
}
218218

219219
struct OrParams {

0 commit comments

Comments
 (0)