Skip to content

Commit 3a657a3

Browse files
dfa1claude
andcommitted
refactor(reader): FlatSegmentDecoder is SerializedArrayDecoder
Renamed after its exact Rust counterpart (SerializedArray in vortex-array/src/serde.rs: "a parsed but not-yet-decoded deserialized array" whose decode() resolves the encoding id against the spec table and consults the registry). "Flat" is a layout concept and "segment" a byte-range concept — the unit this class decodes is one serialized array message. VortexHandle's decodeFlatSegment follows as decodeSegment, next to rawSegment. Pitest target FQN and living docs updated; released changelog entries and ADR 0001 stay as written. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 10ad426 commit 3a657a3

14 files changed

Lines changed: 35 additions & 35 deletions

File tree

cli/src/main/java/io/github/dfa1/vortex/cli/tui/VortexInspectorTui.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ private void runDictLoad(InspectorTree.Node dictNode) {
607607
int segIdx = values.segments().getFirst();
608608
SegmentSpec spec = tree.segmentSpecs().get(segIdx);
609609
io.github.dfa1.vortex.reader.array.Array arr =
610-
handle.decodeFlatSegment(spec, dtype, values.rowCount(), arena);
610+
handle.decodeSegment(spec, dtype, values.rowCount(), arena);
611611
int n = (int) Math.min(arr.length(), DATA_PREVIEW_ROWS);
612612
List<String> out = new ArrayList<>(n);
613613
for (int i = 0; i < n; i++) {
@@ -722,7 +722,7 @@ private List<String> decodeStatsFlat(
722722
}
723723
int segIdx = flat.segments().getFirst();
724724
SegmentSpec spec = tree.segmentSpecs().get(segIdx);
725-
Array arr = handle.decodeFlatSegment(spec, statsDtype, flat.rowCount(), arena);
725+
Array arr = handle.decodeSegment(spec, statsDtype, flat.rowCount(), arena);
726726
return InspectorRender.formatStatsArray(arr, statsDtype);
727727
}
728728

docs/testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ bounds/parse classes** — not the whole codebase. It measures whether the tests
113113
```bash
114114
./mvnw -pl core -P pitest verify # IoBounds, PTypeIO
115115
./mvnw -pl reader -am -P pitest verify -DskipITs # Footer, Trailer, PostscriptParser,
116-
# SegmentSpec, Layout, FlatSegmentDecoder
116+
# SegmentSpec, Layout, SerializedArrayDecoder
117117
./mvnw -pl writer -am -P pitest verify -DskipITs # ChunkImpl, WriteRegistry
118118
```
119119

reader/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
<param>io.github.dfa1.vortex.reader.PostscriptParser</param>
9191
<param>io.github.dfa1.vortex.reader.SegmentSpec</param>
9292
<param>io.github.dfa1.vortex.reader.layout.Layout</param>
93-
<param>io.github.dfa1.vortex.reader.FlatSegmentDecoder</param>
93+
<param>io.github.dfa1.vortex.reader.SerializedArrayDecoder</param>
9494
</targetClasses>
9595
</configuration>
9696
</plugin>

reader/src/main/java/io/github/dfa1/vortex/reader/ScanIterator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ private List<ArrayStats> decodeZoneTable(String column) {
410410
long nZones = statsFlat.rowCount();
411411
SegmentSpec spec = file.footer().segmentSpecs().get(segIdx);
412412
try (Arena tableArena = Arena.ofConfined()) {
413-
Array decoded = file.decodeFlatSegment(spec, statsDtype, nZones, tableArena);
413+
Array decoded = file.decodeSegment(spec, statsDtype, nZones, tableArena);
414414
if (!(decoded instanceof StructArray table)) {
415415
return null;
416416
}
@@ -818,8 +818,8 @@ public Array decodeChild(Layout child, DType dtype) {
818818
}
819819

820820
@Override
821-
public Array decodeFlatSegment(SegmentSpec spec, DType dtype, long rowCount) {
822-
return file.decodeFlatSegment(spec, dtype, rowCount, arena);
821+
public Array decodeSegment(SegmentSpec spec, DType dtype, long rowCount) {
822+
return file.decodeSegment(spec, dtype, rowCount, arena);
823823
}
824824

825825
@Override

reader/src/main/java/io/github/dfa1/vortex/reader/FlatSegmentDecoder.java renamed to reader/src/main/java/io/github/dfa1/vortex/reader/SerializedArrayDecoder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
///
2424
/// [ReadRegistry] is pure dispatch; this class owns all file-format knowledge:
2525
/// FlatBuffer parsing, buffer-offset arithmetic, and encoding-spec lookup.
26-
final class FlatSegmentDecoder {
26+
final class SerializedArrayDecoder {
2727

2828
/// Hard cap on array-node recursion depth. The encoded array tree nests through child nodes
2929
/// (validity, patches, run-ends, dictionary codes/values, …); a crafted or self-referential
@@ -37,7 +37,7 @@ final class FlatSegmentDecoder {
3737
/// Creates a decoder backed by the given registry.
3838
///
3939
/// @param registry the registry used to dispatch to concrete decoder impls
40-
public FlatSegmentDecoder(ReadRegistry registry) {
40+
public SerializedArrayDecoder(ReadRegistry registry) {
4141
this.registry = registry;
4242
}
4343

reader/src/main/java/io/github/dfa1/vortex/reader/VortexHandle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface VortexHandle extends Closeable {
3232
/// @param rowCount number of logical rows in the segment
3333
/// @param arena allocator for decode output; lifetime matches the caller's chunk epoch
3434
/// @return the decoded array
35-
Array decodeFlatSegment(SegmentSpec spec, DType dtype, long rowCount, SegmentAllocator arena);
35+
Array decodeSegment(SegmentSpec spec, DType dtype, long rowCount, SegmentAllocator arena);
3636

3737
/// Returns a read-only view of the bytes backing the given segment spec.
3838
/// Writes through the returned segment throw `UnsupportedOperationException`.

reader/src/main/java/io/github/dfa1/vortex/reader/VortexHttpReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,13 @@ public long fileSize() {
288288
// ── HTTP helpers ──────────────────────────────────────────────────────────
289289

290290
@Override
291-
public io.github.dfa1.vortex.reader.array.Array decodeFlatSegment(
291+
public io.github.dfa1.vortex.reader.array.Array decodeSegment(
292292
io.github.dfa1.vortex.reader.SegmentSpec spec,
293293
DType dtype, long rowCount,
294294
java.lang.foreign.SegmentAllocator arenaOut
295295
) {
296296
MemorySegment seg = rawSegment(spec);
297-
return new FlatSegmentDecoder(registry)
297+
return new SerializedArrayDecoder(registry)
298298
.decode(seg, footer.arraySpecs(), dtype, rowCount, arenaOut);
299299
}
300300

reader/src/main/java/io/github/dfa1/vortex/reader/VortexReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,13 @@ private ArrayStats readFlatStats(Layout flat) {
317317
}
318318

319319
@Override
320-
public io.github.dfa1.vortex.reader.array.Array decodeFlatSegment(
320+
public io.github.dfa1.vortex.reader.array.Array decodeSegment(
321321
io.github.dfa1.vortex.reader.SegmentSpec spec,
322322
DType dtype, long rowCount,
323323
java.lang.foreign.SegmentAllocator arena
324324
) {
325325
MemorySegment seg = IoBounds.slice(fileSegment, spec.offset(), spec.length()).asReadOnly();
326-
return new FlatSegmentDecoder(registry)
326+
return new SerializedArrayDecoder(registry)
327327
.decode(seg, footer.arraySpecs(), dtype, rowCount, arena);
328328
}
329329

reader/src/main/java/io/github/dfa1/vortex/reader/layout/FlatLayoutDecoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public Array decode(LayoutDecodeContext ctx, Layout layout, DType dtype) {
2222
}
2323
int segIdx = layout.segments().getFirst();
2424
SegmentSpec spec = ctx.segmentSpec(segIdx);
25-
return ctx.decodeFlatSegment(spec, dtype, layout.rowCount());
25+
return ctx.decodeSegment(spec, dtype, layout.rowCount());
2626
}
2727
}

reader/src/main/java/io/github/dfa1/vortex/reader/layout/LayoutDecodeContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public interface LayoutDecodeContext {
3131
/// @param dtype logical type of the decoded array
3232
/// @param rowCount number of logical rows in the segment
3333
/// @return the decoded [Array]
34-
Array decodeFlatSegment(SegmentSpec spec, DType dtype, long rowCount);
34+
Array decodeSegment(SegmentSpec spec, DType dtype, long rowCount);
3535

3636
/// Resolves a segment index (as stored on a flat [Layout]) to its [SegmentSpec] in the
3737
/// file's segment table.

0 commit comments

Comments
 (0)