Skip to content

Commit d8abd52

Browse files
committed
Addressing PR comments, improving code coverage.
1 parent b770d9a commit d8abd52

19 files changed

Lines changed: 118 additions & 112 deletions

engine/table/src/main/java/io/deephaven/engine/table/impl/select/WhereFilterDelegating.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface WhereFilterDelegating {
1818

1919
/**
2020
* If the provided filter is an instance of {@code WhereFilterDelegating}, returns the effective wrapped filter of
21-
* that filter. Otherwise, returns the filter itself wrapped in an Optional.
21+
* that filter. Otherwise, returns the filter itself.
2222
*/
2323
static WhereFilter maybeUnwrapFilter(WhereFilter filter) {
2424
if (filter instanceof WhereFilterDelegating) {

engine/table/src/main/java/io/deephaven/engine/table/impl/sources/regioned/kernel/ByteRegionBinarySearchKernel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static RowSet binarySearchMinMax(
124124
}
125125

126126
// Validate that a logical range was found and the bounds didn't cross
127-
if (start != -1 && end != -1) {
127+
if (start != -1 && end != -1 && start <= end) {
128128
return RowSetFactory.fromRange(start, end);
129129
}
130130

@@ -156,9 +156,9 @@ public static RowSet binarySearchMin(
156156

157157
if (sortColumn.isAscending()) {
158158
start = findStartIndexAscending(region, firstKey, lastKey, min, minInc);
159-
end = (int) lastKey;
159+
end = Math.toIntExact(lastKey);
160160
} else {
161-
start = (int) firstKey;
161+
start = Math.toIntExact(firstKey);
162162
end = findEndIndexDescending(region, firstKey, lastKey, min, minInc);
163163
}
164164

@@ -193,11 +193,11 @@ public static RowSet binarySearchMax(
193193
final int end;
194194

195195
if (sortColumn.isAscending()) {
196-
start = (int) firstKey;
196+
start = Math.toIntExact(firstKey);
197197
end = findEndIndexAscending(region, firstKey, lastKey, max, maxInc);
198198
} else {
199199
start = findStartIndexDescending(region, firstKey, lastKey, max, maxInc);
200-
end = (int) lastKey;
200+
end = Math.toIntExact(lastKey);
201201
}
202202

203203
if (start != -1 && end != -1 && start <= end) {

engine/table/src/main/java/io/deephaven/engine/table/impl/sources/regioned/kernel/CharRegionBinarySearchKernel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static RowSet binarySearchMinMax(
120120
}
121121

122122
// Validate that a logical range was found and the bounds didn't cross
123-
if (start != -1 && end != -1) {
123+
if (start != -1 && end != -1 && start <= end) {
124124
return RowSetFactory.fromRange(start, end);
125125
}
126126

@@ -152,9 +152,9 @@ public static RowSet binarySearchMin(
152152

153153
if (sortColumn.isAscending()) {
154154
start = findStartIndexAscending(region, firstKey, lastKey, min, minInc);
155-
end = (int) lastKey;
155+
end = Math.toIntExact(lastKey);
156156
} else {
157-
start = (int) firstKey;
157+
start = Math.toIntExact(firstKey);
158158
end = findEndIndexDescending(region, firstKey, lastKey, min, minInc);
159159
}
160160

@@ -189,11 +189,11 @@ public static RowSet binarySearchMax(
189189
final int end;
190190

191191
if (sortColumn.isAscending()) {
192-
start = (int) firstKey;
192+
start = Math.toIntExact(firstKey);
193193
end = findEndIndexAscending(region, firstKey, lastKey, max, maxInc);
194194
} else {
195195
start = findStartIndexDescending(region, firstKey, lastKey, max, maxInc);
196-
end = (int) lastKey;
196+
end = Math.toIntExact(lastKey);
197197
}
198198

199199
if (start != -1 && end != -1 && start <= end) {

engine/table/src/main/java/io/deephaven/engine/table/impl/sources/regioned/kernel/DoubleRegionBinarySearchKernel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static RowSet binarySearchMinMax(
124124
}
125125

126126
// Validate that a logical range was found and the bounds didn't cross
127-
if (start != -1 && end != -1) {
127+
if (start != -1 && end != -1 && start <= end) {
128128
return RowSetFactory.fromRange(start, end);
129129
}
130130

@@ -156,9 +156,9 @@ public static RowSet binarySearchMin(
156156

157157
if (sortColumn.isAscending()) {
158158
start = findStartIndexAscending(region, firstKey, lastKey, min, minInc);
159-
end = (int) lastKey;
159+
end = Math.toIntExact(lastKey);
160160
} else {
161-
start = (int) firstKey;
161+
start = Math.toIntExact(firstKey);
162162
end = findEndIndexDescending(region, firstKey, lastKey, min, minInc);
163163
}
164164

@@ -193,11 +193,11 @@ public static RowSet binarySearchMax(
193193
final int end;
194194

195195
if (sortColumn.isAscending()) {
196-
start = (int) firstKey;
196+
start = Math.toIntExact(firstKey);
197197
end = findEndIndexAscending(region, firstKey, lastKey, max, maxInc);
198198
} else {
199199
start = findStartIndexDescending(region, firstKey, lastKey, max, maxInc);
200-
end = (int) lastKey;
200+
end = Math.toIntExact(lastKey);
201201
}
202202

203203
if (start != -1 && end != -1 && start <= end) {

engine/table/src/main/java/io/deephaven/engine/table/impl/sources/regioned/kernel/FloatRegionBinarySearchKernel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static RowSet binarySearchMinMax(
124124
}
125125

126126
// Validate that a logical range was found and the bounds didn't cross
127-
if (start != -1 && end != -1) {
127+
if (start != -1 && end != -1 && start <= end) {
128128
return RowSetFactory.fromRange(start, end);
129129
}
130130

@@ -156,9 +156,9 @@ public static RowSet binarySearchMin(
156156

157157
if (sortColumn.isAscending()) {
158158
start = findStartIndexAscending(region, firstKey, lastKey, min, minInc);
159-
end = (int) lastKey;
159+
end = Math.toIntExact(lastKey);
160160
} else {
161-
start = (int) firstKey;
161+
start = Math.toIntExact(firstKey);
162162
end = findEndIndexDescending(region, firstKey, lastKey, min, minInc);
163163
}
164164

@@ -193,11 +193,11 @@ public static RowSet binarySearchMax(
193193
final int end;
194194

195195
if (sortColumn.isAscending()) {
196-
start = (int) firstKey;
196+
start = Math.toIntExact(firstKey);
197197
end = findEndIndexAscending(region, firstKey, lastKey, max, maxInc);
198198
} else {
199199
start = findStartIndexDescending(region, firstKey, lastKey, max, maxInc);
200-
end = (int) lastKey;
200+
end = Math.toIntExact(lastKey);
201201
}
202202

203203
if (start != -1 && end != -1 && start <= end) {

engine/table/src/main/java/io/deephaven/engine/table/impl/sources/regioned/kernel/IntRegionBinarySearchKernel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static RowSet binarySearchMinMax(
124124
}
125125

126126
// Validate that a logical range was found and the bounds didn't cross
127-
if (start != -1 && end != -1) {
127+
if (start != -1 && end != -1 && start <= end) {
128128
return RowSetFactory.fromRange(start, end);
129129
}
130130

@@ -156,9 +156,9 @@ public static RowSet binarySearchMin(
156156

157157
if (sortColumn.isAscending()) {
158158
start = findStartIndexAscending(region, firstKey, lastKey, min, minInc);
159-
end = (int) lastKey;
159+
end = Math.toIntExact(lastKey);
160160
} else {
161-
start = (int) firstKey;
161+
start = Math.toIntExact(firstKey);
162162
end = findEndIndexDescending(region, firstKey, lastKey, min, minInc);
163163
}
164164

@@ -193,11 +193,11 @@ public static RowSet binarySearchMax(
193193
final int end;
194194

195195
if (sortColumn.isAscending()) {
196-
start = (int) firstKey;
196+
start = Math.toIntExact(firstKey);
197197
end = findEndIndexAscending(region, firstKey, lastKey, max, maxInc);
198198
} else {
199199
start = findStartIndexDescending(region, firstKey, lastKey, max, maxInc);
200-
end = (int) lastKey;
200+
end = Math.toIntExact(lastKey);
201201
}
202202

203203
if (start != -1 && end != -1 && start <= end) {

engine/table/src/main/java/io/deephaven/engine/table/impl/sources/regioned/kernel/LongRegionBinarySearchKernel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static RowSet binarySearchMinMax(
124124
}
125125

126126
// Validate that a logical range was found and the bounds didn't cross
127-
if (start != -1 && end != -1) {
127+
if (start != -1 && end != -1 && start <= end) {
128128
return RowSetFactory.fromRange(start, end);
129129
}
130130

@@ -156,9 +156,9 @@ public static RowSet binarySearchMin(
156156

157157
if (sortColumn.isAscending()) {
158158
start = findStartIndexAscending(region, firstKey, lastKey, min, minInc);
159-
end = (int) lastKey;
159+
end = Math.toIntExact(lastKey);
160160
} else {
161-
start = (int) firstKey;
161+
start = Math.toIntExact(firstKey);
162162
end = findEndIndexDescending(region, firstKey, lastKey, min, minInc);
163163
}
164164

@@ -193,11 +193,11 @@ public static RowSet binarySearchMax(
193193
final int end;
194194

195195
if (sortColumn.isAscending()) {
196-
start = (int) firstKey;
196+
start = Math.toIntExact(firstKey);
197197
end = findEndIndexAscending(region, firstKey, lastKey, max, maxInc);
198198
} else {
199199
start = findStartIndexDescending(region, firstKey, lastKey, max, maxInc);
200-
end = (int) lastKey;
200+
end = Math.toIntExact(lastKey);
201201
}
202202

203203
if (start != -1 && end != -1 && start <= end) {

engine/table/src/main/java/io/deephaven/engine/table/impl/sources/regioned/kernel/ObjectRegionBinarySearchKernel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static RowSet binarySearchMinMax(
123123
}
124124

125125
// Validate that a logical range was found and the bounds didn't cross
126-
if (start != -1 && end != -1) {
126+
if (start != -1 && end != -1 && start <= end) {
127127
return RowSetFactory.fromRange(start, end);
128128
}
129129

@@ -155,9 +155,9 @@ public static RowSet binarySearchMin(
155155

156156
if (sortColumn.isAscending()) {
157157
start = findStartIndexAscending(region, firstKey, lastKey, min, minInc);
158-
end = (int) lastKey;
158+
end = Math.toIntExact(lastKey);
159159
} else {
160-
start = (int) firstKey;
160+
start = Math.toIntExact(firstKey);
161161
end = findEndIndexDescending(region, firstKey, lastKey, min, minInc);
162162
}
163163

@@ -192,11 +192,11 @@ public static RowSet binarySearchMax(
192192
final int end;
193193

194194
if (sortColumn.isAscending()) {
195-
start = (int) firstKey;
195+
start = Math.toIntExact(firstKey);
196196
end = findEndIndexAscending(region, firstKey, lastKey, max, maxInc);
197197
} else {
198198
start = findStartIndexDescending(region, firstKey, lastKey, max, maxInc);
199-
end = (int) lastKey;
199+
end = Math.toIntExact(lastKey);
200200
}
201201

202202
if (start != -1 && end != -1 && start <= end) {

engine/table/src/main/java/io/deephaven/engine/table/impl/sources/regioned/kernel/ShortRegionBinarySearchKernel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static RowSet binarySearchMinMax(
124124
}
125125

126126
// Validate that a logical range was found and the bounds didn't cross
127-
if (start != -1 && end != -1) {
127+
if (start != -1 && end != -1 && start <= end) {
128128
return RowSetFactory.fromRange(start, end);
129129
}
130130

@@ -156,9 +156,9 @@ public static RowSet binarySearchMin(
156156

157157
if (sortColumn.isAscending()) {
158158
start = findStartIndexAscending(region, firstKey, lastKey, min, minInc);
159-
end = (int) lastKey;
159+
end = Math.toIntExact(lastKey);
160160
} else {
161-
start = (int) firstKey;
161+
start = Math.toIntExact(firstKey);
162162
end = findEndIndexDescending(region, firstKey, lastKey, min, minInc);
163163
}
164164

@@ -193,11 +193,11 @@ public static RowSet binarySearchMax(
193193
final int end;
194194

195195
if (sortColumn.isAscending()) {
196-
start = (int) firstKey;
196+
start = Math.toIntExact(firstKey);
197197
end = findEndIndexAscending(region, firstKey, lastKey, max, maxInc);
198198
} else {
199199
start = findStartIndexDescending(region, firstKey, lastKey, max, maxInc);
200-
end = (int) lastKey;
200+
end = Math.toIntExact(lastKey);
201201
}
202202

203203
if (start != -1 && end != -1 && start <= end) {

engine/table/src/test/java/io/deephaven/engine/table/impl/QueryTableWhereTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2726,7 +2726,7 @@ public void testMergedTableSources() {
27262726
filter1.withRespectedBarriers("1").withDeclaredBarriers("2"),
27272727
postFilter.withRespectedBarriers("2")));
27282728
assertEquals(200_000, preFilter.numRowsProcessed());
2729-
assertEquals(100_000, filter0.numRowsProcessed()); // 100_000 from source1, 0 from source2
2729+
assertEquals(100_000, filter1.numRowsProcessed()); // 100_000 from source1, 0 from source2
27302730
assertEquals(99_999, postFilter.numRowsProcessed()); // 99_000 from source1, 0 from source2
27312731

27322732
assertEquals(99_999, res1.size());

0 commit comments

Comments
 (0)