Skip to content

Commit 33798ab

Browse files
dfa1claude
andcommitted
fix(writer): clear two Sonar bugs in the SUM stat plumbing
- scalarDouble: branch instead of a ternary so the F32 path widens Float -> double explicitly rather than mixing boxed Double/Float operands (java:S2154). - ChunkRef: suppress java:S6218 — the byte[] stat components are never value-compared (instances live in per-column lists, read positionally), so the default identity equals is correct and an override would be dead code. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 58ceca2 commit 33798ab

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

writer/src/main/java/io/github/dfa1/vortex/writer/VortexWriter.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,9 +974,13 @@ private static long scalarLong(byte[] bytes) throws IOException {
974974
}
975975

976976
private static double scalarDouble(byte[] bytes) throws IOException {
977-
// Float columns serialise min/max as f64 (F64) or f32 (F32).
977+
// Float columns serialise min/max as f64 (F64) or f32 (F32). Branch rather than use a
978+
// ternary so the F32 path widens Float -> double explicitly instead of mixing boxed types.
978979
ScalarValue sv = decodeScalar(bytes);
979-
return sv.f64_value() != null ? sv.f64_value() : sv.f32_value();
980+
if (sv.f64_value() != null) {
981+
return sv.f64_value();
982+
}
983+
return sv.f32_value();
980984
}
981985

982986
private static ScalarValue decodeScalar(byte[] bytes) throws IOException {
@@ -1432,6 +1436,9 @@ private static Object buildCodesArray(Object data, PType ptype, Map<Object, Inte
14321436
private record SegRef(long offset, long len) {
14331437
}
14341438

1439+
// S6218: the byte[] stat components are never value-compared — ChunkRef instances are only
1440+
// collected in per-column lists and read positionally, so the default identity equals is fine.
1441+
@SuppressWarnings("java:S6218")
14351442
private record ChunkRef(int segIdx, long rowCount, byte[] statsMin, byte[] statsMax,
14361443
byte[] statsSum, long nullCount) {
14371444
boolean hasStats() {

0 commit comments

Comments
 (0)