Skip to content

Commit a741dcd

Browse files
dfa1claude
andcommitted
fix(compute): avoid Float/Double numeric promotion in boxDouble
A `Float ? : Double` conditional triggers binary numeric promotion (JLS 15.25): both branches unbox to double, so an f32 column's extreme was boxed back to Double, violating the documented Float contract and bit-identity with Reductions' MIN/MAX. Split into separate returns. Fixes SonarCloud S2154. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 2ba5488 commit a741dcd

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

reader/src/main/java/io/github/dfa1/vortex/reader/compute/FusedFilterAggregate.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,14 @@ private static Object boxDouble(boolean found, double value, boolean isFloat) {
222222
if (!found) {
223223
return null;
224224
}
225-
// (float) round-trips a value that already came from a float accessor without loss.
226-
return isFloat ? Float.valueOf((float) value) : Double.valueOf(value);
225+
// Kept as separate returns, not a `?:`: a Float/Double conditional triggers binary numeric
226+
// promotion (JLS 15.25), unboxing both branches to double and boxing an f32 column's extreme
227+
// back to Double — silently violating the Float contract above.
228+
if (isFloat) {
229+
// (float) round-trips a value that already came from a float accessor without loss.
230+
return Float.valueOf((float) value);
231+
}
232+
return Double.valueOf(value);
227233
}
228234

229235
/// Reports whether every leaf accepts row `i` (the n-ary `AND`), short-circuiting on the first

0 commit comments

Comments
 (0)