Skip to content

Commit 94d2fa4

Browse files
dfa1claude
andcommitted
refactor(writer): drop dead ptype arms in primitiveArrayLen
All three callers (the global-dict writer's two chunk loops and the isDictCandidate check, which runs after its narrow-int/F16/F32 early return) pass only dict-admitted ptypes: I32/U32, I64/U64, F64. The I8/U8, I16/U16/F16, and F32 arms were unreachable dead code. Collapse to default -> throw and retarget the unit test's artificial I8 case to F64. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f89072a commit 94d2fa4

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,14 +1321,14 @@ static boolean isDictCandidate(PType ptype, Object data) {
13211321
return seen.size() * 2 < n;
13221322
}
13231323

1324+
/// Length of a global-dict column's chunk array. Only the dict-admitted carriers ([#isDictCandidate])
1325+
/// — I32/U32, I64/U64, F64 — reach here; narrow-int and F16/F32 ptypes are rejected upstream.
13241326
static int primitiveArrayLen(Object data, PType ptype) {
13251327
return switch (ptype) {
1326-
case I8, U8 -> ((byte[]) data).length;
1327-
case I16, U16, F16 -> ((short[]) data).length;
13281328
case I32, U32 -> ((int[]) data).length;
13291329
case I64, U64 -> ((long[]) data).length;
1330-
case F32 -> ((float[]) data).length;
13311330
case F64 -> ((double[]) data).length;
1331+
default -> throw new IllegalStateException("ptype not admitted to the global dict: " + ptype);
13321332
};
13331333
}
13341334

writer/src/test/java/io/github/dfa1/vortex/writer/VortexWriterDictDecisionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ void codePTypeForSize_picksNarrowestUnsignedCarrier(int dictSize, PType expected
100100
// ── primitiveArrayLen / readPrimitiveElement ─────────────────────────────────
101101

102102
static Stream<Arguments> primitiveArrayLenCases() {
103+
// Only dict-admitted ptypes reach primitiveArrayLen: I32/U32 (int[]), I64/U64 (long[]), F64.
103104
return Stream.of(
104105
arguments(new long[]{1, 2, 3}, PType.I64, 3),
105106
arguments(new int[]{1, 2}, PType.I32, 2),
106-
arguments(new byte[]{1, 2, 3, 4}, PType.I8, 4));
107+
arguments(new double[]{1.0, 2.0, 3.0, 4.0}, PType.F64, 4));
107108
}
108109

109110
@ParameterizedTest

0 commit comments

Comments
 (0)