Skip to content

Commit 3a4dcdf

Browse files
dfa1claude
andcommitted
refactor(reader)!: drop dead EmptyArray, enforce dtype→family invariant
EmptyArray was never constructed in production — empties are represented as zero-length typed arrays in their own family (LazyConstant*, Materialized* len 0). It only occupied a slot in sealed Array's permits, adding a dead case to exhaustive switches, and broke the dtype→family invariant (EmptyArray(I64) is not a LongArray, so `case LongArray` consumers would miss it). Remove the type and its permit. The lone user — a universal stub decoder in VortexReaderTest — now returns a zero-length UnknownArray. BREAKING CHANGE: EmptyArray removed from the sealed Array permits. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent fda2398 commit 3a4dcdf

3 files changed

Lines changed: 6 additions & 26 deletions

File tree

reader/src/main/java/io/github/dfa1/vortex/reader/array/Array.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/// Buffers are `MemorySegment` slices backed by the memory-mapped file; lifetime
1010
/// is tied to the `VortexFile`'s Arena.
1111
public sealed interface Array
12-
permits BoolArray, ByteArray, DecimalArray, DoubleArray, EmptyArray, FixedSizeListArray,
12+
permits BoolArray, ByteArray, DecimalArray, DoubleArray, FixedSizeListArray,
1313
Float16Array, FloatArray, GenericArray, IntArray, ListArray, ListViewArray,
1414
LongArray, MaskedArray, NullArray, ShortArray, StructArray, UnknownArray,
1515
VarBinArray, VariantArray {

reader/src/main/java/io/github/dfa1/vortex/reader/array/EmptyArray.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

reader/src/test/java/io/github/dfa1/vortex/reader/VortexReaderTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import io.github.dfa1.vortex.core.VortexException;
55
import io.github.dfa1.vortex.core.VortexFormat;
66
import io.github.dfa1.vortex.reader.array.Array;
7-
import io.github.dfa1.vortex.reader.array.EmptyArray;
87
import io.github.dfa1.vortex.reader.array.UnknownArray;
98
import io.github.dfa1.vortex.reader.decode.DecodeContext;
109
import io.github.dfa1.vortex.reader.decode.EncodingDecoder;
@@ -16,6 +15,7 @@
1615
import org.junit.jupiter.params.provider.ValueSource;
1716

1817
import java.io.IOException;
18+
import java.lang.foreign.MemorySegment;
1919
import java.net.URISyntaxException;
2020
import java.nio.ByteOrder;
2121
import java.nio.file.Files;
@@ -44,7 +44,10 @@ public boolean accepts(DType dtype) {
4444

4545
@Override
4646
public Array decode(DecodeContext ctx) {
47-
return EmptyArray.of(ctx.dtype());
47+
// Generic zero-length stand-in: scan chunk row count comes from the
48+
// layout, so the leaf array's contents are irrelevant to this test.
49+
return new UnknownArray("stub", ctx.dtype(), 0, null,
50+
new MemorySegment[0], new Array[0]);
4851
}
4952
});
5053
}

0 commit comments

Comments
 (0)