From 06b1cc9866feb59481acd3c66506b456fdb6104c Mon Sep 17 00:00:00 2001 From: Davide Angelocola Date: Tue, 23 Jun 2026 21:37:08 +0200 Subject: [PATCH] refactor(core): canonical DType constants, drop per-class duplicates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the no-arg non-nullable DType factories with shared immutable constants on the DType interface: - Primitives: DType.I8 … I64, U8 … U64, F16/F32/F64 - Others: DType.BOOL, UTF8, BINARY, NULL, VARIANT Removes the per-class private *_DTYPE fields in the encoders/decoders and the 130+ inline `new DType.X(false)` / factory call sites across all modules. Build a nullable column from a constant via asNullable(). Breaking (minor): the no-arg factories DType.i8()…f64(), bool_(), utf8(), binary(), null_(), variant() are removed. The decimal(..) / structBuilder() factories and the record constructors are unchanged. Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 10 ++ README.md | 8 +- .../dfa1/vortex/cli/CliTestSupport.java | 11 +- .../dfa1/vortex/cli/SchemaCommandTest.java | 16 +-- .../dfa1/vortex/cli/tui/ArrayFixtures.java | 18 +-- .../dfa1/vortex/cli/tui/GridRenderTest.java | 23 ++-- .../vortex/cli/tui/InspectorRenderTest.java | 10 +- .../dfa1/vortex/cli/tui/TuiTestSupport.java | 17 ++- .../io/github/dfa1/vortex/core/DType.java | 120 +++++++----------- .../dfa1/vortex/core/DTypeExtensionTest.java | 2 +- .../dfa1/vortex/core/DTypeFactoriesTest.java | 40 +++--- .../vortex/core/DTypeStructBuilderTest.java | 24 ++-- .../vortex/core/DTypeWithNullableTest.java | 22 ++-- .../github/dfa1/vortex/encoding/DTypes.java | 28 ++-- .../github/dfa1/vortex/csv/CsvImporter.java | 8 +- .../dfa1/vortex/csv/CsvExporterTest.java | 7 +- .../dfa1/vortex/csv/CsvImporterTest.java | 13 +- docs/reference.md | 18 +-- docs/tutorial.md | 15 ++- .../dfa1/vortex/inspect/ZonedStatsSchema.java | 21 ++- .../vortex/inspect/InspectorTreeTest.java | 27 ++-- .../vortex/inspect/VortexInspectorTest.java | 9 +- .../vortex/inspect/ZonedStatsSchemaTest.java | 16 +-- ...stantEncodingSelectionIntegrationTest.java | 3 +- .../FileSizeComparisonIntegrationTest.java | 19 ++- .../JavaRoundTripIntegrationTest.java | 3 +- .../JavaWritesRustReadsIntegrationTest.java | 40 +++--- .../RustWritesJavaReadsIntegrationTest.java | 2 +- ...antJavaWritesRustReadsIntegrationTest.java | 5 +- .../LargeCsvRoundTripLoadIntegrationTest.java | 17 ++- .../dfa1/vortex/jdbc/JdbcImporterTest.java | 9 +- .../vortex/parquet/ParquetImporterTest.java | 14 +- .../performance/JavaVsJniReadBenchmark.java | 15 +-- .../performance/JavaVsJniWriteBenchmark.java | 15 +-- .../performance/LazyArrayWalkBenchmark.java | 11 +- .../dfa1/vortex/reader/ScanIterator.java | 2 +- .../reader/decode/AlpEncodingDecoder.java | 6 +- .../reader/decode/AlpRdEncodingDecoder.java | 11 +- .../reader/decode/ChunkedEncodingDecoder.java | 3 +- .../reader/decode/MaskedEncodingDecoder.java | 2 +- .../reader/decode/PatchedEncodingDecoder.java | 4 +- .../reader/decode/PcoEncodingDecoder.java | 2 +- .../decode/PrimitiveEncodingDecoder.java | 2 +- .../reader/decode/RleEncodingDecoder.java | 2 +- .../reader/decode/StructEncodingDecoder.java | 4 +- .../reader/decode/ZstdEncodingDecoder.java | 2 +- .../extension/UuidExtensionDecoder.java | 3 +- .../reader/FlatSegmentBoundsSecurityTest.java | 3 +- .../reader/FlatSegmentDecoderDecodeTest.java | 3 +- .../vortex/reader/VortexHttpReaderIT.java | 7 +- .../reader/array/DictRecordSmokeTest.java | 19 ++- .../vortex/reader/array/DoubleArrayTest.java | 3 +- .../vortex/reader/array/GenericArrayTest.java | 3 +- .../vortex/reader/array/IntArrayTest.java | 3 +- .../reader/array/LazyAlpDoubleArrayTest.java | 3 +- .../reader/array/LazyAlpFloatArrayTest.java | 3 +- .../reader/array/LazyAlpRdArrayTest.java | 11 +- .../reader/array/LazyConstantArrayTest.java | 47 ++++--- .../reader/array/LazyDecimalArrayTest.java | 3 +- .../array/LazyDecimalBytePartsArrayTest.java | 15 +-- .../reader/array/LazyForByteArrayTest.java | 3 +- .../reader/array/LazyForIntArrayTest.java | 3 +- .../reader/array/LazyForLongArrayTest.java | 3 +- .../reader/array/LazyForShortArrayTest.java | 3 +- .../vortex/reader/array/LazyRleArrayTest.java | 13 +- .../reader/array/LazyZigZagByteArrayTest.java | 3 +- .../reader/array/LazyZigZagIntArrayTest.java | 3 +- .../reader/array/LazyZigZagLongArrayTest.java | 3 +- .../array/LazyZigZagShortArrayTest.java | 3 +- .../vortex/reader/array/ListArraysTest.java | 3 +- .../vortex/reader/array/LongArrayTest.java | 3 +- .../vortex/reader/array/OffsetArrayTest.java | 15 +-- .../vortex/reader/array/VarBinArrayTest.java | 2 +- .../reader/array/VarBinChunkedModeTest.java | 4 +- .../reader/array/VarBinViewModeTest.java | 2 +- .../reader/decode/AlpEncodingDecoderTest.java | 7 +- .../DateTimePartsEncodingDecoderTest.java | 4 +- .../decode/DictEncodingDecoderTest.java | 32 ++--- .../decode/PatchedEncodingDecoderTest.java | 7 +- .../reader/decode/PcoEncodingDecoderTest.java | 40 +++--- .../decode/VarBinEncodingDecoderTest.java | 2 +- .../decode/VarBinViewEncodingDecoderTest.java | 4 +- .../decode/VariantEncodingDecoderTest.java | 19 ++- .../decode/ZigZagEncodingDecoderTest.java | 2 +- .../extension/DateExtensionDecoderTest.java | 5 +- .../extension/ExtensionStorageTest.java | 3 +- .../extension/ExtensionTestSupport.java | 7 +- .../extension/TimeExtensionDecoderTest.java | 4 +- .../TimestampExtensionDecoderTest.java | 5 +- .../extension/UuidExtensionDecoderTest.java | 5 +- .../dfa1/vortex/writer/VortexWriter.java | 8 +- .../writer/encode/AlpEncodingEncoder.java | 6 +- .../writer/encode/AlpRdEncodingEncoder.java | 21 ++- .../writer/encode/ChunkedEncodingEncoder.java | 3 +- .../encode/DateTimePartsEncodingEncoder.java | 14 +- .../writer/encode/MaskedEncodingEncoder.java | 2 +- .../writer/encode/PatchedEncodingEncoder.java | 4 +- .../writer/encode/UuidExtensionEncoder.java | 3 +- .../writer/encode/VariantEncodingEncoder.java | 5 +- .../vortex/writer/BitpackedEncodingTest.java | 3 +- .../dfa1/vortex/writer/ChunkImplTest.java | 12 +- .../dfa1/vortex/writer/DeltaEncodingTest.java | 3 +- .../dfa1/vortex/writer/DictEncodingTest.java | 3 +- .../dfa1/vortex/writer/GlobalDictF64Test.java | 3 +- .../writer/GlobalDictPrimitiveTest.java | 9 +- .../vortex/writer/GlobalDictUtf8Test.java | 2 +- .../writer/MultiChunkUtf8RoundTripTest.java | 2 +- .../vortex/writer/TypedChunkBuilderTest.java | 8 +- .../dfa1/vortex/writer/VortexWriterTest.java | 8 +- .../dfa1/vortex/writer/WriterZoneMapTest.java | 18 +-- .../vortex/writer/ZoneMapPruningTest.java | 3 +- ...BitpackedConstantPatchesBroadcastTest.java | 3 +- .../encode/ChunkedEncodingEncoderTest.java | 15 +-- .../DateTimePartsEncodingEncoderTest.java | 5 +- .../encode/DecimalEncodingEncoderTest.java | 3 +- .../writer/encode/ExtEncodingEncoderTest.java | 13 +- .../encode/MaskedEncodingEncoderTest.java | 6 +- .../encode/PatchedEncodingEncoderTest.java | 4 +- .../writer/encode/PcoEncodingEncoderTest.java | 17 ++- .../encode/PrimitiveEncodingEncoderTest.java | 13 +- .../writer/encode/RleEncodingEncoderTest.java | 27 ++-- .../encode/SequenceEncodingEncoderTest.java | 6 +- .../encode/TimeExtensionEncoderTest.java | 6 +- .../encode/VarBinEncodingEncoderTest.java | 3 +- .../encode/VariantEncodingEncoderTest.java | 2 +- .../encode/ZigZagEncodingEncoderTest.java | 2 +- .../encode/ZstdEncodingEncoderTest.java | 4 +- 127 files changed, 592 insertions(+), 691 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1ea5e47..a483e2ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to **vortex-java** are documented here. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Canonical non-nullable `DType` constants: primitives `DType.I8` … `DType.I64`, `DType.U8` … `DType.U64`, `DType.F16`/`F32`/`F64`, plus `DType.BOOL`, `DType.UTF8`, `DType.BINARY`, `DType.NULL`, `DType.VARIANT`. Shared immutable instances — prefer them over `new DType.Primitive(pt, false)` / `new DType.Utf8(false)` etc.; build a nullable column with `DType.I64.asNullable()`. The encoders/decoders that each declared private `*_DTYPE` fields now reference these. + +### Removed + +- **Breaking (minor):** the no-arg factory methods `DType.i8()` … `DType.f64()`, `DType.bool_()`, `DType.utf8()`, `DType.binary()`, `DType.null_()`, `DType.variant()` are replaced by the constants above (`DType.i64()` → `DType.I64`, `DType.utf8()` → `DType.UTF8`). The `DType.decimal(..)`/`DType.structBuilder()` factories and the record constructors are unchanged. + ## [0.8.3] — 2026-06-23 A **Sonar-driven refactoring** release: no new file-format capability, but a focused pass using SonarCloud findings to drive cleanups — dead code removed, duplication factored out, and one hot-loop micro-optimisation. Each finding was triaged (lead, not verdict) so the changes preserve behaviour and the JIT vectorisation of the hot decode loops. The interpretation framework behind this is now documented in `docs/testing.md`. diff --git a/README.md b/README.md index 69573d8c..f613733c 100644 --- a/README.md +++ b/README.md @@ -97,10 +97,10 @@ try (VortexReader vf = VortexReader.open(Path.of("data/example.vortex")); ```java DType.Struct schema = DType.structBuilder() - .field("timestamp", DType.i64()) - .field("symbol", DType.utf8()) - .field("price", DType.f64()) - .field("volume", DType.i64().asNullable()) // boxed Long[] → nullable + .field("timestamp", DType.I64) + .field("symbol", DType.UTF8) + .field("price", DType.F64) + .field("volume", DType.I64.asNullable()) // boxed Long[] → nullable .build(); try (var ch = FileChannel.open(Path.of("data/example.vortex"), diff --git a/cli/src/test/java/io/github/dfa1/vortex/cli/CliTestSupport.java b/cli/src/test/java/io/github/dfa1/vortex/cli/CliTestSupport.java index 622256b9..8c8e62e2 100644 --- a/cli/src/test/java/io/github/dfa1/vortex/cli/CliTestSupport.java +++ b/cli/src/test/java/io/github/dfa1/vortex/cli/CliTestSupport.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.cli; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.writer.VortexWriter; import io.github.dfa1.vortex.writer.WriteOptions; @@ -27,7 +26,7 @@ static Path writeSmallVortex(Path dir, String name) throws IOException { Path file = dir.resolve(name); DType.Struct schema = new DType.Struct( List.of("id"), - List.of(new DType.Primitive(PType.I64, false)), + List.of(DType.I64), false); try (FileChannel ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); VortexWriter writer = VortexWriter.create(ch, schema, WriteOptions.defaults())) { @@ -44,10 +43,10 @@ static Path writeTypedVortex(Path dir, String name) throws IOException { DType.Struct schema = new DType.Struct( List.of("id", "qty", "price", "name"), List.of( - new DType.Primitive(PType.I64, false), - new DType.Primitive(PType.I32, false), - new DType.Primitive(PType.F64, false), - new DType.Utf8(false)), + DType.I64, + DType.I32, + DType.F64, + DType.UTF8), false); try (FileChannel ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); VortexWriter writer = VortexWriter.create(ch, schema, WriteOptions.defaults())) { diff --git a/cli/src/test/java/io/github/dfa1/vortex/cli/SchemaCommandTest.java b/cli/src/test/java/io/github/dfa1/vortex/cli/SchemaCommandTest.java index f1921056..9bb36eaa 100644 --- a/cli/src/test/java/io/github/dfa1/vortex/cli/SchemaCommandTest.java +++ b/cli/src/test/java/io/github/dfa1/vortex/cli/SchemaCommandTest.java @@ -64,17 +64,17 @@ void validFile_printsStructSchemaAndReturnsOk(@TempDir Path tmp) throws IOExcept } static Stream dtypeCases() { - DType i64 = new DType.Primitive(PType.I64, false); + DType i64 = DType.I64; return Stream.of( - arguments(new DType.Primitive(PType.I64, false), "I64"), + arguments(DType.I64, "I64"), arguments(new DType.Primitive(PType.I32, true), "I32?"), - arguments(new DType.Utf8(false), "utf8"), + arguments(DType.UTF8, "utf8"), arguments(new DType.Utf8(true), "utf8?"), - arguments(new DType.Binary(false), "binary"), + arguments(DType.BINARY, "binary"), arguments(new DType.Binary(true), "binary?"), - arguments(new DType.Bool(false), "bool"), + arguments(DType.BOOL, "bool"), arguments(new DType.Bool(true), "bool?"), - arguments(new DType.Null(false), "null"), + arguments(DType.NULL, "null"), arguments(new DType.Decimal((byte) 10, (byte) 2, false), "decimal(10,2)"), arguments(new DType.Decimal((byte) 10, (byte) 2, true), "decimal(10,2)?"), arguments(new DType.List(i64, false), "list"), @@ -83,9 +83,9 @@ static Stream dtypeCases() { arguments(new DType.FixedSizeList(i64, 4, true), "list[4]?"), arguments(new DType.Extension("vortex.uuid", i64, null, false), "ext"), arguments(new DType.Extension("vortex.uuid", i64, null, true), "ext?"), - arguments(new DType.Variant(false), "variant"), + arguments(DType.VARIANT, "variant"), arguments(new DType.Variant(true), "variant?"), - arguments(new DType.Struct(List.of("a", "b"), List.of(i64, new DType.Utf8(false)), false), + arguments(new DType.Struct(List.of("a", "b"), List.of(i64, DType.UTF8), false), "struct")); } diff --git a/cli/src/test/java/io/github/dfa1/vortex/cli/tui/ArrayFixtures.java b/cli/src/test/java/io/github/dfa1/vortex/cli/tui/ArrayFixtures.java index b9c18479..5d6f632a 100644 --- a/cli/src/test/java/io/github/dfa1/vortex/cli/tui/ArrayFixtures.java +++ b/cli/src/test/java/io/github/dfa1/vortex/cli/tui/ArrayFixtures.java @@ -36,7 +36,7 @@ static LongArray longs(Arena arena, long... vs) { for (int i = 0; i < vs.length; i++) { seg.setAtIndex(ValueLayout.JAVA_LONG, i, vs[i]); } - return new MaterializedLongArray(new DType.Primitive(PType.I64, false), vs.length, seg.asReadOnly()); + return new MaterializedLongArray(DType.I64, vs.length, seg.asReadOnly()); } static IntArray ints(Arena arena, int... vs) { @@ -44,7 +44,7 @@ static IntArray ints(Arena arena, int... vs) { for (int i = 0; i < vs.length; i++) { seg.setAtIndex(ValueLayout.JAVA_INT, i, vs[i]); } - return new MaterializedIntArray(new DType.Primitive(PType.I32, false), vs.length, seg.asReadOnly()); + return new MaterializedIntArray(DType.I32, vs.length, seg.asReadOnly()); } static ShortArray shorts(Arena arena, short... vs) { @@ -52,7 +52,7 @@ static ShortArray shorts(Arena arena, short... vs) { for (int i = 0; i < vs.length; i++) { seg.setAtIndex(ValueLayout.JAVA_SHORT, i, vs[i]); } - return new MaterializedShortArray(new DType.Primitive(PType.I16, false), vs.length, seg.asReadOnly()); + return new MaterializedShortArray(DType.I16, vs.length, seg.asReadOnly()); } static ByteArray bytes(Arena arena, byte... vs) { @@ -60,7 +60,7 @@ static ByteArray bytes(Arena arena, byte... vs) { for (int i = 0; i < vs.length; i++) { seg.set(ValueLayout.JAVA_BYTE, i, vs[i]); } - return new MaterializedByteArray(new DType.Primitive(PType.I8, false), vs.length, seg.asReadOnly()); + return new MaterializedByteArray(DType.I8, vs.length, seg.asReadOnly()); } static DoubleArray doubles(Arena arena, double... vs) { @@ -68,7 +68,7 @@ static DoubleArray doubles(Arena arena, double... vs) { for (int i = 0; i < vs.length; i++) { seg.setAtIndex(ValueLayout.JAVA_DOUBLE, i, vs[i]); } - return new MaterializedDoubleArray(new DType.Primitive(PType.F64, false), vs.length, seg.asReadOnly()); + return new MaterializedDoubleArray(DType.F64, vs.length, seg.asReadOnly()); } static FloatArray floats(Arena arena, float... vs) { @@ -76,7 +76,7 @@ static FloatArray floats(Arena arena, float... vs) { for (int i = 0; i < vs.length; i++) { seg.setAtIndex(ValueLayout.JAVA_FLOAT, i, vs[i]); } - return new MaterializedFloatArray(new DType.Primitive(PType.F32, false), vs.length, seg.asReadOnly()); + return new MaterializedFloatArray(DType.F32, vs.length, seg.asReadOnly()); } static BoolArray bools(Arena arena, boolean... vs) { @@ -89,7 +89,7 @@ static BoolArray bools(Arena arena, boolean... vs) { seg.set(ValueLayout.JAVA_BYTE, byteIdx, (byte) (cur | (1 << (i & 7)))); } } - return new MaterializedBoolArray(new DType.Bool(false), vs.length, seg.asReadOnly()); + return new MaterializedBoolArray(DType.BOOL, vs.length, seg.asReadOnly()); } /// Builds a UTF-8 [VarBinArray] (`OffsetMode`, I64 offsets) from the given strings. @@ -98,12 +98,12 @@ static VarBinArray utf8(Arena arena, String... vs) { for (int i = 0; i < vs.length; i++) { rows[i] = vs[i].getBytes(StandardCharsets.UTF_8); } - return varbin(arena, new DType.Utf8(false), rows); + return varbin(arena, DType.UTF8, rows); } /// Builds a binary [VarBinArray] (`OffsetMode`, I64 offsets) from the given byte rows. static VarBinArray binary(Arena arena, byte[]... rows) { - return varbin(arena, new DType.Binary(false), rows); + return varbin(arena, DType.BINARY, rows); } private static VarBinArray varbin(Arena arena, DType dtype, byte[]... rows) { diff --git a/cli/src/test/java/io/github/dfa1/vortex/cli/tui/GridRenderTest.java b/cli/src/test/java/io/github/dfa1/vortex/cli/tui/GridRenderTest.java index d6a7ca31..70477f1c 100644 --- a/cli/src/test/java/io/github/dfa1/vortex/cli/tui/GridRenderTest.java +++ b/cli/src/test/java/io/github/dfa1/vortex/cli/tui/GridRenderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.cli.tui; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.encoding.TimeUnit; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.reader.array.ByteArray; @@ -27,9 +26,9 @@ /// arrays without a terminal or fixture file. class GridRenderTest { - private static final DType I64 = new DType.Primitive(PType.I64, false); - private static final DType F64 = new DType.Primitive(PType.F64, false); - private static final DType BOOL = new DType.Bool(false); + private static final DType I64 = DType.I64; + private static final DType F64 = DType.F64; + private static final DType BOOL = DType.BOOL; @Test void nullArrayRendersEmpty() { @@ -77,7 +76,7 @@ void rendersDateExtensionFromIntStorage() { try (Arena arena = Arena.ofConfined()) { // Given — vortex.date over I32 epoch-day storage: day 0 = 1970-01-01 DType dateExt = new DType.Extension("vortex.date", - new DType.Primitive(PType.I32, false), null, false); + DType.I32, null, false); IntArray storage = ArrayFixtures.ints(arena, 0, 1); // When / Then @@ -117,7 +116,7 @@ void rendersUuidExtensionFromFixedSizeListStorage() { DType uuidExt = UuidExtensionDecoder.INSTANCE.dtype(false); ByteArray elems = ArrayFixtures.bytes(arena, new byte[16]); FixedSizeListArray storage = new FixedSizeListArray( - new DType.FixedSizeList(new DType.Primitive(PType.U8, false), 16, false), 1, elems); + new DType.FixedSizeList(DType.U8, 16, false), 1, elems); // When / Then assertThat(GridRender.formatCell(storage, 0, uuidExt)) @@ -145,8 +144,8 @@ void rendersUtf8VarBinAsRawString() { Array sut = ArrayFixtures.utf8(arena, "héllo", "x"); // When / Then - assertThat(GridRender.formatCell(sut, 0, new DType.Utf8(false))).isEqualTo("héllo"); - assertThat(GridRender.formatCell(sut, 1, new DType.Utf8(false))).isEqualTo("x"); + assertThat(GridRender.formatCell(sut, 0, DType.UTF8)).isEqualTo("héllo"); + assertThat(GridRender.formatCell(sut, 1, DType.UTF8)).isEqualTo("x"); } } @@ -157,7 +156,7 @@ void rendersBinaryVarBinAsHex() { Array sut = ArrayFixtures.binary(arena, new byte[]{0x01, (byte) 0xab, 0x02}); // When / Then - assertThat(GridRender.formatCell(sut, 0, new DType.Binary(false))).isEqualTo("0x01ab02"); + assertThat(GridRender.formatCell(sut, 0, DType.BINARY)).isEqualTo("0x01ab02"); } } @@ -169,7 +168,7 @@ void truncatesBinaryHexBeyond16Bytes() { Array sut = ArrayFixtures.binary(arena, twenty); // When - String cell = GridRender.formatCell(sut, 0, new DType.Binary(false)); + String cell = GridRender.formatCell(sut, 0, DType.BINARY); // Then — "0x" + 16*"00" + "..." assertThat(cell).isEqualTo("0x" + "00".repeat(16) + "..."); @@ -181,7 +180,7 @@ void extensionDecodeFailureRendersDiagnostic() { try (Arena arena = Arena.ofConfined()) { // Given — vortex.date declared but storage is F64, which epochInteger rejects DType dateExt = new DType.Extension("vortex.date", - new DType.Primitive(PType.I32, false), null, false); + DType.I32, null, false); Array badStorage = ArrayFixtures.doubles(arena, 1.5); // When — the decode throws and is caught @@ -197,7 +196,7 @@ void unknownExtensionIdFallsThroughToStorageRendering() { try (Arena arena = Arena.ofConfined()) { // Given — an extension id this reader does not know: render the raw storage value DType unknownExt = new DType.Extension("custom.thing", - new DType.Primitive(PType.I32, false), null, false); + DType.I32, null, false); IntArray storage = ArrayFixtures.ints(arena, 42); // When / Then — no extension formatting, falls to the IntArray branch diff --git a/cli/src/test/java/io/github/dfa1/vortex/cli/tui/InspectorRenderTest.java b/cli/src/test/java/io/github/dfa1/vortex/cli/tui/InspectorRenderTest.java index 546b2c09..53e98a3a 100644 --- a/cli/src/test/java/io/github/dfa1/vortex/cli/tui/InspectorRenderTest.java +++ b/cli/src/test/java/io/github/dfa1/vortex/cli/tui/InspectorRenderTest.java @@ -24,7 +24,7 @@ /// in-memory arrays — no terminal, worker, or encoded fixture required. class InspectorRenderTest { - private static final DType I64 = new DType.Primitive(PType.I64, false); + private static final DType I64 = DType.I64; @Nested class FormatValue { @@ -92,7 +92,7 @@ void rendersDateExtension() { try (Arena arena = Arena.ofConfined()) { // Given — vortex.date over I32 epoch-day storage DType dateExt = new DType.Extension("vortex.date", - new DType.Primitive(PType.I32, false), null, false); + DType.I32, null, false); IntArray storage = ArrayFixtures.ints(arena, 0); // When / Then — day 0 = 1970-01-01 @@ -107,7 +107,7 @@ void rendersUtf8VarBinQuoted() { Array sut = ArrayFixtures.utf8(arena, "hi"); // When / Then - assertThat(InspectorRender.formatValue(sut, 0, new DType.Utf8(false))).isEqualTo("\"hi\""); + assertThat(InspectorRender.formatValue(sut, 0, DType.UTF8)).isEqualTo("\"hi\""); } } @@ -118,7 +118,7 @@ void rendersBinaryVarBinAsShortHex() { Array sut = ArrayFixtures.binary(arena, new byte[]{0x01, (byte) 0xab}); // When / Then - assertThat(InspectorRender.formatValue(sut, 0, new DType.Binary(false))).isEqualTo("0x01ab"); + assertThat(InspectorRender.formatValue(sut, 0, DType.BINARY)).isEqualTo("0x01ab"); } } @@ -127,7 +127,7 @@ void dateExtensionDecodeFailureFallsThroughToGeneric() { try (Arena arena = Arena.ofConfined()) { // Given — vortex.date declared but storage is F64; the decode throws and is swallowed DType dateExt = new DType.Extension("vortex.date", - new DType.Primitive(PType.I32, false), null, false); + DType.I32, null, false); Array badStorage = ArrayFixtures.doubles(arena, 1.5); // When / Then — falls through to the generic DoubleArray rendering diff --git a/cli/src/test/java/io/github/dfa1/vortex/cli/tui/TuiTestSupport.java b/cli/src/test/java/io/github/dfa1/vortex/cli/tui/TuiTestSupport.java index 86217365..d885d6e7 100644 --- a/cli/src/test/java/io/github/dfa1/vortex/cli/tui/TuiTestSupport.java +++ b/cli/src/test/java/io/github/dfa1/vortex/cli/tui/TuiTestSupport.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.cli.tui; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.VortexHandle; import io.github.dfa1.vortex.reader.VortexReader; import io.github.dfa1.vortex.writer.VortexWriter; @@ -31,9 +30,9 @@ static Path writeGridVortex(Path dir, String name, int rows) throws IOException DType.Struct schema = new DType.Struct( List.of("a", "b", "c"), List.of( - new DType.Primitive(PType.I64, false), - new DType.Primitive(PType.I64, false), - new DType.Primitive(PType.I64, false)), + DType.I64, + DType.I64, + DType.I64), false); long[] a = new long[rows]; long[] b = new long[rows]; @@ -58,10 +57,10 @@ static Path writeMultiTypeVortex(Path dir, String name) throws IOException { DType.Struct schema = new DType.Struct( List.of("i", "d", "flag", "name"), List.of( - new DType.Primitive(PType.I64, false), - new DType.Primitive(PType.F64, false), - new DType.Bool(false), - new DType.Utf8(false)), + DType.I64, + DType.F64, + DType.BOOL, + DType.UTF8), false); try (FileChannel ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); VortexWriter writer = VortexWriter.create(ch, schema, WriteOptions.defaults())) { @@ -90,7 +89,7 @@ static Path writeRichVortex(Path dir, String name, int rows) throws IOException Path file = dir.resolve(name); DType.Struct schema = new DType.Struct( List.of("label", "n"), - List.of(new DType.Utf8(false), new DType.Primitive(PType.I64, false)), + List.of(DType.UTF8, DType.I64), false); String[] labels = {"red", "green", "blue"}; String[] label = new String[rows]; diff --git a/core/src/main/java/io/github/dfa1/vortex/core/DType.java b/core/src/main/java/io/github/dfa1/vortex/core/DType.java index 10e9b45b..d62db40f 100644 --- a/core/src/main/java/io/github/dfa1/vortex/core/DType.java +++ b/core/src/main/java/io/github/dfa1/vortex/core/DType.java @@ -26,7 +26,7 @@ public sealed interface DType /// Returns a copy of this type marked nullable. Sugar over /// [#withNullable(boolean)] so call sites read as a fluent adjective: - /// `DType.i64().asNullable()`. + /// `DType.I64.asNullable()`. /// /// @return a new [DType] identical to this one but with `nullable = true` default DType asNullable() { @@ -53,91 +53,65 @@ default DType withNullable(boolean nullable) { }; } - // ── Static factories ──────────────────────────────────────────────────── + // ── Canonical non-nullable types ───────────────────────────────────────── // - // Convenience entry points returning non-nullable instances. Combine with - // [#nullable()] for nullable columns. The underlying records are unchanged - // and remain usable directly (pattern matching, proto serialization, tests). + // Shared immutable instances — prefer these over `new Bool(false)`, + // `new Utf8(false)`, etc. For a nullable column build from one with + // [#asNullable()], e.g. `DType.UTF8.asNullable()`. - /// @return non-nullable [Bool] - static Bool bool_() { - return new Bool(false); - } + /// Non-nullable [Bool]. + Bool BOOL = new Bool(false); - /// @return non-nullable [Utf8] - static Utf8 utf8() { - return new Utf8(false); - } + /// Non-nullable [Utf8]. + Utf8 UTF8 = new Utf8(false); - /// @return non-nullable [Binary] - static Binary binary() { - return new Binary(false); - } + /// Non-nullable [Binary]. + Binary BINARY = new Binary(false); - /// @return non-nullable [Null] - static Null null_() { - return new Null(false); - } + /// Non-nullable [Null]. + Null NULL = new Null(false); - /// @return non-nullable [Variant] - static Variant variant() { - return new Variant(false); - } + /// Non-nullable [Variant]. + Variant VARIANT = new Variant(false); - /// @return non-nullable [Primitive] of [PType#I8] - static Primitive i8() { - return new Primitive(PType.I8, false); - } + // ── Canonical non-nullable primitives ─────────────────────────────────── + // + // Shared immutable instances — prefer these over `new Primitive(pt, false)`. + // For a nullable column build from one with [#asNullable()], e.g. + // `DType.I64.asNullable()`. - /// @return non-nullable [Primitive] of [PType#I16] - static Primitive i16() { - return new Primitive(PType.I16, false); - } + /// Non-nullable [Primitive] of [PType#I8]. + Primitive I8 = new Primitive(PType.I8, false); - /// @return non-nullable [Primitive] of [PType#I32] - static Primitive i32() { - return new Primitive(PType.I32, false); - } + /// Non-nullable [Primitive] of [PType#I16]. + Primitive I16 = new Primitive(PType.I16, false); - /// @return non-nullable [Primitive] of [PType#I64] - static Primitive i64() { - return new Primitive(PType.I64, false); - } + /// Non-nullable [Primitive] of [PType#I32]. + Primitive I32 = new Primitive(PType.I32, false); - /// @return non-nullable [Primitive] of [PType#U8] - static Primitive u8() { - return new Primitive(PType.U8, false); - } + /// Non-nullable [Primitive] of [PType#I64]. + Primitive I64 = new Primitive(PType.I64, false); - /// @return non-nullable [Primitive] of [PType#U16] - static Primitive u16() { - return new Primitive(PType.U16, false); - } + /// Non-nullable [Primitive] of [PType#U8]. + Primitive U8 = new Primitive(PType.U8, false); - /// @return non-nullable [Primitive] of [PType#U32] - static Primitive u32() { - return new Primitive(PType.U32, false); - } + /// Non-nullable [Primitive] of [PType#U16]. + Primitive U16 = new Primitive(PType.U16, false); - /// @return non-nullable [Primitive] of [PType#U64] - static Primitive u64() { - return new Primitive(PType.U64, false); - } + /// Non-nullable [Primitive] of [PType#U32]. + Primitive U32 = new Primitive(PType.U32, false); - /// @return non-nullable [Primitive] of [PType#F16] - static Primitive f16() { - return new Primitive(PType.F16, false); - } + /// Non-nullable [Primitive] of [PType#U64]. + Primitive U64 = new Primitive(PType.U64, false); - /// @return non-nullable [Primitive] of [PType#F32] - static Primitive f32() { - return new Primitive(PType.F32, false); - } + /// Non-nullable [Primitive] of [PType#F16]. + Primitive F16 = new Primitive(PType.F16, false); - /// @return non-nullable [Primitive] of [PType#F64] - static Primitive f64() { - return new Primitive(PType.F64, false); - } + /// Non-nullable [Primitive] of [PType#F32]. + Primitive F32 = new Primitive(PType.F32, false); + + /// Non-nullable [Primitive] of [PType#F64]. + Primitive F64 = new Primitive(PType.F64, false); /// @param precision total number of significant decimal digits /// @param scale number of digits to the right of the decimal point @@ -151,10 +125,10 @@ static Decimal decimal(int precision, int scale) { /// /// ```java /// DType.Struct schema = DType.structBuilder() - /// .field("timestamp", DType.i64()) - /// .field("symbol", DType.utf8()) - /// .field("price", DType.f64()) - /// .field("volume", DType.i64().asNullable()) + /// .field("timestamp", DType.I64) + /// .field("symbol", DType.UTF8) + /// .field("price", DType.F64) + /// .field("volume", DType.I64.asNullable()) /// .build(); /// ``` /// diff --git a/core/src/test/java/io/github/dfa1/vortex/core/DTypeExtensionTest.java b/core/src/test/java/io/github/dfa1/vortex/core/DTypeExtensionTest.java index bb1ad868..1d701ef1 100644 --- a/core/src/test/java/io/github/dfa1/vortex/core/DTypeExtensionTest.java +++ b/core/src/test/java/io/github/dfa1/vortex/core/DTypeExtensionTest.java @@ -9,7 +9,7 @@ class DTypeExtensionTest { - private static final DType.Primitive I32 = new DType.Primitive(PType.I32, false); + private static final DType.Primitive I32 = DType.I32; @Test void metadataAtCap_accepted() { diff --git a/core/src/test/java/io/github/dfa1/vortex/core/DTypeFactoriesTest.java b/core/src/test/java/io/github/dfa1/vortex/core/DTypeFactoriesTest.java index 943987af..5b4e87de 100644 --- a/core/src/test/java/io/github/dfa1/vortex/core/DTypeFactoriesTest.java +++ b/core/src/test/java/io/github/dfa1/vortex/core/DTypeFactoriesTest.java @@ -10,7 +10,7 @@ class DTypeFactoriesTest { @Test void primitiveFactories_areNonNullable() { // Given / When - DType.Primitive sut = DType.i64(); + DType.Primitive sut = DType.I64; // Then assertThat(sut.ptype()).isEqualTo(PType.I64); @@ -20,7 +20,7 @@ void primitiveFactories_areNonNullable() { @Test void nullableShortcut_marksType_nullable() { // Given - DType sut = DType.utf8(); + DType sut = DType.UTF8; // When DType result = sut.asNullable(); @@ -35,27 +35,27 @@ void nullableShortcut_marksType_nullable() { @Test void allPrimitiveFactories_returnExpectedPType() { // Given / When / Then - assertThat(DType.i8().ptype()).isEqualTo(PType.I8); - assertThat(DType.i16().ptype()).isEqualTo(PType.I16); - assertThat(DType.i32().ptype()).isEqualTo(PType.I32); - assertThat(DType.i64().ptype()).isEqualTo(PType.I64); - assertThat(DType.u8().ptype()).isEqualTo(PType.U8); - assertThat(DType.u16().ptype()).isEqualTo(PType.U16); - assertThat(DType.u32().ptype()).isEqualTo(PType.U32); - assertThat(DType.u64().ptype()).isEqualTo(PType.U64); - assertThat(DType.f16().ptype()).isEqualTo(PType.F16); - assertThat(DType.f32().ptype()).isEqualTo(PType.F32); - assertThat(DType.f64().ptype()).isEqualTo(PType.F64); + assertThat(DType.I8.ptype()).isEqualTo(PType.I8); + assertThat(DType.I16.ptype()).isEqualTo(PType.I16); + assertThat(DType.I32.ptype()).isEqualTo(PType.I32); + assertThat(DType.I64.ptype()).isEqualTo(PType.I64); + assertThat(DType.U8.ptype()).isEqualTo(PType.U8); + assertThat(DType.U16.ptype()).isEqualTo(PType.U16); + assertThat(DType.U32.ptype()).isEqualTo(PType.U32); + assertThat(DType.U64.ptype()).isEqualTo(PType.U64); + assertThat(DType.F16.ptype()).isEqualTo(PType.F16); + assertThat(DType.F32.ptype()).isEqualTo(PType.F32); + assertThat(DType.F64.ptype()).isEqualTo(PType.F64); } @Test void bool_utf8_binary_null_variant_factories_areNonNullable() { // Given / When / Then - assertThat(DType.bool_().nullable()).isFalse(); - assertThat(DType.utf8().nullable()).isFalse(); - assertThat(DType.binary().nullable()).isFalse(); - assertThat(DType.null_().nullable()).isFalse(); - assertThat(DType.variant().nullable()).isFalse(); + assertThat(DType.BOOL.nullable()).isFalse(); + assertThat(DType.UTF8.nullable()).isFalse(); + assertThat(DType.BINARY.nullable()).isFalse(); + assertThat(DType.NULL.nullable()).isFalse(); + assertThat(DType.VARIANT.nullable()).isFalse(); } @Test @@ -72,10 +72,10 @@ void decimalFactory_setsPrecisionAndScale() { @Test void nullableShortcut_equivalentTo_withNullableTrue() { // Given - DType direct = DType.f64().withNullable(true); + DType direct = DType.F64.withNullable(true); // When - DType result = DType.f64().asNullable(); + DType result = DType.F64.asNullable(); // Then assertThat(result).isEqualTo(direct); diff --git a/core/src/test/java/io/github/dfa1/vortex/core/DTypeStructBuilderTest.java b/core/src/test/java/io/github/dfa1/vortex/core/DTypeStructBuilderTest.java index f9e8e46d..2c07fd0b 100644 --- a/core/src/test/java/io/github/dfa1/vortex/core/DTypeStructBuilderTest.java +++ b/core/src/test/java/io/github/dfa1/vortex/core/DTypeStructBuilderTest.java @@ -14,15 +14,15 @@ class DTypeStructBuilderTest { void build_preservesFieldInsertionOrder() { // Given / When DType.Struct sut = DType.structBuilder() - .field("timestamp", DType.i64()) - .field("symbol", DType.utf8()) - .field("price", DType.f64()) + .field("timestamp", DType.I64) + .field("symbol", DType.UTF8) + .field("price", DType.F64) .build(); // Then assertThat(sut.fieldNames()).containsExactly("timestamp", "symbol", "price"); assertThat(sut.fieldTypes()).containsExactly( - DType.i64(), DType.utf8(), DType.f64()); + DType.I64, DType.UTF8, DType.F64); assertThat(sut.nullable()).isFalse(); } @@ -30,7 +30,7 @@ void build_preservesFieldInsertionOrder() { void asNullable_marksTheStructItself() { // Given / When DType.Struct sut = DType.structBuilder() - .field("v", DType.i64()) + .field("v", DType.I64) .asNullable() .build(); @@ -52,10 +52,10 @@ void emptyBuilder_buildsEmptyStruct() { @Test void duplicateField_throws_atAddTime() { // Given - DType.StructBuilder sut = DType.structBuilder().field("x", DType.i64()); + DType.StructBuilder sut = DType.structBuilder().field("x", DType.I64); // When / Then - assertThatThrownBy(() -> sut.field("x", DType.f64())) + assertThatThrownBy(() -> sut.field("x", DType.F64)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("duplicate field name: x"); } @@ -64,14 +64,14 @@ void duplicateField_throws_atAddTime() { void buildResult_equalsRecordConstructed_struct() { // Given DType.Struct viaBuilder = DType.structBuilder() - .field("a", DType.i32()) - .field("b", DType.utf8()) + .field("a", DType.I32) + .field("b", DType.UTF8) .build(); // When DType.Struct result = new DType.Struct( List.of("a", "b"), - List.of(new DType.Primitive(PType.I32, false), new DType.Utf8(false)), + List.of(DType.I32, DType.UTF8), false); // Then @@ -81,8 +81,8 @@ void buildResult_equalsRecordConstructed_struct() { @Test void builder_isNotReusable_afterMutation_byField() { // Given / When — separate builder instances must produce independent structs - DType.Struct resultX = DType.structBuilder().field("x", DType.i64()).build(); - DType.Struct resultY = DType.structBuilder().field("y", DType.utf8()).build(); + DType.Struct resultX = DType.structBuilder().field("x", DType.I64).build(); + DType.Struct resultY = DType.structBuilder().field("y", DType.UTF8).build(); // Then assertThat(resultX.fieldNames()).containsExactly("x"); diff --git a/core/src/test/java/io/github/dfa1/vortex/core/DTypeWithNullableTest.java b/core/src/test/java/io/github/dfa1/vortex/core/DTypeWithNullableTest.java index ec607ea4..7b0341f8 100644 --- a/core/src/test/java/io/github/dfa1/vortex/core/DTypeWithNullableTest.java +++ b/core/src/test/java/io/github/dfa1/vortex/core/DTypeWithNullableTest.java @@ -16,19 +16,19 @@ class DTypeWithNullableTest { /// One non-nullable instance of each [DType] variant, with non-default payload /// fields so field-preservation is actually exercised (not just the flag). static Stream nonNullableSamples() { - DType i32 = new DType.Primitive(PType.I32, false); + DType i32 = DType.I32; return Stream.of( - Arguments.of("Null", new DType.Null(false)), - Arguments.of("Bool", new DType.Bool(false)), - Arguments.of("Primitive", new DType.Primitive(PType.I64, false)), + Arguments.of("Null", DType.NULL), + Arguments.of("Bool", DType.BOOL), + Arguments.of("Primitive", DType.I64), Arguments.of("Decimal", new DType.Decimal((byte) 10, (byte) 2, false)), - Arguments.of("Utf8", new DType.Utf8(false)), - Arguments.of("Binary", new DType.Binary(false)), - Arguments.of("Struct", new DType.Struct(List.of("a", "b"), List.of(i32, new DType.Utf8(false)), false)), + Arguments.of("Utf8", DType.UTF8), + Arguments.of("Binary", DType.BINARY), + Arguments.of("Struct", new DType.Struct(List.of("a", "b"), List.of(i32, DType.UTF8), false)), Arguments.of("List", new DType.List(i32, false)), Arguments.of("FixedSizeList", new DType.FixedSizeList(i32, 4, false)), Arguments.of("Extension", new DType.Extension("ip.address", i32, null, false)), - Arguments.of("Variant", new DType.Variant(false)) + Arguments.of("Variant", DType.VARIANT) ); } @@ -68,7 +68,7 @@ void withNullableFalse_onAlreadyNonNullable_isIdempotent(String name, DType sut) @Test void asNullable_isSugarForWithNullableTrue() { // Given - DType sut = new DType.Primitive(PType.I64, false); + DType sut = DType.I64; // When DType result = sut.asNullable(); @@ -81,7 +81,7 @@ void asNullable_isSugarForWithNullableTrue() { @Test void withNullable_preservesCompoundPayload_struct() { // Given — a struct whose field names/types must ride through the flip verbatim - DType i32 = new DType.Primitive(PType.I32, false); + DType i32 = DType.I32; DType.Struct sut = new DType.Struct(List.of("id", "name"), List.of(i32, new DType.Utf8(true)), false); // When @@ -96,7 +96,7 @@ void withNullable_preservesCompoundPayload_struct() { @Test void withNullable_preservesCompoundPayload_extensionAndFixedSizeList() { // Given - DType storage = new DType.Primitive(PType.I32, false); + DType storage = DType.I32; DType.Extension ext = new DType.Extension("ip.address", storage, null, false); DType.FixedSizeList fsl = new DType.FixedSizeList(storage, 16, false); diff --git a/core/src/test/java/io/github/dfa1/vortex/encoding/DTypes.java b/core/src/test/java/io/github/dfa1/vortex/encoding/DTypes.java index e7f7613a..21966464 100644 --- a/core/src/test/java/io/github/dfa1/vortex/encoding/DTypes.java +++ b/core/src/test/java/io/github/dfa1/vortex/encoding/DTypes.java @@ -9,27 +9,27 @@ @SuppressWarnings("unused") public final class DTypes { - public static final DType I8 = new DType.Primitive(PType.I8, false); - public static final DType I16 = new DType.Primitive(PType.I16, false); - public static final DType I32 = new DType.Primitive(PType.I32, false); - public static final DType I64 = new DType.Primitive(PType.I64, false); - public static final DType U8 = new DType.Primitive(PType.U8, false); - public static final DType U16 = new DType.Primitive(PType.U16, false); - public static final DType U32 = new DType.Primitive(PType.U32, false); - public static final DType U64 = new DType.Primitive(PType.U64, false); - public static final DType F16 = new DType.Primitive(PType.F16, false); - public static final DType F32 = new DType.Primitive(PType.F32, false); - public static final DType F64 = new DType.Primitive(PType.F64, false); + public static final DType I8 = DType.I8; + public static final DType I16 = DType.I16; + public static final DType I32 = DType.I32; + public static final DType I64 = DType.I64; + public static final DType U8 = DType.U8; + public static final DType U16 = DType.U16; + public static final DType U32 = DType.U32; + public static final DType U64 = DType.U64; + public static final DType F16 = DType.F16; + public static final DType F32 = DType.F32; + public static final DType F64 = DType.F64; public static final DType I32_N = new DType.Primitive(PType.I32, true); public static final DType I64_N = new DType.Primitive(PType.I64, true); public static final DType F64_N = new DType.Primitive(PType.F64, true); - public static final DType BOOL = new DType.Bool(false); + public static final DType BOOL = DType.BOOL; public static final DType BOOL_N = new DType.Bool(true); - public static final DType UTF8 = new DType.Utf8(false); + public static final DType UTF8 = DType.UTF8; public static final DType UTF8_N = new DType.Utf8(true); - public static final DType BINARY = new DType.Binary(false); + public static final DType BINARY = DType.BINARY; public static final DType BINARY_N = new DType.Binary(true); public static final DType NULL = new DType.Null(true); diff --git a/csv/src/main/java/io/github/dfa1/vortex/csv/CsvImporter.java b/csv/src/main/java/io/github/dfa1/vortex/csv/CsvImporter.java index e529b453..e99e8eae 100644 --- a/csv/src/main/java/io/github/dfa1/vortex/csv/CsvImporter.java +++ b/csv/src/main/java/io/github/dfa1/vortex/csv/CsvImporter.java @@ -197,15 +197,15 @@ private static String[] generateHeaders(int colCount) { private static DType resolveType(boolean canBeLong, boolean canBeDouble, boolean canBeBool) { if (canBeLong) { - return new DType.Primitive(PType.I64, false); + return DType.I64; } if (canBeDouble) { - return new DType.Primitive(PType.F64, false); + return DType.F64; } if (canBeBool) { - return new DType.Bool(false); + return DType.BOOL; } - return new DType.Utf8(false); + return DType.UTF8; } static Map buildChunk(DType.Struct schema, List rows) { diff --git a/csv/src/test/java/io/github/dfa1/vortex/csv/CsvExporterTest.java b/csv/src/test/java/io/github/dfa1/vortex/csv/CsvExporterTest.java index 334b74cf..7c6bf6cc 100644 --- a/csv/src/test/java/io/github/dfa1/vortex/csv/CsvExporterTest.java +++ b/csv/src/test/java/io/github/dfa1/vortex/csv/CsvExporterTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.csv; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.writer.VortexWriter; import io.github.dfa1.vortex.writer.WriteOptions; import org.junit.jupiter.api.Test; @@ -25,7 +24,7 @@ void exportsToCsvFile(@TempDir Path tmp) throws Exception { Path vortex = tmp.resolve("data.vortex"); DType.Struct schema = new DType.Struct( List.of("id", "name"), - List.of(new DType.Primitive(PType.I64, false), new DType.Utf8(false)), + List.of(DType.I64, DType.UTF8), false); try (FileChannel ch = FileChannel.open(vortex, StandardOpenOption.CREATE, StandardOpenOption.WRITE); VortexWriter writer = VortexWriter.create(ch, schema, WriteOptions.defaults())) { @@ -50,7 +49,7 @@ void exportsToWriter(@TempDir Path tmp) throws Exception { Path vortex = tmp.resolve("data.vortex"); DType.Struct schema = new DType.Struct( List.of("x"), - List.of(new DType.Primitive(PType.F64, false)), + List.of(DType.F64), false); try (FileChannel ch = FileChannel.open(vortex, StandardOpenOption.CREATE, StandardOpenOption.WRITE); VortexWriter writer = VortexWriter.create(ch, schema, WriteOptions.defaults())) { @@ -75,7 +74,7 @@ void suppressesHeaderWhenConfigured(@TempDir Path tmp) throws Exception { Path vortex = tmp.resolve("data.vortex"); DType.Struct schema = new DType.Struct( List.of("id"), - List.of(new DType.Primitive(PType.I64, false)), + List.of(DType.I64), false); try (FileChannel ch = FileChannel.open(vortex, StandardOpenOption.CREATE, StandardOpenOption.WRITE); VortexWriter writer = VortexWriter.create(ch, schema, WriteOptions.defaults())) { diff --git a/csv/src/test/java/io/github/dfa1/vortex/csv/CsvImporterTest.java b/csv/src/test/java/io/github/dfa1/vortex/csv/CsvImporterTest.java index b3e6b282..42342b07 100644 --- a/csv/src/test/java/io/github/dfa1/vortex/csv/CsvImporterTest.java +++ b/csv/src/test/java/io/github/dfa1/vortex/csv/CsvImporterTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.csv; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.LongArray; import io.github.dfa1.vortex.reader.array.VarBinArray; import io.github.dfa1.vortex.reader.VortexReader; @@ -34,10 +33,10 @@ void infersTypedColumnsAndRoundTrips(@TempDir Path tmp) throws Exception { assertThat(reader.dtype()).isInstanceOf(DType.Struct.class); DType.Struct schema = (DType.Struct) reader.dtype(); assertThat(schema.fieldNames()).containsExactly("id", "price", "active", "name"); - assertThat(schema.fieldTypes().get(0)).isEqualTo(new DType.Primitive(PType.I64, false)); - assertThat(schema.fieldTypes().get(1)).isEqualTo(new DType.Primitive(PType.F64, false)); - assertThat(schema.fieldTypes().get(2)).isEqualTo(new DType.Bool(false)); - assertThat(schema.fieldTypes().get(3)).isEqualTo(new DType.Utf8(false)); + assertThat(schema.fieldTypes().get(0)).isEqualTo(DType.I64); + assertThat(schema.fieldTypes().get(1)).isEqualTo(DType.F64); + assertThat(schema.fieldTypes().get(2)).isEqualTo(DType.BOOL); + assertThat(schema.fieldTypes().get(3)).isEqualTo(DType.UTF8); try (ScanIterator iter = reader.scan(ScanOptions.all())) { assertThat(iter.hasNext()).isTrue(); @@ -96,7 +95,7 @@ void respectsSchemaOverride(@TempDir Path tmp) throws Exception { Path vortex = tmp.resolve("data.vortex"); DType.Struct forcedSchema = new DType.Struct( java.util.List.of("value"), - java.util.List.of(new DType.Utf8(false)), + java.util.List.of(DType.UTF8), false); // When @@ -105,7 +104,7 @@ void respectsSchemaOverride(@TempDir Path tmp) throws Exception { // Then try (VortexReader reader = VortexReader.open(vortex)) { DType.Struct schema = (DType.Struct) reader.dtype(); - assertThat(schema.fieldTypes().getFirst()).isEqualTo(new DType.Utf8(false)); + assertThat(schema.fieldTypes().getFirst()).isEqualTo(DType.UTF8); try (ScanIterator iter = reader.scan(ScanOptions.all())) { assertThat(iter.hasNext()).isTrue(); try (Chunk chunk = iter.next()) { diff --git a/docs/reference.md b/docs/reference.md index dde89e86..422e4281 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -33,18 +33,18 @@ Methods: `byteSize()`, `isFloating()`, `isSigned()`. Sealed logical type. All variants take a trailing `boolean nullable`. -Each `DType` variant is a record. Prefer the static factories for new code — the -record constructors stay available for pattern matching and tests. +Each `DType` variant is a record. Prefer the canonical constants / factories for +new code — the record constructors stay available for pattern matching and tests. -| Record | Factory | Record constructor | +| Record | Constant / factory | Record constructor | |-----------------------|--------------------------------------------------------|-------------------------------------------------------------| -| `DType.Null` | `DType.null_()` | `new DType.Null(nullable)` | -| `DType.Bool` | `DType.bool_()` | `new DType.Bool(nullable)` | -| `DType.Primitive` | `DType.i8()` … `DType.i64()`, `DType.u8()` … `DType.u64()`, `DType.f16()`, `DType.f32()`, `DType.f64()` | `new DType.Primitive(PType, nullable)` | +| `DType.Null` | `DType.NULL` | `new DType.Null(nullable)` | +| `DType.Bool` | `DType.BOOL` | `new DType.Bool(nullable)` | +| `DType.Primitive` | `DType.I8` … `DType.I64`, `DType.U8` … `DType.U64`, `DType.F16`, `DType.F32`, `DType.F64` (constants) | `DType.I64.asNullable()` / `new DType.Primitive(PType, nullable)` | | `DType.Decimal` | `DType.decimal(precision, scale)` | `new DType.Decimal(precision, scale, nullable)` | -| `DType.Utf8` | `DType.utf8()` | `new DType.Utf8(nullable)` | -| `DType.Binary` | `DType.binary()` | `new DType.Binary(nullable)` | -| `DType.Variant` | `DType.variant()` | `new DType.Variant(nullable)` | +| `DType.Utf8` | `DType.UTF8` | `new DType.Utf8(nullable)` | +| `DType.Binary` | `DType.BINARY` | `new DType.Binary(nullable)` | +| `DType.Variant` | `DType.VARIANT` | `new DType.Variant(nullable)` | | `DType.Struct` | `DType.structBuilder().field(name, type)…build()` | `new DType.Struct(fieldNames, fieldTypes, nullable)` | | `DType.List` | — | `new DType.List(elementType, nullable)` | | `DType.FixedSizeList` | — | `new DType.FixedSizeList(elementType, fixedSize, nullable)` | diff --git a/docs/tutorial.md b/docs/tutorial.md index 8f89c379..70195aa3 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -48,16 +48,17 @@ A Vortex file is a typed struct — every column has a declared type before any import io.github.dfa1.vortex.core.DType; DType.Struct schema = DType.structBuilder() - .field("timestamp", DType.i64()) // unix epoch millis - .field("symbol", DType.utf8()) // ticker symbol - .field("price", DType.f64()) // trade price - .field("volume", DType.i64().asNullable()) // shares traded, may be null + .field("timestamp", DType.I64) // unix epoch millis + .field("symbol", DType.UTF8) // ticker symbol + .field("price", DType.F64) // trade price + .field("volume", DType.I64.asNullable()) // shares traded, may be null .build(); ``` -`DType.i64()`, `DType.utf8()`, `DType.f64()`, etc. return non-nullable types by default. -Chain `.asNullable()` to opt into nulls. -See [reference.md#core-types](reference.md#core-types) for the full factory list. +`DType.I8` … `DType.F64`, plus `DType.BOOL`, `DType.UTF8`, `DType.BINARY`, +`DType.NULL`, `DType.VARIANT`, are non-nullable canonical constants. Chain +`.asNullable()` to opt into nulls. +See [reference.md#core-types](reference.md#core-types) for the full list. --- diff --git a/inspector/src/main/java/io/github/dfa1/vortex/inspect/ZonedStatsSchema.java b/inspector/src/main/java/io/github/dfa1/vortex/inspect/ZonedStatsSchema.java index 5b3f7fb3..e7ba1e0b 100644 --- a/inspector/src/main/java/io/github/dfa1/vortex/inspect/ZonedStatsSchema.java +++ b/inspector/src/main/java/io/github/dfa1/vortex/inspect/ZonedStatsSchema.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.inspect; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -153,10 +152,10 @@ public static DType.Struct statsTableDtype(DType columnDtype, List present types.add(stype.withNullable(true)); if (stat == Stat.MAX) { names.add(Stat.MAX_IS_TRUNCATED); - types.add(new DType.Bool(false)); + types.add(DType.BOOL); } else if (stat == Stat.MIN) { names.add(Stat.MIN_IS_TRUNCATED); - types.add(new DType.Bool(false)); + types.add(DType.BOOL); } } return new DType.Struct(List.copyOf(names), List.copyOf(types), false); @@ -198,18 +197,18 @@ public static DType statDtype(Stat stat, DType columnDtype) { private static DType statDtypeDirect(Stat stat, DType columnDtype) { return switch (stat) { - case IS_CONSTANT, IS_SORTED, IS_STRICT_SORTED -> new DType.Bool(false); + case IS_CONSTANT, IS_SORTED, IS_STRICT_SORTED -> DType.BOOL; case MAX, MIN -> { if (columnDtype instanceof DType.Null) { yield null; } yield columnDtype; } - case NULL_COUNT -> new DType.Primitive(PType.U64, false); - case UNCOMPRESSED_SIZE_IN_BYTES -> new DType.Primitive(PType.U64, false); + case NULL_COUNT -> DType.U64; + case UNCOMPRESSED_SIZE_IN_BYTES -> DType.U64; case NAN_COUNT -> { if (columnDtype instanceof DType.Primitive p && p.ptype().isFloating()) { - yield new DType.Primitive(PType.U64, false); + yield DType.U64; } yield null; } @@ -219,13 +218,13 @@ private static DType statDtypeDirect(Stat stat, DType columnDtype) { private static DType sumDtype(DType columnDtype) { if (columnDtype instanceof DType.Bool) { - return new DType.Primitive(PType.U64, false); + return DType.U64; } if (columnDtype instanceof DType.Primitive p) { return switch (p.ptype()) { - case U8, U16, U32, U64 -> new DType.Primitive(PType.U64, false); - case I8, I16, I32, I64 -> new DType.Primitive(PType.I64, false); - case F16, F32, F64 -> new DType.Primitive(PType.F64, false); + case U8, U16, U32, U64 -> DType.U64; + case I8, I16, I32, I64 -> DType.I64; + case F16, F32, F64 -> DType.F64; }; } // Decimal sum widening and other types are not handled — falls through to null diff --git a/inspector/src/test/java/io/github/dfa1/vortex/inspect/InspectorTreeTest.java b/inspector/src/test/java/io/github/dfa1/vortex/inspect/InspectorTreeTest.java index 9b4aeebe..84ab4c55 100644 --- a/inspector/src/test/java/io/github/dfa1/vortex/inspect/InspectorTreeTest.java +++ b/inspector/src/test/java/io/github/dfa1/vortex/inspect/InspectorTreeTest.java @@ -4,7 +4,6 @@ import io.github.dfa1.vortex.core.DType; import io.github.dfa1.vortex.reader.Footer; import io.github.dfa1.vortex.reader.Layout; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.SegmentSpec; import io.github.dfa1.vortex.reader.VortexHandle; import org.junit.jupiter.api.Test; @@ -32,7 +31,7 @@ void build_withStructDType_assignsFieldNamesToColumns() { Layout root = struct(10, List.of(idLeaf, valLeaf)); DType dtype = new DType.Struct( List.of("id", "value"), - List.of(new DType.Primitive(PType.I64, false), new DType.Primitive(PType.F64, false)), + List.of(DType.I64, DType.F64), false); givenHandle(dtype, root, List.of("vortex.constant"), List.of()); @@ -52,7 +51,7 @@ void build_withFewerColNamesThanChildren_fillsWithSyntheticNames() { // exceeds the dtype's named fields. Should not throw; should fall back to col0/col1... Layout root = struct(0, List.of(leaf("vortex.constant", 0), leaf("vortex.constant", 0))); DType dtype = new DType.Struct(List.of("only"), - List.of(new DType.Primitive(PType.I32, false)), false); + List.of(DType.I32), false); givenHandle(dtype, root, List.of("vortex.constant"), List.of()); // When @@ -67,7 +66,7 @@ void build_withFewerColNamesThanChildren_fillsWithSyntheticNames() { void build_withNonStructRoot_leavesFieldNameEmpty() { // Given Layout root = leaf("vortex.flat", 100); - DType dtype = new DType.Primitive(PType.I64, false); + DType dtype = DType.I64; givenHandle(dtype, root, List.of("vortex.flat"), List.of()); // When @@ -82,7 +81,7 @@ void build_withNonStructRoot_leavesFieldNameEmpty() { void build_sumsSegmentBytesAndCountsSegments() { // Given Layout root = leaf("vortex.flat", 0); - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; List segs = List.of( new SegmentSpec(0, 128, (byte) 0, CompressionScheme.LZ4), new SegmentSpec(128, 256, (byte) 0, CompressionScheme.LZ4), @@ -103,7 +102,7 @@ void build_setsTotalRowCountFromRootLayout() { // Given — total rows is the root layout's row count, regardless of struct/non-struct Layout root = struct(12_345L, List.of(leaf("vortex.constant", 12_345L))); DType dtype = new DType.Struct(List.of("c"), - List.of(new DType.Primitive(PType.I32, false)), false); + List.of(DType.I32), false); givenHandle(dtype, root, List.of("vortex.constant"), List.of()); // When @@ -117,7 +116,7 @@ void build_setsTotalRowCountFromRootLayout() { void build_carriesVersionAndFileSize() { // Given Layout root = leaf("vortex.flat", 0); - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; given(handle.version()).willReturn(7); given(handle.fileSize()).willReturn(123_456L); given(handle.dtype()).willReturn(dtype); @@ -142,9 +141,9 @@ void build_reportsProgressOncePerPeekedSegment() { Layout c3 = new Layout("vortex.flat", 0, null, List.of(), List.of(2)); Layout root = struct(0, List.of(c1, c2, c3)); DType dtype = new DType.Struct(List.of("a", "b", "c"), - List.of(new DType.Primitive(PType.I32, false), - new DType.Primitive(PType.I32, false), - new DType.Primitive(PType.I32, false)), + List.of(DType.I32, + DType.I32, + DType.I32), false); List segs = List.of( new SegmentSpec(0, 1024, (byte) 0, CompressionScheme.ZSTD), // skipped @@ -166,7 +165,7 @@ void build_progressNoop_isAcceptedAndProducesSameTree() { // Given Layout root = struct(0, List.of(leaf("vortex.constant", 0))); DType dtype = new DType.Struct(List.of("c"), - List.of(new DType.Primitive(PType.I32, false)), false); + List.of(DType.I32), false); givenHandle(dtype, root, List.of("vortex.constant"), List.of()); // When / Then — NOOP passes; no NPE @@ -183,8 +182,8 @@ void buildShallow_skipsAllSlicesAndStillNamesColumns() { Layout col1 = new Layout("vortex.flat", 10, null, List.of(), List.of(1)); Layout root = struct(10, List.of(col0, col1)); DType dtype = new DType.Struct(List.of("id", "value"), - List.of(new DType.Primitive(PType.I64, false), - new DType.Primitive(PType.F64, false)), + List.of(DType.I64, + DType.F64), false); List segs = List.of( new SegmentSpec(0, 64, (byte) 0, CompressionScheme.NONE), @@ -250,7 +249,7 @@ void build_flatChildWithCompressedSegment_skipsRootEncodingPeek() { // are intentionally skipped so a malformed or compressed payload can't crash the // inspector. With code != NONE we should still build a tree, with no encodings used. Layout root = new Layout("vortex.flat", 0, null, List.of(), List.of(0)); - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; SegmentSpec compressed = new SegmentSpec(0, 1024, (byte) 0, CompressionScheme.ZSTD); givenHandle(dtype, root, List.of("vortex.flat"), List.of(compressed)); diff --git a/inspector/src/test/java/io/github/dfa1/vortex/inspect/VortexInspectorTest.java b/inspector/src/test/java/io/github/dfa1/vortex/inspect/VortexInspectorTest.java index 7f19e1ae..fd78086a 100644 --- a/inspector/src/test/java/io/github/dfa1/vortex/inspect/VortexInspectorTest.java +++ b/inspector/src/test/java/io/github/dfa1/vortex/inspect/VortexInspectorTest.java @@ -4,7 +4,6 @@ import io.github.dfa1.vortex.reader.CompressionScheme; import io.github.dfa1.vortex.core.DType; import io.github.dfa1.vortex.reader.Layout; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.SegmentSpec; import org.junit.jupiter.api.Test; @@ -72,7 +71,7 @@ void render_nonStruct_inlinesSingleColumnLayout() { InspectorTree.Node root = new InspectorTree.Node(leaf, Optional.empty(), Set.of(), ArrayStats.empty(), List.of()); InspectorTree sut = new InspectorTree( 1, 256L, - new DType.Primitive(PType.I32, false), + DType.I32, List.of("vortex.flat"), Set.of(), List.of(new SegmentSpec(0, 256, (byte) 0, CompressionScheme.NONE)), 100L, root); @@ -114,7 +113,7 @@ void render_chainsChildrenWithArrow() { InspectorTree sut = new InspectorTree( 1, 1024L, - new DType.Struct(List.of("v"), List.of(new DType.Primitive(PType.I32, false)), false), + new DType.Struct(List.of("v"), List.of(DType.I32), false), List.of("vortex.flat"), Set.of(), List.of(), 1000L, rootN); @@ -143,7 +142,7 @@ void render_aggregatesMinMaxAcrossChunks() { Set.of("vortex.flat"), ArrayStats.empty(), List.of(chunkedN)); InspectorTree sut = new InspectorTree(1, 1024L, - new DType.Struct(List.of("id"), List.of(new DType.Primitive(PType.I64, false)), false), + new DType.Struct(List.of("id"), List.of(DType.I64), false), List.of("vortex.flat"), Set.of(), List.of(), 1000L, rootN); // When @@ -193,7 +192,7 @@ private static InspectorTree struct2col(int version, long fileSize, List present = List.of( ZonedStatsSchema.Stat.MAX, ZonedStatsSchema.Stat.MIN, @@ -137,9 +137,9 @@ void buildsStructWithMinMaxAndTruncationFlags() { // i64 sum widens to nullable i64; min/max stay i64 but nullable; truncation flags are non-null Bool assertThat(schema.fieldTypes()).containsExactly( new DType.Primitive(PType.I64, true), - new DType.Bool(false), + DType.BOOL, new DType.Primitive(PType.I64, true), - new DType.Bool(false), + DType.BOOL, new DType.Primitive(PType.I64, true)); assertThat(schema.nullable()).isFalse(); } @@ -163,7 +163,7 @@ void dropsMaxAndMinForDTypeNull() { @Test void dropsSumForUnsupportedColumnDtype() { // Given — Utf8 column has no sum (Rust returns None) - DType columnDtype = new DType.Utf8(false); + DType columnDtype = DType.UTF8; List present = List.of( ZonedStatsSchema.Stat.MIN, ZonedStatsSchema.Stat.SUM, @@ -179,7 +179,7 @@ void dropsSumForUnsupportedColumnDtype() { @Test void dropsNanCountForNonFloatColumn() { // Given — nan_count only makes sense for floats - DType columnDtype = new DType.Primitive(PType.I32, false); + DType columnDtype = DType.I32; List present = List.of( ZonedStatsSchema.Stat.MAX, ZonedStatsSchema.Stat.NAN_COUNT, @@ -195,7 +195,7 @@ void dropsNanCountForNonFloatColumn() { @Test void keepsNanCountForFloatColumn() { // Given — float column → nan_count is u64 - DType columnDtype = new DType.Primitive(PType.F64, false); + DType columnDtype = DType.F64; List present = List.of( ZonedStatsSchema.Stat.MAX, ZonedStatsSchema.Stat.NAN_COUNT); @@ -211,7 +211,7 @@ void keepsNanCountForFloatColumn() { void resolvesExtensionViaStorageDType() { // Given — ext over i32 storage; sum should widen using storage dtype (i32 → i64) DType columnDtype = new DType.Extension("ip.address", - new DType.Primitive(PType.I32, false), null, false); + DType.I32, null, false); List present = List.of( ZonedStatsSchema.Stat.MIN, ZonedStatsSchema.Stat.SUM); @@ -227,7 +227,7 @@ void resolvesExtensionViaStorageDType() { @Test void allStatsTogetherForI32() { // Given — sanity that every stat slots correctly into i32 column - DType columnDtype = new DType.Primitive(PType.I32, false); + DType columnDtype = DType.I32; List present = List.copyOf(EnumSet.allOf(ZonedStatsSchema.Stat.class)); // When diff --git a/integration/src/test/java/io/github/dfa1/vortex/integration/ConstantEncodingSelectionIntegrationTest.java b/integration/src/test/java/io/github/dfa1/vortex/integration/ConstantEncodingSelectionIntegrationTest.java index 39dd2444..73296e0f 100644 --- a/integration/src/test/java/io/github/dfa1/vortex/integration/ConstantEncodingSelectionIntegrationTest.java +++ b/integration/src/test/java/io/github/dfa1/vortex/integration/ConstantEncodingSelectionIntegrationTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.integration; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.inspect.VortexInspector; import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.reader.VortexReader; @@ -26,7 +25,7 @@ class ConstantEncodingSelectionIntegrationTest { private static final DType.Struct SCHEMA = new DType.Struct( List.of("v"), - List.of(new DType.Primitive(PType.I64, false)), + List.of(DType.I64), false); @Test diff --git a/integration/src/test/java/io/github/dfa1/vortex/integration/FileSizeComparisonIntegrationTest.java b/integration/src/test/java/io/github/dfa1/vortex/integration/FileSizeComparisonIntegrationTest.java index bfaf1f0c..cb6ee3f3 100644 --- a/integration/src/test/java/io/github/dfa1/vortex/integration/FileSizeComparisonIntegrationTest.java +++ b/integration/src/test/java/io/github/dfa1/vortex/integration/FileSizeComparisonIntegrationTest.java @@ -4,7 +4,6 @@ import dev.vortex.arrow.ArrowAllocation; import dev.vortex.jni.NativeLoader; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.LongArray; import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.reader.VortexReader; @@ -54,13 +53,13 @@ class FileSizeComparisonIntegrationTest { private static final DType.Struct JAVA_SCHEMA = new DType.Struct( List.of("symbol", "date", "open", "high", "low", "close", "volume"), List.of( - new DType.Utf8(false), - new DType.Primitive(PType.I32, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.I64, false) + DType.UTF8, + DType.I32, + DType.F64, + DType.F64, + DType.F64, + DType.F64, + DType.I64 ), false ); @@ -295,7 +294,7 @@ void pco_i64_javaVsJni(@TempDir Path tmp) throws IOException { } DType.Struct javaSchema = new DType.Struct( - List.of("v"), List.of(new DType.Primitive(PType.I64, false)), false); + List.of("v"), List.of(DType.I64), false); Schema jniSchema = new Schema(List.of( Field.notNullable("v", new ArrowType.Int(64, true)))); @@ -358,7 +357,7 @@ void highCardinalityUtf8_javaVsJni(@TempDir Path tmp) throws IOException { data[i] = new String(bytes, StandardCharsets.UTF_8); } DType.Struct javaSchema = new DType.Struct( - List.of("s"), List.of(new DType.Utf8(false)), false); + List.of("s"), List.of(DType.UTF8), false); Schema jniSchema = new Schema(List.of( Field.notNullable("s", new ArrowType.Utf8()))); diff --git a/integration/src/test/java/io/github/dfa1/vortex/integration/JavaRoundTripIntegrationTest.java b/integration/src/test/java/io/github/dfa1/vortex/integration/JavaRoundTripIntegrationTest.java index 96a4b625..df456c08 100644 --- a/integration/src/test/java/io/github/dfa1/vortex/integration/JavaRoundTripIntegrationTest.java +++ b/integration/src/test/java/io/github/dfa1/vortex/integration/JavaRoundTripIntegrationTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.integration; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.reader.ScanOptions; import io.github.dfa1.vortex.reader.VortexReader; @@ -32,7 +31,7 @@ class JavaRoundTripIntegrationTest { private static final DType.Struct I32_SCHEMA = new DType.Struct( List.of("v"), - List.of(new DType.Primitive(PType.I32, false)), + List.of(DType.I32), false); @Test diff --git a/integration/src/test/java/io/github/dfa1/vortex/integration/JavaWritesRustReadsIntegrationTest.java b/integration/src/test/java/io/github/dfa1/vortex/integration/JavaWritesRustReadsIntegrationTest.java index 0c140a5f..10963940 100644 --- a/integration/src/test/java/io/github/dfa1/vortex/integration/JavaWritesRustReadsIntegrationTest.java +++ b/integration/src/test/java/io/github/dfa1/vortex/integration/JavaWritesRustReadsIntegrationTest.java @@ -82,65 +82,65 @@ class JavaWritesRustReadsIntegrationTest { private static final BufferAllocator ALLOCATOR = ArrowAllocation.rootAllocator(); private static final DType.Struct SCHEMA = new DType.Struct( List.of("id", "value"), - List.of(new DType.Primitive(PType.I64, false), - new DType.Primitive(PType.F64, false)), + List.of(DType.I64, + DType.F64), false); private static final DType.Struct I32_SCHEMA = new DType.Struct( List.of("v"), - List.of(new DType.Primitive(PType.I32, false)), + List.of(DType.I32), false); private static final DType.Struct STRING_SCHEMA = new DType.Struct( List.of("s"), - List.of(new DType.Utf8(false)), + List.of(DType.UTF8), false); private static final DType.Struct TS_SCHEMA = new DType.Struct( List.of("ts"), - List.of(new DType.Primitive(PType.I64, false)), + List.of(DType.I64), false); private static final DType.Struct F32_SCHEMA = new DType.Struct( List.of("v"), - List.of(new DType.Primitive(PType.F32, false)), + List.of(DType.F32), false); private static final DType.Struct F64_SCHEMA = new DType.Struct( List.of("v"), - List.of(new DType.Primitive(PType.F64, false)), + List.of(DType.F64), false); private static final DType.Struct F16_SCHEMA = new DType.Struct( List.of("v"), - List.of(new DType.Primitive(PType.F16, false)), + List.of(DType.F16), false); private static final DType.Struct BOOL_SCHEMA = new DType.Struct( List.of("b"), - List.of(new DType.Bool(false)), + List.of(DType.BOOL), false); private static final DType.Struct NULL_SCHEMA = new DType.Struct( List.of("n"), - List.of(new DType.Null(false)), + List.of(DType.NULL), false); private static final DType.Struct LIST_I64_SCHEMA = new DType.Struct( List.of("items"), - List.of(new DType.List(new DType.Primitive(PType.I64, false), false)), + List.of(new DType.List(DType.I64, false)), false); private static final DType.Struct OHLC_SCHEMA = new DType.Struct( List.of("date", "symbol", "open", "high", "low", "close", "volume"), List.of( - new DType.Primitive(PType.I32, false), - new DType.Utf8(false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.I64, false)), + DType.I32, + DType.UTF8, + DType.F64, + DType.F64, + DType.F64, + DType.F64, + DType.I64), false); static { @@ -1238,7 +1238,7 @@ void javaWriter_rustReader_globalDict_i64(@TempDir Path tmp) throws IOException Path file = tmp.resolve("java_globaldict_i64.vtx"); DType.Struct schema = new DType.Struct( List.of("v"), - List.of(new DType.Primitive(PType.I64, false)), + List.of(DType.I64), false); long[] chunk1 = {1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L}; long[] chunk2 = {3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L}; @@ -1263,7 +1263,7 @@ void javaWriter_rustReader_globalDict_f64(@TempDir Path tmp) throws IOException Path file = tmp.resolve("java_globaldict_f64.vtx"); DType.Struct schema = new DType.Struct( List.of("v"), - List.of(new DType.Primitive(PType.F64, false)), + List.of(DType.F64), false); double[] chunk1 = {1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0}; double[] chunk2 = {3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0}; diff --git a/integration/src/test/java/io/github/dfa1/vortex/integration/RustWritesJavaReadsIntegrationTest.java b/integration/src/test/java/io/github/dfa1/vortex/integration/RustWritesJavaReadsIntegrationTest.java index 73c729a4..8a16ffee 100644 --- a/integration/src/test/java/io/github/dfa1/vortex/integration/RustWritesJavaReadsIntegrationTest.java +++ b/integration/src/test/java/io/github/dfa1/vortex/integration/RustWritesJavaReadsIntegrationTest.java @@ -559,7 +559,7 @@ void jniWriter_javaReader_f16_primitiveRoundTrip(@TempDir Path tmp) throws IOExc // Then — correct dtype, correct values assertThat(vf.dtype()).isInstanceOf(DType.Struct.class); assertThat(((DType.Struct) vf.dtype()).field("v")) - .isEqualTo(new DType.Primitive(PType.F16, false)); + .isEqualTo(DType.F16); assertThat(results).hasSize(1); // F16 column snapshots as a short[] (raw float16 bits) short[] decoded = (short[]) results.getFirst().columns().get("v"); diff --git a/integration/src/test/java/io/github/dfa1/vortex/integration/VariantJavaWritesRustReadsIntegrationTest.java b/integration/src/test/java/io/github/dfa1/vortex/integration/VariantJavaWritesRustReadsIntegrationTest.java index 73fca9d9..38df8bc3 100644 --- a/integration/src/test/java/io/github/dfa1/vortex/integration/VariantJavaWritesRustReadsIntegrationTest.java +++ b/integration/src/test/java/io/github/dfa1/vortex/integration/VariantJavaWritesRustReadsIntegrationTest.java @@ -5,7 +5,6 @@ import dev.vortex.arrow.ArrowAllocation; import dev.vortex.jni.NativeLoader; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.proto.Primitive; import io.github.dfa1.vortex.proto.Scalar; import io.github.dfa1.vortex.proto.ScalarValue; @@ -39,7 +38,7 @@ class VariantJavaWritesRustReadsIntegrationTest { private static final DType.Struct VARIANT_SCHEMA = new DType.Struct( List.of("v"), - List.of(new DType.Variant(false)), + List.of(DType.VARIANT), false); static { @@ -98,7 +97,7 @@ void javaWriter_jniReader_shreddedVariantColumn(@TempDir Path tmp) throws IOExce Path file = tmp.resolve("java_variant_shredded.vtx"); List values = List.of(i32Variant(10L), i32Variant(20L), i32Variant(30L)); VariantData data = VariantData.shredded( - values, new int[]{10, 20, 30}, new DType.Primitive(PType.I32, false)); + values, new int[]{10, 20, 30}, DType.I32); try (var ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); var sut = VortexWriter.create(ch, VARIANT_SCHEMA, WriteOptions.defaults())) { diff --git a/integration/src/test/java/io/github/dfa1/vortex/integration/load/LargeCsvRoundTripLoadIntegrationTest.java b/integration/src/test/java/io/github/dfa1/vortex/integration/load/LargeCsvRoundTripLoadIntegrationTest.java index b9ae4f80..762788b9 100644 --- a/integration/src/test/java/io/github/dfa1/vortex/integration/load/LargeCsvRoundTripLoadIntegrationTest.java +++ b/integration/src/test/java/io/github/dfa1/vortex/integration/load/LargeCsvRoundTripLoadIntegrationTest.java @@ -6,7 +6,6 @@ import de.siegmar.fastcsv.reader.CsvRecord; import de.siegmar.fastcsv.writer.CsvWriter; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.csv.CsvExporter; import io.github.dfa1.vortex.csv.CsvImporter; import io.github.dfa1.vortex.csv.ExportOptions; @@ -47,14 +46,14 @@ class LargeCsvRoundTripLoadIntegrationTest { private static final DType.Struct SCHEMA = new DType.Struct( List.of("id", "a", "b", "x", "y", "flag", "sym", "note"), List.of( - new DType.Primitive(PType.I64, false), - new DType.Primitive(PType.I64, false), - new DType.Primitive(PType.I64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Bool(false), - new DType.Utf8(false), - new DType.Utf8(false)), + DType.I64, + DType.I64, + DType.I64, + DType.F64, + DType.F64, + DType.BOOL, + DType.UTF8, + DType.UTF8), false); private static final String[] HEADER = SCHEMA.fieldNames().toArray(String[]::new); diff --git a/jdbc/src/test/java/io/github/dfa1/vortex/jdbc/JdbcImporterTest.java b/jdbc/src/test/java/io/github/dfa1/vortex/jdbc/JdbcImporterTest.java index 04abf1c5..75982e3e 100644 --- a/jdbc/src/test/java/io/github/dfa1/vortex/jdbc/JdbcImporterTest.java +++ b/jdbc/src/test/java/io/github/dfa1/vortex/jdbc/JdbcImporterTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.jdbc; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.BoolArray; import io.github.dfa1.vortex.reader.array.DoubleArray; import io.github.dfa1.vortex.reader.array.LongArray; @@ -65,10 +64,10 @@ void roundTripsAllSupportedTypes(@TempDir Path tmp) throws Exception { assertThat(reader.dtype()).isInstanceOf(DType.Struct.class); DType.Struct schema = (DType.Struct) reader.dtype(); assertThat(schema.fieldNames()).containsExactly("ID", "NAME", "SCORE", "ACTIVE"); - assertThat(schema.fieldTypes().get(0)).isEqualTo(new DType.Primitive(PType.I64, false)); - assertThat(schema.fieldTypes().get(1)).isEqualTo(new DType.Utf8(false)); - assertThat(schema.fieldTypes().get(2)).isEqualTo(new DType.Primitive(PType.F64, false)); - assertThat(schema.fieldTypes().get(3)).isEqualTo(new DType.Bool(false)); + assertThat(schema.fieldTypes().get(0)).isEqualTo(DType.I64); + assertThat(schema.fieldTypes().get(1)).isEqualTo(DType.UTF8); + assertThat(schema.fieldTypes().get(2)).isEqualTo(DType.F64); + assertThat(schema.fieldTypes().get(3)).isEqualTo(DType.BOOL); try (ScanIterator iter = reader.scan(ScanOptions.all())) { assertThat(iter.hasNext()).isTrue(); diff --git a/parquet/src/test/java/io/github/dfa1/vortex/parquet/ParquetImporterTest.java b/parquet/src/test/java/io/github/dfa1/vortex/parquet/ParquetImporterTest.java index 35ec9f74..bb2126ba 100644 --- a/parquet/src/test/java/io/github/dfa1/vortex/parquet/ParquetImporterTest.java +++ b/parquet/src/test/java/io/github/dfa1/vortex/parquet/ParquetImporterTest.java @@ -39,7 +39,7 @@ class TypeMapping { void boolean_mapsToBool_carryingNullability() { // Given / When / Then — REQUIRED is non-null, OPTIONAL is nullable assertThat(ParquetImporter.mapDType(col("b", PhysicalType.BOOLEAN, RepetitionType.REQUIRED, null))) - .isEqualTo(new DType.Bool(false)); + .isEqualTo(DType.BOOL); assertThat(ParquetImporter.mapDType(col("b", PhysicalType.BOOLEAN, RepetitionType.OPTIONAL, null))) .isEqualTo(new DType.Bool(true)); } @@ -50,7 +50,7 @@ void int32_withoutAnnotation_mapsToI32() { DType result = ParquetImporter.mapDType(col("i", PhysicalType.INT32, RepetitionType.REQUIRED, null)); // Then - assertThat(result).isEqualTo(new DType.Primitive(PType.I32, false)); + assertThat(result).isEqualTo(DType.I32); } @ParameterizedTest @@ -78,11 +78,11 @@ void int32_withIntAnnotation_mapsToSizedPType(int bitWidth, boolean signed, PTyp void int64_signedAndUnsigned_mapToI64AndU64() { // Given / When / Then assertThat(ParquetImporter.mapDType(col("l", PhysicalType.INT64, RepetitionType.REQUIRED, null))) - .isEqualTo(new DType.Primitive(PType.I64, false)); + .isEqualTo(DType.I64); assertThat(ParquetImporter.mapDType(col("l", PhysicalType.INT64, RepetitionType.REQUIRED, - new LogicalType.IntType(64, true)))).isEqualTo(new DType.Primitive(PType.I64, false)); + new LogicalType.IntType(64, true)))).isEqualTo(DType.I64); assertThat(ParquetImporter.mapDType(col("l", PhysicalType.INT64, RepetitionType.REQUIRED, - new LogicalType.IntType(64, false)))).isEqualTo(new DType.Primitive(PType.U64, false)); + new LogicalType.IntType(64, false)))).isEqualTo(DType.U64); } @ParameterizedTest @@ -107,9 +107,9 @@ void int64_timestamp_mapsToTimestampExtensionOverI64(LogicalType.TimeUnit unit) void float_and_double_mapToF32AndF64() { // Given / When / Then assertThat(ParquetImporter.mapDType(col("f", PhysicalType.FLOAT, RepetitionType.REQUIRED, null))) - .isEqualTo(new DType.Primitive(PType.F32, false)); + .isEqualTo(DType.F32); assertThat(ParquetImporter.mapDType(col("d", PhysicalType.DOUBLE, RepetitionType.REQUIRED, null))) - .isEqualTo(new DType.Primitive(PType.F64, false)); + .isEqualTo(DType.F64); } @Test diff --git a/performance/src/main/java/io/github/dfa1/vortex/performance/JavaVsJniReadBenchmark.java b/performance/src/main/java/io/github/dfa1/vortex/performance/JavaVsJniReadBenchmark.java index f00fc5f1..963a712c 100644 --- a/performance/src/main/java/io/github/dfa1/vortex/performance/JavaVsJniReadBenchmark.java +++ b/performance/src/main/java/io/github/dfa1/vortex/performance/JavaVsJniReadBenchmark.java @@ -9,7 +9,6 @@ import dev.vortex.arrow.ArrowAllocation; import dev.vortex.jni.NativeLoader; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.DoubleArray; import io.github.dfa1.vortex.reader.array.LongArray; import io.github.dfa1.vortex.reader.array.VarBinArray; @@ -100,13 +99,13 @@ public class JavaVsJniReadBenchmark { private static final DType.Struct JAVA_SCHEMA = new DType.Struct( List.of("date", "symbol", "open", "high", "low", "close", "volume"), List.of( - new DType.Primitive(PType.I32, false), - new DType.Utf8(false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.I64, false) + DType.I32, + DType.UTF8, + DType.F64, + DType.F64, + DType.F64, + DType.F64, + DType.I64 ), false); private static final Object FILE_LOCK = new Object(); diff --git a/performance/src/main/java/io/github/dfa1/vortex/performance/JavaVsJniWriteBenchmark.java b/performance/src/main/java/io/github/dfa1/vortex/performance/JavaVsJniWriteBenchmark.java index e7f1926e..726124f3 100644 --- a/performance/src/main/java/io/github/dfa1/vortex/performance/JavaVsJniWriteBenchmark.java +++ b/performance/src/main/java/io/github/dfa1/vortex/performance/JavaVsJniWriteBenchmark.java @@ -4,7 +4,6 @@ import dev.vortex.arrow.ArrowAllocation; import dev.vortex.jni.NativeLoader; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.writer.VortexWriter; import io.github.dfa1.vortex.writer.WriteOptions; import org.apache.arrow.c.ArrowArray; @@ -87,13 +86,13 @@ public class JavaVsJniWriteBenchmark { private static final DType.Struct JAVA_SCHEMA = new DType.Struct( List.of("date", "symbol", "open", "high", "low", "close", "volume"), List.of( - new DType.Primitive(PType.I32, false), - new DType.Utf8(false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.F64, false), - new DType.Primitive(PType.I64, false) + DType.I32, + DType.UTF8, + DType.F64, + DType.F64, + DType.F64, + DType.F64, + DType.I64 ), false ); diff --git a/performance/src/main/java/io/github/dfa1/vortex/performance/LazyArrayWalkBenchmark.java b/performance/src/main/java/io/github/dfa1/vortex/performance/LazyArrayWalkBenchmark.java index 835c820a..14370c60 100644 --- a/performance/src/main/java/io/github/dfa1/vortex/performance/LazyArrayWalkBenchmark.java +++ b/performance/src/main/java/io/github/dfa1/vortex/performance/LazyArrayWalkBenchmark.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.performance; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.reader.array.DoubleArray; import io.github.dfa1.vortex.reader.array.FloatArray; @@ -53,11 +52,11 @@ public class LazyArrayWalkBenchmark { private static final int NUM_CHUNKS = (ROWS + 1023) / 1024; private static final int SPARSE_PATCHES = 1_000; - private static final DType I32 = new DType.Primitive(PType.I32, false); - private static final DType I64 = new DType.Primitive(PType.I64, false); - private static final DType I8 = new DType.Primitive(PType.I8, false); - private static final DType F64 = new DType.Primitive(PType.F64, false); - private static final DType F32 = new DType.Primitive(PType.F32, false); + private static final DType I32 = DType.I32; + private static final DType I64 = DType.I64; + private static final DType I8 = DType.I8; + private static final DType F64 = DType.F64; + private static final DType F32 = DType.F32; private Arena arena; diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/ScanIterator.java b/reader/src/main/java/io/github/dfa1/vortex/reader/ScanIterator.java index df0c1d43..a3bd0927 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/ScanIterator.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/ScanIterator.java @@ -504,7 +504,7 @@ private static Array sliceArray(Array full, long offset, long length, DType dtyp BoolArray validity = m.validity(); BoolArray validitySlice = validity == null ? null - : (BoolArray) sliceArray(validity, offset, length, new DType.Bool(false)); + : (BoolArray) sliceArray(validity, offset, length, DType.BOOL); yield new MaskedArray(innerSlice, validitySlice); } case LongArray a -> new OffsetLongArray(dtype, length, a, offset); diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/AlpEncodingDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/AlpEncodingDecoder.java index 3eeaa10e..8bc2f4aa 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/AlpEncodingDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/AlpEncodingDecoder.java @@ -26,8 +26,6 @@ public final class AlpEncodingDecoder implements EncodingDecoder { private static final double[] IF10_F64 = {1e-0, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8, 1e-9, 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15, 1e-16, 1e-17, 1e-18, 1e-19, 1e-20, 1e-21, 1e-22, 1e-23}; private static final float[] F10_F32 = {1e0f, 1e1f, 1e2f, 1e3f, 1e4f, 1e5f, 1e6f, 1e7f, 1e8f, 1e9f, 1e10f}; private static final float[] IF10_F32 = {1e-0f, 1e-1f, 1e-2f, 1e-3f, 1e-4f, 1e-5f, 1e-6f, 1e-7f, 1e-8f, 1e-9f, 1e-10f}; - private static final DType I64_DTYPE = new DType.Primitive(PType.I64, false); - private static final DType I32_DTYPE = new DType.Primitive(PType.I32, false); /// Public no-arg constructor required by [java.util.ServiceLoader]. public AlpEncodingDecoder() { @@ -76,7 +74,7 @@ private static Array decodeF64(DecodeContext ctx, ALPMetadata meta, int expE, in // the encoder's verify step. double df = F10_F64[expF]; double de = IF10_F64[expE]; - MemorySegment src = ctx.decodeChildSegment(0, I64_DTYPE, n); + MemorySegment src = ctx.decodeChildSegment(0, DType.I64, n); long srcCap = SegmentBroadcast.capacity(src, 8); if (meta.patches() == null) { @@ -106,7 +104,7 @@ private static Array decodeF64(DecodeContext ctx, ALPMetadata meta, int expE, in private static Array decodeF32(DecodeContext ctx, ALPMetadata meta, int expE, int expF, long n) { float df = F10_F32[expF]; float de = IF10_F32[expE]; - MemorySegment src = ctx.decodeChildSegment(0, I32_DTYPE, n); + MemorySegment src = ctx.decodeChildSegment(0, DType.I32, n); long srcCap = SegmentBroadcast.capacity(src, 4); if (meta.patches() == null) { diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/AlpRdEncodingDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/AlpRdEncodingDecoder.java index 79312922..35d569ea 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/AlpRdEncodingDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/AlpRdEncodingDecoder.java @@ -21,9 +21,6 @@ /// Read-only decoder for `vortex.alprd`. public final class AlpRdEncodingDecoder implements EncodingDecoder { - private static final DType U16_DTYPE = new DType.Primitive(PType.U16, false); - private static final DType U32_DTYPE = new DType.Primitive(PType.U32, false); - private static final DType U64_DTYPE = new DType.Primitive(PType.U64, false); /// Public no-arg constructor required by [java.util.ServiceLoader]. public AlpRdEncodingDecoder() { @@ -55,20 +52,20 @@ public Array decode(DecodeContext ctx) { // Lazy path: keep left/right as typed Arrays + patches as a small short[] + // a lazy indices Array. No n-sized output buffer allocated. - Array leftRaw = ctx.decodeChild(0, U16_DTYPE, n); + Array leftRaw = ctx.decodeChild(0, DType.U16, n); ShortArray leftArr = (ShortArray) unwrap(leftRaw); Patches patches = decodePatches(ctx, meta.patches()); return switch (ptype) { case F64 -> { - Array rightRaw = ctx.decodeChild(1, U64_DTYPE, n); + Array rightRaw = ctx.decodeChild(1, DType.U64, n); LongArray rightArr = (LongArray) unwrap(rightRaw); yield new LazyAlpRdDoubleArray(ctx.dtype(), n, dict, rightBitWidth, leftArr, rightArr, patches.indices, patches.leftValues, patches.offset); } case F32 -> { - Array rightRaw = ctx.decodeChild(1, U32_DTYPE, n); + Array rightRaw = ctx.decodeChild(1, DType.U32, n); IntArray rightArr = (IntArray) unwrap(rightRaw); yield new LazyAlpRdFloatArray(ctx.dtype(), n, dict, rightBitWidth, leftArr, rightArr, patches.indices, patches.leftValues, patches.offset); @@ -102,7 +99,7 @@ private static Patches decodePatches(DecodeContext ctx, PatchesMetadata pm) { // Pull the small left-values table into a short[] so lookups don't pay an // Array-dispatch per patch hit. Patches are typically <1% of rows. - MemorySegment valSeg = ctx.decodeChildSegment(3, U16_DTYPE, numPatches); + MemorySegment valSeg = ctx.decodeChildSegment(3, DType.U16, numPatches); long valCap = SegmentBroadcast.capacity(valSeg, 2); short[] leftValues = new short[(int) numPatches]; for (int j = 0; j < numPatches; j++) { diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/ChunkedEncodingDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/ChunkedEncodingDecoder.java index e41db0b4..ad4e9277 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/ChunkedEncodingDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/ChunkedEncodingDecoder.java @@ -56,8 +56,7 @@ public Array decode(DecodeContext ctx) { } private static long[] readOffsets(DecodeContext ctx, int nchunks) { - DType u64 = new DType.Primitive(PType.U64, false); - MemorySegment offsetsBuf = ctx.decodeChildSegment(0, u64, nchunks + 1L); + MemorySegment offsetsBuf = ctx.decodeChildSegment(0, DType.U64, nchunks + 1L); long cap = SegmentBroadcast.capacity(offsetsBuf, 8); long[] offsets = new long[nchunks + 1]; for (int i = 0; i <= nchunks; i++) { diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/MaskedEncodingDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/MaskedEncodingDecoder.java index 8f8522e1..bf026b4c 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/MaskedEncodingDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/MaskedEncodingDecoder.java @@ -35,7 +35,7 @@ public Array decode(DecodeContext ctx) { BoolArray validity = null; if (numChildren == 2) { - Array validityArray = ctx.decodeChild(1, new DType.Bool(false), ctx.rowCount()); + Array validityArray = ctx.decodeChild(1, DType.BOOL, ctx.rowCount()); if (!(validityArray instanceof BoolArray ba)) { throw new VortexException(EncodingId.VORTEX_MASKED, "validity child decoded to unexpected type: " + validityArray.getClass().getSimpleName()); diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PatchedEncodingDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PatchedEncodingDecoder.java index 62b4eb00..bcfd5203 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PatchedEncodingDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PatchedEncodingDecoder.java @@ -66,9 +66,9 @@ public Array decode(DecodeContext ctx) { MemorySegment innerSeg = ctx.decodeChildSegment(0, ctx.dtype(), n); MemorySegment laneOffsetsSeg = ctx.decodeChildSegment(1, - new DType.Primitive(PType.U32, false), nChunks * nLanes + 1); + DType.U32, nChunks * nLanes + 1); MemorySegment patchIndicesSeg = ctx.decodeChildSegment(2, - new DType.Primitive(PType.U16, false), nPatches); + DType.U16, nPatches); MemorySegment patchValuesSeg = ctx.decodeChildSegment(3, ctx.dtype(), nPatches); MemorySegment out = ctx.arena().allocate(n * elemBytes); diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoder.java index a089896e..63244195 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoder.java @@ -61,7 +61,7 @@ public Array decode(DecodeContext ctx) { BoolArray validity = null; long validCount = n; if (ctx.node().children().length > 0) { - Array validityArr = ctx.decodeChild(0, new DType.Bool(false), n); + Array validityArr = ctx.decodeChild(0, DType.BOOL, n); if (!(validityArr instanceof BoolArray ba)) { throw new VortexException(EncodingId.VORTEX_PCO, "pco validity child must be Bool, got: " + validityArr.getClass().getSimpleName()); diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PrimitiveEncodingDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PrimitiveEncodingDecoder.java index 9c436fa3..49773c4d 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PrimitiveEncodingDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/PrimitiveEncodingDecoder.java @@ -45,7 +45,7 @@ public Array decode(DecodeContext ctx) { case F16 -> new MaterializedFloat16Array(dt, n, buf); }; if (ctx.node().children().length == 1) { - Array va = ctx.decodeChild(0, new DType.Bool(false), n); + Array va = ctx.decodeChild(0, DType.BOOL, n); if (!(va instanceof BoolArray validity)) { throw new VortexException(EncodingId.VORTEX_PRIMITIVE, "validity child decoded to unexpected type: " + va.getClass().getSimpleName()); diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/RleEncodingDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/RleEncodingDecoder.java index 7468b6e8..896eb63d 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/RleEncodingDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/RleEncodingDecoder.java @@ -107,7 +107,7 @@ public Array decode(DecodeContext ctx) { if (indicesValidity == null) { return result; } - BoolArray outputValidity = new OffsetBoolArray(new DType.Bool(false), rowCount, indicesValidity, offset); + BoolArray outputValidity = new OffsetBoolArray(DType.BOOL, rowCount, indicesValidity, offset); return new MaskedArray(result, outputValidity); } diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/StructEncodingDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/StructEncodingDecoder.java index 1e32dba7..ea88586c 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/StructEncodingDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/StructEncodingDecoder.java @@ -40,7 +40,7 @@ public Array decode(DecodeContext ctx) { BoolArray structValidity = null; if (hasValidity) { ArrayNode validityNode = ctx.node().children()[0]; - var validityCtx = new DecodeContext(validityNode, new DType.Bool(false), + var validityCtx = new DecodeContext(validityNode, DType.BOOL, ctx.rowCount(), ctx.segmentBuffers(), ctx.registry(), ctx.arena()); Array va = ctx.registry().decode(validityCtx); if (!(va instanceof BoolArray ba)) { @@ -79,7 +79,7 @@ public Array decode(DecodeContext ctx) { return ctx.registry().decode(valuesCtx); } else if (numChildren == 2) { ArrayNode validityNode = ctx.node().children()[0]; - var validityCtx = new DecodeContext(validityNode, new DType.Bool(false), + var validityCtx = new DecodeContext(validityNode, DType.BOOL, ctx.rowCount(), ctx.segmentBuffers(), ctx.registry(), ctx.arena()); Array va = ctx.registry().decode(validityCtx); if (!(va instanceof BoolArray validity)) { diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/ZstdEncodingDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/ZstdEncodingDecoder.java index 00897a0b..51de6d69 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/decode/ZstdEncodingDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/decode/ZstdEncodingDecoder.java @@ -58,7 +58,7 @@ public Array decode(DecodeContext ctx) { BoolArray validity = null; if (ctx.node().children().length > 0) { - Array validityArray = ctx.decodeChild(0, new DType.Bool(false), ctx.rowCount()); + Array validityArray = ctx.decodeChild(0, DType.BOOL, ctx.rowCount()); if (!(validityArray instanceof BoolArray ba)) { throw new VortexException(EncodingId.VORTEX_ZSTD, "validity child decoded to unexpected type: " + validityArray.getClass().getSimpleName()); diff --git a/reader/src/main/java/io/github/dfa1/vortex/reader/extension/UuidExtensionDecoder.java b/reader/src/main/java/io/github/dfa1/vortex/reader/extension/UuidExtensionDecoder.java index 37e6ccbc..bfa5f8bd 100644 --- a/reader/src/main/java/io/github/dfa1/vortex/reader/extension/UuidExtensionDecoder.java +++ b/reader/src/main/java/io/github/dfa1/vortex/reader/extension/UuidExtensionDecoder.java @@ -2,7 +2,6 @@ import io.github.dfa1.vortex.core.DType; import io.github.dfa1.vortex.core.IoBounds; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.reader.array.ByteArray; @@ -35,7 +34,7 @@ public ExtensionId extensionId() { @Override public DType.Extension dtype(boolean nullable) { - DType.Primitive u8 = new DType.Primitive(PType.U8, false); + DType.Primitive u8 = DType.U8; // Rust vortex.uuid metadata: 0 bytes means "no specific version" — but the field // must be present in the flatbuffer or the Rust reader's ok_or_else() check fails. return new DType.Extension( diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/FlatSegmentBoundsSecurityTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/FlatSegmentBoundsSecurityTest.java index 199c1d44..13ff7f99 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/FlatSegmentBoundsSecurityTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/FlatSegmentBoundsSecurityTest.java @@ -3,7 +3,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import com.google.flatbuffers.FlatBufferBuilder; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.fbs.Array; import io.github.dfa1.vortex.fbs.ArrayNode; @@ -25,7 +24,7 @@ class FlatSegmentBoundsSecurityTest { - private static final DType DTYPE = new DType.Primitive(PType.I32, false); + private static final DType DTYPE = DType.I32; private final FlatSegmentDecoder sut = new FlatSegmentDecoder(ReadRegistry.empty()); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/FlatSegmentDecoderDecodeTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/FlatSegmentDecoderDecodeTest.java index e1d6d06a..f17118ac 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/FlatSegmentDecoderDecodeTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/FlatSegmentDecoderDecodeTest.java @@ -2,7 +2,6 @@ import com.google.flatbuffers.FlatBufferBuilder; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.fbs.ArrayNode; import io.github.dfa1.vortex.fbs.Buffer; import io.github.dfa1.vortex.reader.array.Array; @@ -44,7 +43,7 @@ void decode_unknownEncodingWithBufferPadding_returnsUnknownArray() { // When — encoding index 0 maps to an id no decoder handles Array result = sut.decode(seg, List.of("vortex.nonexistent"), - new DType.Primitive(PType.I32, false), 0, arena); + DType.I32, 0, arena); // Then — the allow-unknown path produced an UnknownArray (proves both the +padding // walk and the UnknownArrayNode fallback ran) diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/VortexHttpReaderIT.java b/reader/src/test/java/io/github/dfa1/vortex/reader/VortexHttpReaderIT.java index da3c087b..4424634b 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/VortexHttpReaderIT.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/VortexHttpReaderIT.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.core.VortexFormat; import io.github.dfa1.vortex.reader.array.ListArray; @@ -193,7 +192,7 @@ void scan_listVortex_decodesListArrayWithCorrectShape() throws Exception { .isGreaterThan(0); assertThat(listArray.offsets().dtype()) .as("offset_ptype must be I64; U8 indicates silent proto tag mismatch") - .isEqualTo(new DType.Primitive(PType.I64, false)); + .isEqualTo(DType.I64); assertThat(listArray.offsets().length()) .as("offsets length must be rowCount + 1") .isEqualTo(chunk.rowCount() + 1); @@ -231,10 +230,10 @@ void scan_listviewVortex_decodesListViewArrayWithCorrectShape() throws Exception .isGreaterThan(0); assertThat(listViewArray.offsets().dtype()) .as("offset_ptype must be U32; U8 indicates silent proto tag mismatch") - .isEqualTo(new DType.Primitive(PType.U32, false)); + .isEqualTo(DType.U32); assertThat(listViewArray.sizes().dtype()) .as("size_ptype must be U32; U8 indicates silent proto tag mismatch") - .isEqualTo(new DType.Primitive(PType.U32, false)); + .isEqualTo(DType.U32); assertThat(listViewArray.offsets().length()) .as("offsets length must equal rowCount") .isEqualTo(chunk.rowCount()); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/DictRecordSmokeTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/DictRecordSmokeTest.java index 3781cdfc..ef977927 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/DictRecordSmokeTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/DictRecordSmokeTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.encoding.PTypeIO; import org.junit.jupiter.api.Nested; @@ -18,14 +17,14 @@ class DictRecordSmokeTest { - private static final DType I64 = new DType.Primitive(PType.I64, false); - private static final DType I32 = new DType.Primitive(PType.I32, false); - private static final DType F64 = new DType.Primitive(PType.F64, false); - private static final DType F32 = new DType.Primitive(PType.F32, false); - private static final DType U8 = new DType.Primitive(PType.U8, false); - private static final DType U16 = new DType.Primitive(PType.U16, false); - private static final DType U32 = new DType.Primitive(PType.U32, false); - private static final DType U64 = new DType.Primitive(PType.U64, false); + private static final DType I64 = DType.I64; + private static final DType I32 = DType.I32; + private static final DType F64 = DType.F64; + private static final DType F32 = DType.F32; + private static final DType U8 = DType.U8; + private static final DType U16 = DType.U16; + private static final DType U32 = DType.U32; + private static final DType U64 = DType.U64; @Nested class Validation { @@ -545,6 +544,6 @@ private static BoolArray boolArray(Arena arena, boolean... values) { seg.set(ValueLayout.JAVA_BYTE, byteIdx, (byte) (cur | (1 << bitIdx))); } } - return new MaterializedBoolArray(new DType.Bool(false), values.length, seg.asReadOnly()); + return new MaterializedBoolArray(DType.BOOL, values.length, seg.asReadOnly()); } } diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/DoubleArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/DoubleArrayTest.java index 81318115..2377f9df 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/DoubleArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/DoubleArrayTest.java @@ -3,7 +3,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -68,7 +67,7 @@ void logicalLengthExceedsCapacity_wrapsAround() { // Given — constant-encoding: 1-element buffer, logical length 3; all 3 visits yield same value MemorySegment seg = Arena.ofAuto().allocate(8, 8); seg.setAtIndex(PTypeIO.LE_DOUBLE, 0, 2.71); - DoubleArray sut = new MaterializedDoubleArray(new DType.Primitive(PType.F64, false), 3, seg); + DoubleArray sut = new MaterializedDoubleArray(DType.F64, 3, seg); List collected = new ArrayList<>(); // When diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/GenericArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/GenericArrayTest.java index bfce4dfe..9da982ad 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/GenericArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/GenericArrayTest.java @@ -3,7 +3,6 @@ import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import org.junit.jupiter.api.Test; @@ -17,7 +16,7 @@ class GenericArrayTest { - private static final DType DTYPE = new DType.Primitive(PType.I64, false); + private static final DType DTYPE = DType.I64; @Test void withLength_shorterLength_returnsClampedView() { diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/IntArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/IntArrayTest.java index f3f028e9..3307aaa8 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/IntArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/IntArrayTest.java @@ -3,7 +3,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -68,7 +67,7 @@ void logicalLengthExceedsCapacity_wrapsAround() { // Given — constant-encoding: 1-element buffer, logical length 4; all 4 visits yield same value MemorySegment seg = Arena.ofAuto().allocate(4, 4); seg.setAtIndex(PTypeIO.LE_INT, 0, 7); - IntArray sut = new MaterializedIntArray(new DType.Primitive(PType.I32, false), 4, seg); + IntArray sut = new MaterializedIntArray(DType.I32, 4, seg); List collected = new ArrayList<>(); // When diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpDoubleArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpDoubleArrayTest.java index 84083d9e..cfebe422 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpDoubleArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpDoubleArrayTest.java @@ -2,7 +2,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -17,7 +16,7 @@ class LazyAlpDoubleArrayTest { - private static final DType F64 = new DType.Primitive(PType.F64, false); + private static final DType F64 = DType.F64; private static LazyAlpDoubleArray of(double scale, long... encoded) { MemorySegment seg = Arena.ofAuto().allocate((long) encoded.length * 8, 8); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpFloatArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpFloatArrayTest.java index 7cb2ab55..31168b75 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpFloatArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpFloatArrayTest.java @@ -2,7 +2,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Test; import java.lang.foreign.Arena; @@ -14,7 +13,7 @@ class LazyAlpFloatArrayTest { - private static final DType F32 = new DType.Primitive(PType.F32, false); + private static final DType F32 = DType.F32; private static LazyAlpFloatArray of(float scale, int... encoded) { MemorySegment seg = Arena.ofAuto().allocate((long) encoded.length * 4, 4); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpRdArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpRdArrayTest.java index 5f0fa70c..3c12009b 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpRdArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyAlpRdArrayTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -18,8 +17,8 @@ /// specific indices. class LazyAlpRdArrayTest { - private static final DType F64 = new DType.Primitive(PType.F64, false); - private static final DType F32 = new DType.Primitive(PType.F32, false); + private static final DType F64 = DType.F64; + private static final DType F32 = DType.F32; @Nested class DoubleDispatch { @@ -177,7 +176,7 @@ private static ShortArray shortArray(Arena arena, short... vs) { for (int i = 0; i < vs.length; i++) { seg.setAtIndex(ValueLayout.JAVA_SHORT, i, vs[i]); } - return new MaterializedShortArray(new DType.Primitive(PType.U16, false), vs.length, seg.asReadOnly()); + return new MaterializedShortArray(DType.U16, vs.length, seg.asReadOnly()); } private static IntArray intArray(Arena arena, int... vs) { @@ -185,7 +184,7 @@ private static IntArray intArray(Arena arena, int... vs) { for (int i = 0; i < vs.length; i++) { seg.setAtIndex(ValueLayout.JAVA_INT, i, vs[i]); } - return new MaterializedIntArray(new DType.Primitive(PType.I32, false), vs.length, seg.asReadOnly()); + return new MaterializedIntArray(DType.I32, vs.length, seg.asReadOnly()); } private static LongArray longArray(Arena arena, long... vs) { @@ -193,6 +192,6 @@ private static LongArray longArray(Arena arena, long... vs) { for (int i = 0; i < vs.length; i++) { seg.setAtIndex(ValueLayout.JAVA_LONG, i, vs[i]); } - return new MaterializedLongArray(new DType.Primitive(PType.I64, false), vs.length, seg.asReadOnly()); + return new MaterializedLongArray(DType.I64, vs.length, seg.asReadOnly()); } } diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyConstantArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyConstantArrayTest.java index 5f5b2233..c6d65e85 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyConstantArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyConstantArrayTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.encoding.PTypeIO; import org.junit.jupiter.api.Nested; @@ -22,7 +21,7 @@ class LazyConstantArrayTest { @Nested class LongConstant { private final LazyConstantLongArray sut = - new LazyConstantLongArray(new DType.Primitive(PType.I64, false), 4, 42L); + new LazyConstantLongArray(DType.I64, 4, 42L); @Test void getLong_returnsBroadcastValue() { @@ -51,7 +50,7 @@ void forEachLong_visitsValueOncePerRow() { @Test void fold_appliesValueLengthTimes() { // When - long result = new LazyConstantLongArray(new DType.Primitive(PType.I64, false), 3, 7L) + long result = new LazyConstantLongArray(DType.I64, 3, 7L) .fold(0L, Long::sum); // Then @@ -69,7 +68,7 @@ void getLong_outOfBounds_throws() { @Nested class IntConstant { private final LazyConstantIntArray sut = - new LazyConstantIntArray(new DType.Primitive(PType.I32, false), 3, -5); + new LazyConstantIntArray(DType.I32, 3, -5); @Test void getInt_returnsBroadcastValue() { @@ -111,32 +110,32 @@ class ShortConstant { @Test void getShort_returnsBroadcastValue() { - LazyConstantShortArray sut = new LazyConstantShortArray(new DType.Primitive(PType.I16, false), 2, RAW); + LazyConstantShortArray sut = new LazyConstantShortArray(DType.I16, 2, RAW); assertThat(sut.getShort(0)).isEqualTo(RAW); assertThat(sut.getShort(1)).isEqualTo(RAW); } @Test void getInt_signedKeepsSign_unsignedZeroExtends() { - assertThat(new LazyConstantShortArray(new DType.Primitive(PType.I16, false), 1, RAW).getInt(0)) + assertThat(new LazyConstantShortArray(DType.I16, 1, RAW).getInt(0)) .isEqualTo((int) RAW); - assertThat(new LazyConstantShortArray(new DType.Primitive(PType.U16, false), 1, RAW).getInt(0)) + assertThat(new LazyConstantShortArray(DType.U16, 1, RAW).getInt(0)) .isEqualTo(0xFF00); } @Test void fold_signedAndUnsignedWidening() { // signed short value is negative; unsigned is 0xFF00 - assertThat(new LazyConstantShortArray(new DType.Primitive(PType.I16, false), 2, RAW) + assertThat(new LazyConstantShortArray(DType.I16, 2, RAW) .fold(0L, Long::sum)).isEqualTo(2L * RAW); - assertThat(new LazyConstantShortArray(new DType.Primitive(PType.U16, false), 2, RAW) + assertThat(new LazyConstantShortArray(DType.U16, 2, RAW) .fold(0L, Long::sum)).isEqualTo(2L * 0xFF00); } @Test void nonPrimitiveDtype_treatedAsSigned() { // Given — a non-Primitive dtype hits the defensive `instanceof` false branch - LazyConstantShortArray sut = new LazyConstantShortArray(new DType.Bool(false), 2, RAW); + LazyConstantShortArray sut = new LazyConstantShortArray(DType.BOOL, 2, RAW); // When / Then — falls back to signed widening assertThat(sut.getInt(0)).isEqualTo((int) RAW); @@ -145,7 +144,7 @@ void nonPrimitiveDtype_treatedAsSigned() { @Test void outOfBounds_throws() { - LazyConstantShortArray sut = new LazyConstantShortArray(new DType.Primitive(PType.I16, false), 1, RAW); + LazyConstantShortArray sut = new LazyConstantShortArray(DType.I16, 1, RAW); assertThatThrownBy(() -> sut.getShort(-1)).isInstanceOf(IndexOutOfBoundsException.class); assertThatThrownBy(() -> sut.getShort(1)).isInstanceOf(IndexOutOfBoundsException.class); assertThatThrownBy(() -> sut.getInt(-1)).isInstanceOf(IndexOutOfBoundsException.class); @@ -159,31 +158,31 @@ class ByteConstant { @Test void getByte_returnsBroadcastValue() { - LazyConstantByteArray sut = new LazyConstantByteArray(new DType.Primitive(PType.I8, false), 2, RAW); + LazyConstantByteArray sut = new LazyConstantByteArray(DType.I8, 2, RAW); assertThat(sut.getByte(0)).isEqualTo(RAW); assertThat(sut.getByte(1)).isEqualTo(RAW); } @Test void getInt_signedKeepsSign_unsignedZeroExtends() { - assertThat(new LazyConstantByteArray(new DType.Primitive(PType.I8, false), 1, RAW).getInt(0)) + assertThat(new LazyConstantByteArray(DType.I8, 1, RAW).getInt(0)) .isEqualTo((int) RAW); - assertThat(new LazyConstantByteArray(new DType.Primitive(PType.U8, false), 1, RAW).getInt(0)) + assertThat(new LazyConstantByteArray(DType.U8, 1, RAW).getInt(0)) .isEqualTo(0xF0); } @Test void fold_signedAndUnsignedWidening() { - assertThat(new LazyConstantByteArray(new DType.Primitive(PType.I8, false), 2, RAW) + assertThat(new LazyConstantByteArray(DType.I8, 2, RAW) .fold(0L, Long::sum)).isEqualTo(2L * RAW); - assertThat(new LazyConstantByteArray(new DType.Primitive(PType.U8, false), 2, RAW) + assertThat(new LazyConstantByteArray(DType.U8, 2, RAW) .fold(0L, Long::sum)).isEqualTo(2L * 0xF0); } @Test void nonPrimitiveDtype_treatedAsSigned() { // Given — a non-Primitive dtype hits the defensive `instanceof` false branch - LazyConstantByteArray sut = new LazyConstantByteArray(new DType.Bool(false), 2, RAW); + LazyConstantByteArray sut = new LazyConstantByteArray(DType.BOOL, 2, RAW); // When / Then — falls back to signed widening assertThat(sut.getInt(0)).isEqualTo((int) RAW); @@ -192,7 +191,7 @@ void nonPrimitiveDtype_treatedAsSigned() { @Test void outOfBounds_throws() { - LazyConstantByteArray sut = new LazyConstantByteArray(new DType.Primitive(PType.I8, false), 1, RAW); + LazyConstantByteArray sut = new LazyConstantByteArray(DType.I8, 1, RAW); assertThatThrownBy(() -> sut.getByte(-1)).isInstanceOf(IndexOutOfBoundsException.class); assertThatThrownBy(() -> sut.getByte(1)).isInstanceOf(IndexOutOfBoundsException.class); assertThatThrownBy(() -> sut.getInt(-1)).isInstanceOf(IndexOutOfBoundsException.class); @@ -203,7 +202,7 @@ void outOfBounds_throws() { @Nested class DoubleConstant { private final LazyConstantDoubleArray sut = - new LazyConstantDoubleArray(new DType.Primitive(PType.F64, false), 3, 3.14); + new LazyConstantDoubleArray(DType.F64, 3, 3.14); @Test void getDouble_returnsBroadcastValue() { @@ -243,7 +242,7 @@ void getDouble_outOfBounds_throws() { @Nested class FloatConstant { private final LazyConstantFloatArray sut = - new LazyConstantFloatArray(new DType.Primitive(PType.F32, false), 2, 1.5f); + new LazyConstantFloatArray(DType.F32, 2, 1.5f); @Test void getFloat_returnsBroadcastValue() { @@ -267,8 +266,8 @@ void getFloat_outOfBounds_throws() { class BoolConstant { @Test void getBoolean_returnsBroadcastValue() { - assertThat(new LazyConstantBoolArray(new DType.Bool(false), 3, true).getBoolean(2)).isTrue(); - assertThat(new LazyConstantBoolArray(new DType.Bool(false), 3, false).getBoolean(0)).isFalse(); + assertThat(new LazyConstantBoolArray(DType.BOOL, 3, true).getBoolean(2)).isTrue(); + assertThat(new LazyConstantBoolArray(DType.BOOL, 3, false).getBoolean(0)).isFalse(); } @Test @@ -278,7 +277,7 @@ void forEachBoolean_visitsValueOncePerRow() { int[] total = {0}; // When - new LazyConstantBoolArray(new DType.Bool(false), 3, true).forEachBoolean(v -> { + new LazyConstantBoolArray(DType.BOOL, 3, true).forEachBoolean(v -> { if (v) { trueCount[0]++; } @@ -292,7 +291,7 @@ void forEachBoolean_visitsValueOncePerRow() { @Test void getBoolean_outOfBounds_throws() { - LazyConstantBoolArray sut = new LazyConstantBoolArray(new DType.Bool(false), 2, true); + LazyConstantBoolArray sut = new LazyConstantBoolArray(DType.BOOL, 2, true); assertThatThrownBy(() -> sut.getBoolean(-1)).isInstanceOf(IndexOutOfBoundsException.class); assertThatThrownBy(() -> sut.getBoolean(2)).isInstanceOf(IndexOutOfBoundsException.class); } diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyDecimalArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyDecimalArrayTest.java index f2f6022e..fdd73548 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyDecimalArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyDecimalArrayTest.java @@ -2,7 +2,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import org.junit.jupiter.api.Test; @@ -121,7 +120,7 @@ void getDecimal_nonDecimalDtype_throws() { try (Arena arena = Arena.ofConfined()) { MemorySegment buf = arena.allocate(8); LazyDecimalArray sut = new LazyDecimalArray( - new DType.Primitive(PType.I64, false), 1, buf, 8); + DType.I64, 1, buf, 8); // When / Then assertThatThrownBy(() -> sut.getDecimal(0)) diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyDecimalBytePartsArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyDecimalBytePartsArrayTest.java index daa4ef72..bd767ca1 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyDecimalBytePartsArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyDecimalBytePartsArrayTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import org.junit.jupiter.api.Test; @@ -25,7 +24,7 @@ void getDecimal_i64Mantissa_reassemblesAtDtypeScale() { mspBuf.set(ValueLayout.JAVA_LONG_UNALIGNED, 0, 4321L); mspBuf.set(ValueLayout.JAVA_LONG_UNALIGNED, 8, -100L); mspBuf.set(ValueLayout.JAVA_LONG_UNALIGNED, 16, 0L); - LongArray msp = new MaterializedLongArray(new DType.Primitive(PType.I64, false), 3, mspBuf); + LongArray msp = new MaterializedLongArray(DType.I64, 3, mspBuf); DType.Decimal dec = new DType.Decimal((byte) 15, (byte) 2, false); LazyDecimalBytePartsArray sut = new LazyDecimalBytePartsArray(dec, 3, msp); @@ -47,7 +46,7 @@ void getDecimal_widensFromNarrowerChildPtype() { mspBuf.set(ValueLayout.JAVA_INT_UNALIGNED, 0, 1234); mspBuf.set(ValueLayout.JAVA_INT_UNALIGNED, 4, -50); mspBuf.set(ValueLayout.JAVA_INT_UNALIGNED, 8, 0); - IntArray msp = new MaterializedIntArray(new DType.Primitive(PType.I32, false), 3, mspBuf); + IntArray msp = new MaterializedIntArray(DType.I32, 3, mspBuf); DType.Decimal dec = new DType.Decimal((byte) 15, (byte) 2, false); LazyDecimalBytePartsArray sut = new LazyDecimalBytePartsArray(dec, 3, msp); @@ -67,12 +66,12 @@ void getDecimal_nullCellInMaskedChild_throws() { MemorySegment mspBuf = arena.allocate(16); mspBuf.set(ValueLayout.JAVA_LONG_UNALIGNED, 0, 1234L); mspBuf.set(ValueLayout.JAVA_LONG_UNALIGNED, 8, 9999L); - LongArray msp = new MaterializedLongArray(new DType.Primitive(PType.I64, false), 2, mspBuf); + LongArray msp = new MaterializedLongArray(DType.I64, 2, mspBuf); MemorySegment validityBuf = arena.allocate(1); // bit 0 set = index 0 valid; bit 1 clear = index 1 null validityBuf.set(ValueLayout.JAVA_BYTE, 0, (byte) 0b0000_0001); - BoolArray validity = new MaterializedBoolArray(new DType.Bool(false), 2, validityBuf); + BoolArray validity = new MaterializedBoolArray(DType.BOOL, 2, validityBuf); MaskedArray masked = new MaskedArray(msp, validity); DType.Decimal dec = new DType.Decimal((byte) 15, (byte) 2, true); @@ -91,7 +90,7 @@ void getDecimal_indexOutOfBounds_throws() { // Given — explicit bounds check guards against silent garbage reads try (Arena arena = Arena.ofConfined()) { MemorySegment mspBuf = arena.allocate(8); - LongArray msp = new MaterializedLongArray(new DType.Primitive(PType.I64, false), 1, mspBuf); + LongArray msp = new MaterializedLongArray(DType.I64, 1, mspBuf); DType.Decimal dec = new DType.Decimal((byte) 4, (byte) 0, false); LazyDecimalBytePartsArray sut = new LazyDecimalBytePartsArray(dec, 1, msp); @@ -111,9 +110,9 @@ void getDecimal_nonDecimalDtype_throws() { // Given — guards against constructing the record with the wrong parent dtype try (Arena arena = Arena.ofConfined()) { MemorySegment mspBuf = arena.allocate(8); - LongArray msp = new MaterializedLongArray(new DType.Primitive(PType.I64, false), 1, mspBuf); + LongArray msp = new MaterializedLongArray(DType.I64, 1, mspBuf); LazyDecimalBytePartsArray sut = new LazyDecimalBytePartsArray( - new DType.Primitive(PType.I64, false), 1, msp); + DType.I64, 1, msp); // When / Then assertThatThrownBy(() -> sut.getDecimal(0)) diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForByteArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForByteArrayTest.java index dc153456..ff3845f9 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForByteArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForByteArrayTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Test; import java.lang.foreign.Arena; @@ -14,7 +13,7 @@ class LazyForByteArrayTest { - private static final DType I8 = new DType.Primitive(PType.I8, false); + private static final DType I8 = DType.I8; private static LazyForByteArray of(byte ref, byte... encoded) { MemorySegment seg = Arena.ofAuto().allocate(encoded.length); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForIntArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForIntArrayTest.java index f7942ce2..d1172e0f 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForIntArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForIntArrayTest.java @@ -2,7 +2,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Test; import java.lang.foreign.Arena; @@ -15,7 +14,7 @@ class LazyForIntArrayTest { - private static final DType I32 = new DType.Primitive(PType.I32, false); + private static final DType I32 = DType.I32; private static LazyForIntArray of(int ref, int... encoded) { MemorySegment seg = Arena.ofAuto().allocate((long) encoded.length * 4, 4); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForLongArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForLongArrayTest.java index 723c926f..ed370c76 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForLongArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForLongArrayTest.java @@ -2,7 +2,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -16,7 +15,7 @@ class LazyForLongArrayTest { - private static final DType I64 = new DType.Primitive(PType.I64, false); + private static final DType I64 = DType.I64; private static LazyForLongArray of(long ref, long... encoded) { MemorySegment seg = Arena.ofAuto().allocate((long) encoded.length * 8, 8); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForShortArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForShortArrayTest.java index 33d1e849..1c4b492a 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForShortArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyForShortArrayTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.encoding.PTypeIO; import org.junit.jupiter.api.Test; @@ -14,7 +13,7 @@ class LazyForShortArrayTest { - private static final DType I16 = new DType.Primitive(PType.I16, false); + private static final DType I16 = DType.I16; private static LazyForShortArray of(short ref, short... encoded) { MemorySegment seg = Arena.ofAuto().allocate((long) encoded.length * 2, 2); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyRleArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyRleArrayTest.java index e053aa5a..44eb96ff 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyRleArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyRleArrayTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -16,12 +15,12 @@ /// so they exercise the lazy semantics without needing a full encoder round-trip. class LazyRleArrayTest { - private static final DType I64 = new DType.Primitive(PType.I64, false); - private static final DType I32 = new DType.Primitive(PType.I32, false); - private static final DType U8 = new DType.Primitive(PType.U8, false); - private static final DType I8 = new DType.Primitive(PType.I8, false); - private static final DType U16 = new DType.Primitive(PType.U16, false); - private static final DType I16 = new DType.Primitive(PType.I16, false); + private static final DType I64 = DType.I64; + private static final DType I32 = DType.I32; + private static final DType U8 = DType.U8; + private static final DType I8 = DType.I8; + private static final DType U16 = DType.U16; + private static final DType I16 = DType.I16; @Nested class LongDispatch { diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagByteArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagByteArrayTest.java index 5197b6ac..8b686b7a 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagByteArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagByteArrayTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Test; import java.lang.foreign.Arena; @@ -14,7 +13,7 @@ class LazyZigZagByteArrayTest { - private static final DType I8 = new DType.Primitive(PType.I8, false); + private static final DType I8 = DType.I8; private static LazyZigZagByteArray of(byte... encoded) { MemorySegment seg = Arena.ofAuto().allocate(encoded.length); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagIntArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagIntArrayTest.java index c8266f91..9ee670a5 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagIntArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagIntArrayTest.java @@ -2,7 +2,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Test; import java.lang.foreign.Arena; @@ -15,7 +14,7 @@ class LazyZigZagIntArrayTest { - private static final DType I32 = new DType.Primitive(PType.I32, false); + private static final DType I32 = DType.I32; private static LazyZigZagIntArray of(int... encoded) { MemorySegment seg = Arena.ofAuto().allocate((long) encoded.length * 4, 4); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagLongArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagLongArrayTest.java index 04f51030..e75e2098 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagLongArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagLongArrayTest.java @@ -2,7 +2,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Test; import java.lang.foreign.Arena; @@ -15,7 +14,7 @@ class LazyZigZagLongArrayTest { - private static final DType I64 = new DType.Primitive(PType.I64, false); + private static final DType I64 = DType.I64; private static LazyZigZagLongArray of(long... encoded) { MemorySegment seg = Arena.ofAuto().allocate((long) encoded.length * 8, 8); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagShortArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagShortArrayTest.java index 8c9de8b0..649e1e0a 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagShortArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LazyZigZagShortArrayTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.encoding.PTypeIO; import org.junit.jupiter.api.Test; @@ -14,7 +13,7 @@ class LazyZigZagShortArrayTest { - private static final DType I16 = new DType.Primitive(PType.I16, false); + private static final DType I16 = DType.I16; private static LazyZigZagShortArray of(short... encoded) { MemorySegment seg = Arena.ofAuto().allocate((long) encoded.length * 2, 2); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/ListArraysTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/ListArraysTest.java index 94e899ab..8def088a 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/ListArraysTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/ListArraysTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -16,7 +15,7 @@ /// Covers the decoded list container arrays (variable-length and fixed-size). class ListArraysTest { - private static final DType ELEM = new DType.Primitive(PType.I32, false); + private static final DType ELEM = DType.I32; @Nested class VariableLength { diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LongArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LongArrayTest.java index a0cb5ec9..1dc57c7e 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/LongArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/LongArrayTest.java @@ -3,7 +3,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -68,7 +67,7 @@ void logicalLengthExceedsCapacity_wrapsAround() { // Given — constant-encoding: 1-element buffer, logical length 4; all 4 visits yield same value MemorySegment seg = Arena.ofAuto().allocate(8, 8); seg.setAtIndex(PTypeIO.LE_LONG, 0, 42L); - LongArray sut = new MaterializedLongArray(new DType.Primitive(PType.I64, false), 4, seg); + LongArray sut = new MaterializedLongArray(DType.I64, 4, seg); List collected = new ArrayList<>(); // When diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/OffsetArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/OffsetArrayTest.java index 0df9f50c..0a1809c4 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/OffsetArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/OffsetArrayTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.array; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -16,9 +15,9 @@ /// unsigned-widening `getInt` path, and fold reduction over the sliced range. class OffsetArrayTest { - private static final DType U8 = new DType.Primitive(PType.U8, false); - private static final DType U16 = new DType.Primitive(PType.U16, false); - private static final DType F32 = new DType.Primitive(PType.F32, false); + private static final DType U8 = DType.U8; + private static final DType U16 = DType.U16; + private static final DType F32 = DType.F32; @Nested class Byte { @@ -146,7 +145,7 @@ class Bool { void getBooleanShiftsByOffset() { // Given — bits [F, T, T, F] BoolArray inner = TestArrays.bools(false, true, true, false); - var sut = new OffsetBoolArray(new DType.Bool(false), 2, inner, 1L); + var sut = new OffsetBoolArray(DType.BOOL, 2, inner, 1L); // When / Then assertThat(sut.getBoolean(0)).isTrue(); // inner[1] @@ -161,7 +160,7 @@ class Int { void getIntShiftsByOffset() { // Given IntArray inner = TestArrays.ints(10, 20, 30, 40); - var sut = new OffsetIntArray(new DType.Primitive(PType.I32, false), 2, inner, 2L); + var sut = new OffsetIntArray(DType.I32, 2, inner, 2L); // When / Then assertThat(sut.getInt(0)).isEqualTo(30); @@ -175,7 +174,7 @@ class Long { void getLongShiftsByOffset() { // Given LongArray inner = TestArrays.longs(5L, 6L, 7L, 8L); - var sut = new OffsetLongArray(new DType.Primitive(PType.I64, false), 2, inner, 1L); + var sut = new OffsetLongArray(DType.I64, 2, inner, 1L); // When / Then assertThat(sut.getLong(0)).isEqualTo(6L); @@ -189,7 +188,7 @@ class Double { void getDoubleShiftsByOffset() { // Given DoubleArray inner = TestArrays.doubles(1.5, 2.5, 3.5); - var sut = new OffsetDoubleArray(new DType.Primitive(PType.F64, false), 2, inner, 1L); + var sut = new OffsetDoubleArray(DType.F64, 2, inner, 1L); // When / Then assertThat(sut.getDouble(0)).isEqualTo(2.5); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinArrayTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinArrayTest.java index 1a89f6e5..2de1acfb 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinArrayTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinArrayTest.java @@ -16,7 +16,7 @@ class VarBinArrayTest { - private static final DType UTF8 = new DType.Utf8(false); + private static final DType UTF8 = DType.UTF8; private static VarBinArray.OffsetMode of(String... values) { byte[] allBytes = String.join("", values).getBytes(StandardCharsets.UTF_8); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinChunkedModeTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinChunkedModeTest.java index c283917b..6b4369fb 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinChunkedModeTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinChunkedModeTest.java @@ -16,7 +16,7 @@ class VarBinChunkedModeTest { - private static final DType UTF8 = new DType.Utf8(false); + private static final DType UTF8 = DType.UTF8; @Nested class Construction { @@ -47,7 +47,7 @@ void nonVarBinChunkRejected() { MemorySegment seg = arena.allocate(8L); seg.setAtIndex(ValueLayout.JAVA_LONG, 0, 42L); LongArray notVarBin = new MaterializedLongArray( - new DType.Primitive(PType.I64, false), 1, seg.asReadOnly()); + DType.I64, 1, seg.asReadOnly()); // When / Then assertThatThrownBy(() -> VarBinArray.ChunkedMode.of(UTF8, 1, List.of(notVarBin))) diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinViewModeTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinViewModeTest.java index e3a6bf8a..fbe211d5 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinViewModeTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinViewModeTest.java @@ -17,7 +17,7 @@ /// referenced views into shared data buffers, length-only reads, and truncate. class VarBinViewModeTest { - private static final DType UTF8 = new DType.Utf8(false); + private static final DType UTF8 = DType.UTF8; private static final int VIEW_SIZE = 16; @Nested diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/AlpEncodingDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/AlpEncodingDecoderTest.java index 31636673..091cbe96 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/AlpEncodingDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/AlpEncodingDecoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.decode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.encoding.EncodingId; import io.github.dfa1.vortex.proto.ALPMetadata; import io.github.dfa1.vortex.proto.PatchesMetadata; @@ -24,8 +23,8 @@ class AlpEncodingDecoderTest { private static final AlpEncodingDecoder SUT = new AlpEncodingDecoder(); private static final ReadRegistry REGISTRY = TestRegistry.ofDecoders(SUT, new PrimitiveEncodingDecoder()); - private static final DType F64 = new DType.Primitive(PType.F64, false); - private static final DType F32 = new DType.Primitive(PType.F32, false); + private static final DType F64 = DType.F64; + private static final DType F32 = DType.F32; private static MemorySegment leLongs(long... vs) { byte[] b = new byte[vs.length * 8]; @@ -59,7 +58,7 @@ void decode_nonPrimitiveDtype_throws() { // Given a Utf8 dtype on an ALP node ArrayNode node = ArrayNode.of(EncodingId.VORTEX_ALP, ByteBuffer.wrap(new ALPMetadata(0, 0, null).encode()), new ArrayNode[0], new int[0]); - DecodeContext ctx = new DecodeContext(node, new DType.Utf8(false), 1, + DecodeContext ctx = new DecodeContext(node, DType.UTF8, 1, new MemorySegment[0], REGISTRY, Arena.ofAuto()); // When / Then diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/DateTimePartsEncodingDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/DateTimePartsEncodingDecoderTest.java index 928e9d2f..f39cd609 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/DateTimePartsEncodingDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/DateTimePartsEncodingDecoderTest.java @@ -113,7 +113,7 @@ void decode_nullableExtension_decodesNullableDaysChild() { void decode_extensionMissingTimeUnitMetadata_throws() { // Given an extension whose metadata byte is absent DType noUnit = new DType.Extension("vortex.timestamp", - new DType.Primitive(PType.I64, false), null, false); + DType.I64, null, false); DecodeContext c = ctx(i64Meta(), noUnit, 1, TestSegments.leLongs(0L), TestSegments.leLongs(0L), TestSegments.leLongs(0L)); @@ -124,7 +124,7 @@ void decode_extensionMissingTimeUnitMetadata_throws() { @Test void decode_nonExtensionDtype_throws() { // Given a primitive (non-extension) logical type - DecodeContext c = ctx(i64Meta(), new DType.Primitive(PType.I64, false), 1, + DecodeContext c = ctx(i64Meta(), DType.I64, 1, TestSegments.leLongs(0L), TestSegments.leLongs(0L), TestSegments.leLongs(0L)); // When / Then diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/DictEncodingDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/DictEncodingDecoderTest.java index 83256506..93925291 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/DictEncodingDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/DictEncodingDecoderTest.java @@ -82,7 +82,7 @@ void f64Values_roundTripThroughDoubleArray() { // Given — covers typedArray's F64 branch and the 8-byte expand path MemorySegment codes = u8Codes(0, 1, 0); MemorySegment values = TestSegments.leDoubles(1.5, -2.25); - DType dtype = new DType.Primitive(PType.F64, false); + DType dtype = DType.F64; // When DoubleArray result = (DoubleArray) decodeProtoSegments(dtype, PType.U8, codes, values, 2, 3); @@ -98,7 +98,7 @@ void f32Values_roundTripThroughFloatArray() { // Given — covers typedArray's F32 branch and the 4-byte expand path MemorySegment codes = u8Codes(1, 0); MemorySegment values = TestSegments.leFloats(3.5f, 4.75f); - DType dtype = new DType.Primitive(PType.F32, false); + DType dtype = DType.F32; // When FloatArray result = (FloatArray) decodeProtoSegments(dtype, PType.U8, codes, values, 2, 2); @@ -113,7 +113,7 @@ void unexpectedCodeType_throws() { // Given — proto declares an I64 code type, which decodeRustProto rejects MemorySegment codes = TestSegments.leLongs(0, 1); MemorySegment values = TestSegments.leLongs(5, 6); - DType dtype = new DType.Primitive(PType.I64, false); + DType dtype = DType.I64; // When / Then assertThatThrownBy(() -> decodeProtoSegments(dtype, PType.I64, codes, values, 2, 2)) @@ -126,7 +126,7 @@ void unsupportedValuePType_throws() { // Given — F16 expands fine (2 bytes) but typedArray has no F16 mapping MemorySegment codes = u8Codes(0, 1); MemorySegment values = TestSegments.leShorts((short) 1, (short) 2); - DType dtype = new DType.Primitive(PType.F16, false); + DType dtype = DType.F16; // When / Then assertThatThrownBy(() -> decodeProtoSegments(dtype, PType.U8, codes, values, 2, 2)) @@ -138,7 +138,7 @@ void unsupportedValuePType_throws() { void missingMetadata_throws() { // Given — primitive dict with no metadata ArrayNode node = ArrayNode.of(EncodingId.VORTEX_DICT, null, new ArrayNode[0], new int[]{}); - DecodeContext ctx = new DecodeContext(node, new DType.Primitive(PType.I32, false), + DecodeContext ctx = new DecodeContext(node, DType.I32, 1, new MemorySegment[0], REGISTRY, Arena.ofAuto()); // When / Then @@ -152,7 +152,7 @@ void emptyMetadata_throws() { // Given — metadata present but with zero remaining bytes (exercises !hasRemaining) ArrayNode node = ArrayNode.of(EncodingId.VORTEX_DICT, ByteBuffer.allocate(0), new ArrayNode[0], new int[]{}); - DecodeContext ctx = new DecodeContext(node, new DType.Primitive(PType.I32, false), + DecodeContext ctx = new DecodeContext(node, DType.I32, 1, new MemorySegment[0], REGISTRY, Arena.ofAuto()); // When / Then @@ -167,7 +167,7 @@ void malformedProtoMetadata_throws() { ByteBuffer meta = ByteBuffer.wrap(new byte[]{0x08, (byte) 0x80}); ArrayNode node = ArrayNode.of(EncodingId.VORTEX_DICT, meta, new ArrayNode[]{primitiveNode(0), primitiveNode(1)}, new int[]{}); - DecodeContext ctx = new DecodeContext(node, new DType.Primitive(PType.I32, false), + DecodeContext ctx = new DecodeContext(node, DType.I32, 1, new MemorySegment[]{u8Codes(0), TestSegments.leLongs(0)}, REGISTRY, Arena.ofAuto()); // When / Then @@ -189,7 +189,7 @@ void singleByteMetadata_decodesViaLegacyPath(PType codePType) { MemorySegment codes = codeSegment(codePType, new long[]{2, 0, 1, 2}); // When - Array result = decodeLegacy(new DType.Primitive(PType.I64, false), codePType, values, codes, 4); + Array result = decodeLegacy(DType.I64, codePType, values, codes, 4); // Then assertLongValues(result, PType.I64, new long[]{300, 100, 200, 300}); @@ -203,7 +203,7 @@ void nonStandardCodeType_throws() { // When / Then assertThatThrownBy(() -> - decodeLegacy(new DType.Primitive(PType.I64, false), PType.I8, values, codes, 2)) + decodeLegacy(DType.I64, PType.I8, values, codes, 2)) .isInstanceOf(VortexException.class) .hasMessageContaining("unexpected code type"); } @@ -300,7 +300,7 @@ void legacyLayout_decodesStringsByCode() { ByteBuffer meta = ByteBuffer.wrap(new byte[]{(byte) PType.U8.ordinal()}); ArrayNode node = ArrayNode.of(EncodingId.VORTEX_DICT, meta, new ArrayNode[0], new int[]{0, 1, 2}); - DecodeContext ctx = new DecodeContext(node, new DType.Utf8(false), 3, + DecodeContext ctx = new DecodeContext(node, DType.UTF8, 3, new MemorySegment[]{bytes, offsets, codes}, REGISTRY, Arena.ofAuto()); // When @@ -332,7 +332,7 @@ void protoLayout_decodesStringsByCode() { ArrayNode dictNode = ArrayNode.of(EncodingId.VORTEX_DICT, dictMeta, new ArrayNode[]{codesNode, valuesNode}, new int[]{}); - DecodeContext ctx = new DecodeContext(dictNode, new DType.Utf8(false), 3, + DecodeContext ctx = new DecodeContext(dictNode, DType.UTF8, 3, segs, REGISTRY, Arena.ofAuto()); // When @@ -348,7 +348,7 @@ void protoLayout_decodesStringsByCode() { void legacyLayout_missingMetadata_throws() { // Given — no children and no metadata ArrayNode node = ArrayNode.of(EncodingId.VORTEX_DICT, null, new ArrayNode[0], new int[]{}); - DecodeContext ctx = new DecodeContext(node, new DType.Utf8(false), 0, + DecodeContext ctx = new DecodeContext(node, DType.UTF8, 0, new MemorySegment[0], REGISTRY, Arena.ofAuto()); // When / Then @@ -364,7 +364,7 @@ void protoLayout_malformedMetadata_throws() { ArrayNode child = primitiveNode(0); ArrayNode node = ArrayNode.of(EncodingId.VORTEX_DICT, meta, new ArrayNode[]{child, child}, new int[]{}); - DecodeContext ctx = new DecodeContext(node, new DType.Utf8(false), 1, + DecodeContext ctx = new DecodeContext(node, DType.UTF8, 1, new MemorySegment[]{u8Codes(0)}, REGISTRY, Arena.ofAuto()); // When / Then @@ -378,7 +378,7 @@ void protoLayout_missingMetadata_throws() { // Given — children present but metadata absent ArrayNode child = primitiveNode(0); ArrayNode node = ArrayNode.of(EncodingId.VORTEX_DICT, null, new ArrayNode[]{child, child}, new int[]{}); - DecodeContext ctx = new DecodeContext(node, new DType.Utf8(false), 1, + DecodeContext ctx = new DecodeContext(node, DType.UTF8, 1, new MemorySegment[]{u8Codes(0)}, REGISTRY, Arena.ofAuto()); // When / Then @@ -392,7 +392,7 @@ void legacyLayout_emptyMetadata_throws() { // Given — no children and zero-remaining metadata (exercises !hasRemaining) ArrayNode node = ArrayNode.of(EncodingId.VORTEX_DICT, ByteBuffer.allocate(0), new ArrayNode[0], new int[]{}); - DecodeContext ctx = new DecodeContext(node, new DType.Utf8(false), 0, + DecodeContext ctx = new DecodeContext(node, DType.UTF8, 0, new MemorySegment[0], REGISTRY, Arena.ofAuto()); // When / Then @@ -407,7 +407,7 @@ void protoLayout_emptyMetadata_throws() { ArrayNode child = primitiveNode(0); ArrayNode node = ArrayNode.of(EncodingId.VORTEX_DICT, ByteBuffer.allocate(0), new ArrayNode[]{child, child}, new int[]{}); - DecodeContext ctx = new DecodeContext(node, new DType.Utf8(false), 1, + DecodeContext ctx = new DecodeContext(node, DType.UTF8, 1, new MemorySegment[]{u8Codes(0)}, REGISTRY, Arena.ofAuto()); // When / Then diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PatchedEncodingDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PatchedEncodingDecoderTest.java index c47d1d5a..2edf70fa 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PatchedEncodingDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PatchedEncodingDecoderTest.java @@ -4,7 +4,6 @@ import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.reader.array.IntArray; import io.github.dfa1.vortex.reader.array.LongArray; @@ -35,7 +34,7 @@ private static ByteBuffer patchedMeta(int nPatches, int nLanes, int offset) { private static Array decode(int n, int[] innerI32, int[] laneOffsets, short[] patchIndices, int[] patchValues) { - return decode(new DType.Primitive(PType.I32, false), n, + return decode(DType.I32, n, TestSegments.leInts(innerI32), TestSegments.leInts(laneOffsets), TestSegments.leShorts(patchIndices), TestSegments.leInts(patchValues), laneOffsets.length - 1); @@ -124,7 +123,7 @@ void decode_variousLengths_noPatches(int n) { @Test void decode_i64_singlePatch() { // Given - DType dtype = new DType.Primitive(PType.I64, false); + DType dtype = DType.I64; // When Array result = decode(dtype, 3, TestSegments.leLongs(100L, 200L, 300L), TestSegments.leInts(0, 1), @@ -145,7 +144,7 @@ void decode_missingMetadata_throws() { ArrayNode patchedNode = ArrayNode.of(EncodingId.VORTEX_PATCHED, null, new ArrayNode[]{innerNode, innerNode, innerNode, innerNode}, new int[]{}); MemorySegment seg = TestSegments.leInts(1, 2, 3); - DecodeContext ctx = new DecodeContext(patchedNode, new DType.Primitive(PType.I32, false), 3, + DecodeContext ctx = new DecodeContext(patchedNode, DType.I32, 3, new MemorySegment[]{seg}, ReadRegistry.empty(), Arena.ofAuto()); // When / Then diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoderTest.java index c6af3e7a..3dd07564 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoderTest.java @@ -170,7 +170,7 @@ class Decode { @Test void decode_nullMetadata_throwsMissingMeta() { - DecodeContext ctx = ctxWith(null, new DType.Primitive(PType.I64, false), 0, new MemorySegment[0]); + DecodeContext ctx = ctxWith(null, DType.I64, 0, new MemorySegment[0]); assertThatThrownBy(() -> SUT.decode(ctx)) .isInstanceOf(VortexException.class) .hasMessageContaining("missing PcoMetadata"); @@ -180,7 +180,7 @@ void decode_nullMetadata_throwsMissingMeta() { void decode_invalidHeaderVersion_throwsUnsupported() { PcoMetadata meta = new PcoMetadata(new byte[]{0x03, 0x00}, java.util.List.of()); DecodeContext ctx = ctxWith(ByteBuffer.wrap(meta.encode()), - new DType.Primitive(PType.I64, false), 0, new MemorySegment[0]); + DType.I64, 0, new MemorySegment[0]); assertThatThrownBy(() -> SUT.decode(ctx)) .isInstanceOf(VortexException.class) .hasMessageContaining("unsupported pco format version 03.00"); @@ -188,7 +188,7 @@ void decode_invalidHeaderVersion_throwsUnsupported() { @Test void decode_nonPrimitiveDtype_throws() { - DecodeContext ctx = ctxWith(validMetaBuffer(), new DType.Utf8(false), 0, new MemorySegment[0]); + DecodeContext ctx = ctxWith(validMetaBuffer(), DType.UTF8, 0, new MemorySegment[0]); assertThatThrownBy(() -> SUT.decode(ctx)) .isInstanceOf(VortexException.class) .hasMessageContaining("Primitive dtype"); @@ -196,7 +196,7 @@ void decode_nonPrimitiveDtype_throws() { @Test void decode_unsupportedPtype_throws() { - DecodeContext ctx = ctxWith(validMetaBuffer(), new DType.Primitive(PType.F16, false), 0, + DecodeContext ctx = ctxWith(validMetaBuffer(), DType.F16, 0, new MemorySegment[0]); assertThatThrownBy(() -> SUT.decode(ctx)) .isInstanceOf(VortexException.class) @@ -213,7 +213,7 @@ void decode_zeroChunks_returnsEmptyArray(PType ptype) { @Test void decode_consecutiveDelta_order1_singleValue_decodes() { - DecodeContext ctx = ctxWith(metaWithOneChunk(1), new DType.Primitive(PType.U64, false), 1, + DecodeContext ctx = ctxWith(metaWithOneChunk(1), DType.U64, 1, new MemorySegment[]{chunkMetaConsecutive(1), pageWithMoments(42L)}); var result = SUT.decode(ctx); assertThat(result.length()).isEqualTo(1); @@ -222,7 +222,7 @@ void decode_consecutiveDelta_order1_singleValue_decodes() { @Test void decode_consecutiveDelta_order2_twoValues_decodes() { - DecodeContext ctx = ctxWith(metaWithOneChunk(2), new DType.Primitive(PType.U64, false), 2, + DecodeContext ctx = ctxWith(metaWithOneChunk(2), DType.U64, 2, new MemorySegment[]{chunkMetaConsecutive(2), pageWithMoments(10L, 7L)}); var result = SUT.decode(ctx); assertThat(result.length()).isEqualTo(2); @@ -235,7 +235,7 @@ void decode_multiPage_singleChunk_decodes() { PcoMetadata meta = new PcoMetadata( new byte[]{PcoEncodingDecoder.PCO_FORMAT_MAJOR, PcoEncodingDecoder.PCO_FORMAT_MINOR}, java.util.List.of(new PcoChunkInfo(java.util.List.of(new PcoPageInfo(1), new PcoPageInfo(1))))); - DecodeContext ctx = ctxWith(ByteBuffer.wrap(meta.encode()), new DType.Primitive(PType.U64, false), 2, + DecodeContext ctx = ctxWith(ByteBuffer.wrap(meta.encode()), DType.U64, 2, new MemorySegment[]{chunkMetaConsecutive(1), pageWithMoments(10L), pageWithMoments(20L)}); var result = SUT.decode(ctx); assertThat(result.length()).isEqualTo(2); @@ -251,7 +251,7 @@ void decode_multiChunk_decodes() { java.util.List.of( new PcoChunkInfo(java.util.List.of(new PcoPageInfo(1))), new PcoChunkInfo(java.util.List.of(new PcoPageInfo(1))))); - DecodeContext ctx = ctxWith(ByteBuffer.wrap(meta.encode()), new DType.Primitive(PType.U64, false), 2, + DecodeContext ctx = ctxWith(ByteBuffer.wrap(meta.encode()), DType.U64, 2, new MemorySegment[]{chunkMetaConsecutive(1), chunkMetaConsecutive(1), pageWithMoments(100L), pageWithMoments(200L)}); var result = SUT.decode(ctx); @@ -324,7 +324,7 @@ void decode_conv1_order1_zeroPrediction_statePassedThrough() { long weightLatent = 0x80000000L; MemorySegment chunkMeta = chunkMetaConv1(0, biasLatent, 1, new long[]{weightLatent}); MemorySegment page = segmentOf((byte) 0x05, (byte) 0x00, (byte) 0x00, (byte) 0x80); - DecodeContext ctx = ctxWith(metaWithOneChunk(2), new DType.Primitive(PType.I32, false), 2, + DecodeContext ctx = ctxWith(metaWithOneChunk(2), DType.I32, 2, new MemorySegment[]{chunkMeta, page}); var result = SUT.decode(ctx); @@ -339,7 +339,7 @@ class DecodeLookback { @Test void decode_lookback_corruptIndexZero_throwsVortexException() { - DecodeContext ctx = ctxWith(metaWithOneChunk(2), new DType.Primitive(PType.U64, false), 2, + DecodeContext ctx = ctxWith(metaWithOneChunk(2), DType.U64, 2, new MemorySegment[]{chunkMetaLookback(), lookbackPage(0L)}); assertThatThrownBy(() -> SUT.decode(ctx)) .isInstanceOf(VortexException.class) @@ -350,7 +350,7 @@ void decode_lookback_corruptIndexZero_throwsVortexException() { void decode_lookback_stateNExceedsPageN_throwsVortexException() { MemorySegment chunkMeta = segmentOf( (byte) 0x20, (byte) 0x20, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00); - DecodeContext ctx = ctxWith(metaWithOneChunk(1), new DType.Primitive(PType.U64, false), 1, + DecodeContext ctx = ctxWith(metaWithOneChunk(1), DType.U64, 1, new MemorySegment[]{chunkMeta, segmentOf((byte) 0x00)}); assertThatThrownBy(() -> SUT.decode(ctx)) .isInstanceOf(VortexException.class) @@ -359,7 +359,7 @@ void decode_lookback_stateNExceedsPageN_throwsVortexException() { @Test void decode_lookback_singleInitialValue_returnsIt() { - DecodeContext ctx = ctxWith(metaWithOneChunk(1), new DType.Primitive(PType.U64, false), 1, + DecodeContext ctx = ctxWith(metaWithOneChunk(1), DType.U64, 1, new MemorySegment[]{chunkMetaLookback(), lookbackPage(42L)}); var result = SUT.decode(ctx); assertThat(result.length()).isEqualTo(1); @@ -372,7 +372,7 @@ class DecodeLookbackDecodeN { @Test void lookback_decodeNExceedsMax_throwsVortexException() { int pageN = (1 << 23) + 2; - DecodeContext ctx = ctxWith(metaWithOneChunk(pageN), new DType.Primitive(PType.U64, false), pageN, + DecodeContext ctx = ctxWith(metaWithOneChunk(pageN), DType.U64, pageN, new MemorySegment[]{chunkMetaLookback(), segmentOf(new byte[8])}); assertThatThrownBy(() -> SUT.decode(ctx)) .isInstanceOf(VortexException.class) @@ -387,7 +387,7 @@ void lookback_stateNExceedsWindowN_throwsVortexException() { MemorySegment chunkMeta = segmentOf( (byte) 0x20, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00); MemorySegment page = segmentOf(new byte[32]); - DecodeContext ctx = ctxWith(metaWithOneChunk(4), new DType.Primitive(PType.U64, false), 4, + DecodeContext ctx = ctxWith(metaWithOneChunk(4), DType.U64, 4, new MemorySegment[]{chunkMeta, page}); assertThatThrownBy(() -> SUT.decode(ctx)) .isInstanceOf(VortexException.class) @@ -401,7 +401,7 @@ class DecodeLookbackWindowNLog { void lookback_windowNLogExceedsMax_throwsVortexException() { MemorySegment chunkMeta = segmentOf( (byte) 0x20, (byte) 0x18, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00); - DecodeContext ctx = ctxWith(metaWithOneChunk(1), new DType.Primitive(PType.U64, false), 1, + DecodeContext ctx = ctxWith(metaWithOneChunk(1), DType.U64, 1, new MemorySegment[]{chunkMeta, segmentOf((byte) 0x00)}); assertThatThrownBy(() -> SUT.decode(ctx)) .isInstanceOf(VortexException.class) @@ -414,7 +414,7 @@ class DecodeDict { @Test void dict_nUniqueExceedsMax_throwsVortexException() { MemorySegment chunkMeta = segmentOf((byte) 0x14, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00); - DecodeContext ctx = ctxWith(metaWithOneChunk(1), new DType.Primitive(PType.U64, false), 1, + DecodeContext ctx = ctxWith(metaWithOneChunk(1), DType.U64, 1, new MemorySegment[]{chunkMeta, segmentOf((byte) 0x00)}); assertThatThrownBy(() -> SUT.decode(ctx)) .isInstanceOf(VortexException.class) @@ -446,7 +446,7 @@ static Stream pageBytesProvider() { @ParameterizedTest @MethodSource("chunkMetaBytesProvider") void randomChunkMetaBytes_neverThrowsJvmException(byte[] chunkMetaBytes) { - DecodeContext ctx = ctxWith(metaWithOneChunk(1), new DType.Primitive(PType.U64, false), 1, + DecodeContext ctx = ctxWith(metaWithOneChunk(1), DType.U64, 1, new MemorySegment[]{segmentOf(chunkMetaBytes), segmentOf((byte) 0x00)}); // VortexException is acceptable; NPE/AIOOBE/etc. are not assertThatCode(() -> { @@ -460,7 +460,7 @@ void randomChunkMetaBytes_neverThrowsJvmException(byte[] chunkMetaBytes) { @ParameterizedTest @MethodSource("pageBytesProvider") void randomPageBytes_classicMode_neverThrowsJvmException(byte[] pageBytes) { - DecodeContext ctx = ctxWith(metaWithOneChunk(1), new DType.Primitive(PType.U64, false), 1, + DecodeContext ctx = ctxWith(metaWithOneChunk(1), DType.U64, 1, new MemorySegment[]{segmentOf((byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00), segmentOf(pageBytes)}); // VortexException is acceptable; NPE/AIOOBE/etc. are not @@ -476,7 +476,7 @@ void randomPageBytes_classicMode_neverThrowsJvmException(byte[] pageBytes) { @ValueSource(ints = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}) void invalidModeNibble_throwsVortexException(int modeNibble) { byte modeByte = (byte) (modeNibble & 0x0F); - DecodeContext ctx = ctxWith(metaWithOneChunk(1), new DType.Primitive(PType.U64, false), 1, + DecodeContext ctx = ctxWith(metaWithOneChunk(1), DType.U64, 1, new MemorySegment[]{segmentOf(modeByte, (byte) 0x00, (byte) 0x00, (byte) 0x00), segmentOf((byte) 0x00)}); assertThatThrownBy(() -> SUT.decode(ctx)) @@ -488,7 +488,7 @@ void invalidModeNibble_throwsVortexException(int modeNibble) { @ValueSource(ints = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}) void invalidDeltaVariant_throwsVortexException(int deltaVariant) { byte modeDeltaByte = (byte) ((deltaVariant & 0x0F) << 4); - DecodeContext ctx = ctxWith(metaWithOneChunk(1), new DType.Primitive(PType.U64, false), 1, + DecodeContext ctx = ctxWith(metaWithOneChunk(1), DType.U64, 1, new MemorySegment[]{segmentOf(modeDeltaByte, (byte) 0x00, (byte) 0x00, (byte) 0x00), segmentOf((byte) 0x00)}); assertThatThrownBy(() -> SUT.decode(ctx)) diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VarBinEncodingDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VarBinEncodingDecoderTest.java index 3b72e57b..1dbf10ce 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VarBinEncodingDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VarBinEncodingDecoderTest.java @@ -29,7 +29,7 @@ private static DecodeContext ctx(ByteBuffer meta, MemorySegment bytes, MemorySeg // children[0] = offsets (primitive, segment index 1); bufferIndices[0] -> bytes (index 0) ArrayNode offsetsNode = ArrayNode.of(EncodingId.VORTEX_PRIMITIVE, null, new ArrayNode[0], new int[]{1}); ArrayNode varbinNode = ArrayNode.of(EncodingId.VORTEX_VARBIN, meta, new ArrayNode[]{offsetsNode}, new int[]{0}); - return new DecodeContext(varbinNode, new DType.Utf8(false), n, + return new DecodeContext(varbinNode, DType.UTF8, n, new MemorySegment[]{bytes, offsets}, REGISTRY, Arena.ofAuto()); } diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VarBinViewEncodingDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VarBinViewEncodingDecoderTest.java index 41ffb80d..2cf9b37d 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VarBinViewEncodingDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VarBinViewEncodingDecoderTest.java @@ -37,7 +37,7 @@ void decode_binaryDtype_inlineViews() { writeInlineView(views, 1, b); ArrayNode node = ArrayNode.of(EncodingId.VORTEX_VARBINVIEW, null, new ArrayNode[0], new int[]{0}); - DecodeContext ctx = new DecodeContext(node, new DType.Binary(false), 2, + DecodeContext ctx = new DecodeContext(node, DType.BINARY, 2, new MemorySegment[]{views}, ReadRegistry.empty(), arena); // When @@ -66,7 +66,7 @@ void decode_wrongDtype_throws() { void decode_noBuffers_throws() { // Given a node with zero buffer indices ArrayNode node = ArrayNode.of(EncodingId.VORTEX_VARBINVIEW, null, new ArrayNode[0], new int[0]); - DecodeContext ctx = new DecodeContext(node, new DType.Utf8(false), 0, + DecodeContext ctx = new DecodeContext(node, DType.UTF8, 0, new MemorySegment[0], ReadRegistry.empty(), Arena.ofAuto()); // When / Then diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VariantEncodingDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VariantEncodingDecoderTest.java index 841d1d19..8dce5eed 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VariantEncodingDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/VariantEncodingDecoderTest.java @@ -4,7 +4,6 @@ import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.reader.array.NullArray; import io.github.dfa1.vortex.reader.array.VariantArray; @@ -25,7 +24,7 @@ class VariantEncodingDecoderTest { - private static final DType VARIANT_DTYPE = new DType.Variant(false); + private static final DType VARIANT_DTYPE = DType.VARIANT; private static final int N = 3; private static final VariantEncodingDecoder SUT = new VariantEncodingDecoder(); @@ -90,7 +89,7 @@ void decode_withShredded_decodesSecondChild() { assertThat(result).isInstanceOf(VariantArray.class); VariantArray va = (VariantArray) result; assertThat(va.shredded()).isNotNull(); - assertThat(va.shredded().dtype()).isEqualTo(new DType.Primitive(PType.I32, false)); + assertThat(va.shredded().dtype()).isEqualTo(DType.I32); assertThat(va.shredded().length()).isEqualTo(N); } @@ -183,7 +182,7 @@ void primitive() { DType result = VariantEncodingDecoder.dtypeFromProto(prim(io.github.dfa1.vortex.proto.PType.I64, false)); // Then - assertThat(result).isEqualTo(new DType.Primitive(PType.I64, false)); + assertThat(result).isEqualTo(DType.I64); } @Test @@ -213,7 +212,7 @@ void binary() { io.github.dfa1.vortex.proto.DType.ofBinary(new io.github.dfa1.vortex.proto.Binary(false))); // Then - assertThat(result).isEqualTo(new DType.Binary(false)); + assertThat(result).isEqualTo(DType.BINARY); } @Test @@ -231,7 +230,7 @@ void struct() { // Then assertThat(result).isEqualTo(new DType.Struct( List.of("a", "b"), - List.of(new DType.Primitive(PType.I32, false), new DType.Utf8(true)), + List.of(DType.I32, new DType.Utf8(true)), false)); } @@ -243,7 +242,7 @@ void list() { prim(io.github.dfa1.vortex.proto.PType.I32, false), true))); // Then - assertThat(result).isEqualTo(new DType.List(new DType.Primitive(PType.I32, false), true)); + assertThat(result).isEqualTo(new DType.List(DType.I32, true)); } @Test @@ -255,7 +254,7 @@ void fixedSizeList() { // Then size is carried through assertThat(result).isEqualTo( - new DType.FixedSizeList(new DType.Primitive(PType.F64, false), 4, false)); + new DType.FixedSizeList(DType.F64, 4, false)); } @Test @@ -271,7 +270,7 @@ void extension_withMetadata() { assertThat(result).isInstanceOf(DType.Extension.class); DType.Extension ext = (DType.Extension) result; assertThat(ext.extensionId()).isEqualTo("ip.address"); - assertThat(ext.storageDType()).isEqualTo(new DType.Primitive(PType.I32, false)); + assertThat(ext.storageDType()).isEqualTo(DType.I32); assertThat(ext.metadata().remaining()).isEqualTo(3); } @@ -295,7 +294,7 @@ void variant() { io.github.dfa1.vortex.proto.DType.ofVariant(new io.github.dfa1.vortex.proto.Variant(false))); // Then - assertThat(result).isEqualTo(new DType.Variant(false)); + assertThat(result).isEqualTo(DType.VARIANT); } @Test diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/ZigZagEncodingDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/ZigZagEncodingDecoderTest.java index 367f98d5..5f305ff2 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/ZigZagEncodingDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/ZigZagEncodingDecoderTest.java @@ -203,7 +203,7 @@ void decode_i64_broadcastsSingleValue() { void decode_nonPrimitiveDtype_throws() { // Given a non-primitive logical type on the context ArrayNode node = ArrayNode.of(EncodingId.VORTEX_ZIGZAG, null, new ArrayNode[0], new int[]{}); - DecodeContext ctx = new DecodeContext(node, new DType.Bool(false), 1, + DecodeContext ctx = new DecodeContext(node, DType.BOOL, 1, new MemorySegment[0], REGISTRY, Arena.ofAuto()); // When / Then diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/DateExtensionDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/DateExtensionDecoderTest.java index 33a5c058..10eb27a6 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/DateExtensionDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/DateExtensionDecoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.extension; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.extension.ExtensionId; import io.github.dfa1.vortex.reader.array.BoolArray; import io.github.dfa1.vortex.reader.array.IntArray; @@ -39,7 +38,7 @@ void dtype_isI32StorageWithDaysMetadata() { // Then assertThat(dtype.extensionId()).isEqualTo("vortex.date"); - assertThat(dtype.storageDType()).isEqualTo(new DType.Primitive(PType.I32, false)); + assertThat(dtype.storageDType()).isEqualTo(DType.I32); assertThat(dtype.metadata()).isNotNull(); assertThat(dtype.metadata().remaining()).isEqualTo(1); assertThat(dtype.metadata().duplicate().get()).isEqualTo((byte) 4); // TimeUnit.Days ordinal @@ -84,7 +83,7 @@ void decodeAll_maskedArray_yieldsNullAtInvalidPositions() { IntArray inner = new MaterializedIntArray(I32, 3, buf); MemorySegment validityBuf = arena.allocate(1); validityBuf.set(ValueLayout.JAVA_BYTE, 0, (byte) 0b0000_0101); - BoolArray validity = new MaterializedBoolArray(new DType.Bool(false), 3, validityBuf); + BoolArray validity = new MaterializedBoolArray(DType.BOOL, 3, validityBuf); // When List out = sut.decodeAll(new MaskedArray(inner, validity)); diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/ExtensionStorageTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/ExtensionStorageTest.java index b7dc6516..623a1137 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/ExtensionStorageTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/ExtensionStorageTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.extension; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.encoding.TimeUnit; import io.github.dfa1.vortex.reader.array.DoubleArray; @@ -90,7 +89,7 @@ void emptyMetadata_throws() { } private DType.Extension ext(ByteBuffer meta) { - return new DType.Extension("vortex.timestamp", new DType.Primitive(PType.I64, false), meta, false); + return new DType.Extension("vortex.timestamp", DType.I64, meta, false); } } diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/ExtensionTestSupport.java b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/ExtensionTestSupport.java index 3a368bc7..1acbaed7 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/ExtensionTestSupport.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/ExtensionTestSupport.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.extension; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.IntArray; import io.github.dfa1.vortex.reader.array.LongArray; import io.github.dfa1.vortex.reader.array.MaterializedIntArray; @@ -17,9 +16,9 @@ /// Shared fixtures for the per-extension decoder test classes. final class ExtensionTestSupport { - static final DType.Primitive I32 = new DType.Primitive(PType.I32, false); - static final DType.Primitive I64 = new DType.Primitive(PType.I64, false); - static final DType.Primitive U8 = new DType.Primitive(PType.U8, false); + static final DType.Primitive I32 = DType.I32; + static final DType.Primitive I64 = DType.I64; + static final DType.Primitive U8 = DType.U8; private ExtensionTestSupport() { } diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/TimeExtensionDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/TimeExtensionDecoderTest.java index 0a68521d..11b4af13 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/TimeExtensionDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/TimeExtensionDecoderTest.java @@ -54,7 +54,7 @@ void dtype_nanosecondsForceI64() { DType.Extension dtype = sut.dtype(TimeUnit.Nanoseconds, false); // Then - assertThat(dtype.storageDType()).isEqualTo(new DType.Primitive(PType.I64, false)); + assertThat(dtype.storageDType()).isEqualTo(DType.I64); assertThat(dtype.metadata().get(0)).isEqualTo((byte) TimeUnit.Nanoseconds.ordinal()); } @@ -105,7 +105,7 @@ void decodeAll_maskedArray_yieldsNullAtInvalidPositions() { IntArray inner = new MaterializedIntArray(I32, 2, buf); MemorySegment validityBuf = arena.allocate(1); validityBuf.set(ValueLayout.JAVA_BYTE, 0, (byte) 0b0000_0001); - BoolArray validity = new MaterializedBoolArray(new DType.Bool(false), 2, validityBuf); + BoolArray validity = new MaterializedBoolArray(DType.BOOL, 2, validityBuf); // When List out = sut.decodeAll( diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/TimestampExtensionDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/TimestampExtensionDecoderTest.java index 77a197e8..604d7561 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/TimestampExtensionDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/TimestampExtensionDecoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.extension; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.encoding.TimeUnit; import io.github.dfa1.vortex.extension.ExtensionId; @@ -47,7 +46,7 @@ void dtype_defaultIsMsUtcless() { DType.Extension dtype = sut.dtype(false); // Then — byte 0 = ms ordinal, bytes 1..3 = 0 (tz_len = 0) - assertThat(dtype.storageDType()).isEqualTo(new DType.Primitive(PType.I64, false)); + assertThat(dtype.storageDType()).isEqualTo(DType.I64); assertThat(dtype.metadata().get(0)).isEqualTo((byte) TimeUnit.Milliseconds.ordinal()); assertThat(dtype.metadata().getShort(1)).isEqualTo((short) 0); } @@ -136,7 +135,7 @@ void decodeAll_maskedArray_yieldsNullAtInvalidPositions() { LongArray inner = new MaterializedLongArray(I64, 2, buf); MemorySegment validityBuf = arena.allocate(1); validityBuf.set(ValueLayout.JAVA_BYTE, 0, (byte) 0b0000_0001); - BoolArray validity = new MaterializedBoolArray(new DType.Bool(false), 2, validityBuf); + BoolArray validity = new MaterializedBoolArray(DType.BOOL, 2, validityBuf); DType.Extension dtype = sut.dtype(true); // When diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/UuidExtensionDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/UuidExtensionDecoderTest.java index 1cedb38d..9565f60a 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/extension/UuidExtensionDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/extension/UuidExtensionDecoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.reader.extension; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.extension.ExtensionId; import io.github.dfa1.vortex.reader.array.BoolArray; @@ -40,7 +39,7 @@ void dtype_isFixedSizeListOf16U8() { DType.Extension dtype = sut.dtype(true); // Then - DType.Primitive u8 = new DType.Primitive(PType.U8, false); + DType.Primitive u8 = DType.U8; assertThat(dtype.storageDType()).isEqualTo(new DType.FixedSizeList(u8, 16, true)); assertThat(dtype.metadata()).isNotNull(); assertThat(dtype.metadata().remaining()).isZero(); @@ -106,7 +105,7 @@ void decodeAll_maskedArray_yieldsNullAtInvalidPositions() { new DType.FixedSizeList(U8, 16, false), 2, innerBytes); MemorySegment validityBuf = arena.allocate(1); validityBuf.set(ValueLayout.JAVA_BYTE, 0, (byte) 0b0000_0001); - BoolArray validity = new MaterializedBoolArray(new DType.Bool(false), 2, validityBuf); + BoolArray validity = new MaterializedBoolArray(DType.BOOL, 2, validityBuf); // When List out = sut.decodeAll(new MaskedArray(innerFsl, validity)); diff --git a/writer/src/main/java/io/github/dfa1/vortex/writer/VortexWriter.java b/writer/src/main/java/io/github/dfa1/vortex/writer/VortexWriter.java index ae42c75f..c6df743b 100644 --- a/writer/src/main/java/io/github/dfa1/vortex/writer/VortexWriter.java +++ b/writer/src/main/java/io/github/dfa1/vortex/writer/VortexWriter.java @@ -65,8 +65,8 @@ /// Usage: /// ```java /// var schema = new DType.Struct(List.of("id", "value"), -/// List.of(new DType.Primitive(PType.I64, false), -/// new DType.Primitive(PType.F64, false)), false); +/// List.of(DType.I64, +/// DType.F64), false); /// try (var channel = FileChannel.open(path, CREATE, WRITE); /// var writer = VortexWriter.create(channel, schema, WriteOptions.defaults())) { /// writer.writeChunk(Map.of("id", idArray, "value", valueArray)); @@ -760,13 +760,13 @@ private void emitZoneMap(String colName, DType minMaxDtype, List minByte types.add(minMaxDtype); fields.add(new NullableData(zoneStatValues(minMaxDtype, maxBytes), allValid.clone())); names.add("max_is_truncated"); - types.add(new DType.Bool(false)); + types.add(DType.BOOL); fields.add(notTruncated); names.add("min"); types.add(minMaxDtype); fields.add(new NullableData(zoneStatValues(minMaxDtype, minBytes), allValid.clone())); names.add("min_is_truncated"); - types.add(new DType.Bool(false)); + types.add(DType.BOOL); fields.add(notTruncated.clone()); } if (sumDtype != null) { diff --git a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/AlpEncodingEncoder.java b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/AlpEncodingEncoder.java index 61b465d4..41b90dc5 100644 --- a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/AlpEncodingEncoder.java +++ b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/AlpEncodingEncoder.java @@ -19,8 +19,6 @@ public final class AlpEncodingEncoder implements EncodingEncoder { private static final double[] IF10_F64 = {1e-0, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8, 1e-9, 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15, 1e-16, 1e-17, 1e-18, 1e-19, 1e-20, 1e-21, 1e-22, 1e-23}; private static final float[] F10_F32 = {1e0f, 1e1f, 1e2f, 1e3f, 1e4f, 1e5f, 1e6f, 1e7f, 1e8f, 1e9f, 1e10f}; private static final float[] IF10_F32 = {1e-0f, 1e-1f, 1e-2f, 1e-3f, 1e-4f, 1e-5f, 1e-6f, 1e-7f, 1e-8f, 1e-9f, 1e-10f}; - private static final DType I64_DTYPE = new DType.Primitive(PType.I64, false); - private static final DType I32_DTYPE = new DType.Primitive(PType.I32, false); private static final int MAX_EXPONENT_F64 = 18; private static final int MAX_EXPONENT_F32 = 10; @@ -237,7 +235,7 @@ private static CascadeStep encodeCascadeF64(double[] values, EncodeContext ctx) byte[] metaBytes = new ALPMetadata(d.expE(), d.expF(), null).encode(); EncodeNode partialRoot = new EncodeNode(EncodingId.VORTEX_ALP, ByteBuffer.wrap(metaBytes), new EncodeNode[1], new int[0]); - ChildSlot slot = new ChildSlot(I64_DTYPE, d.encodedArr(), 0); + ChildSlot slot = new ChildSlot(DType.I64, d.encodedArr(), 0); return new CascadeStep(partialRoot, List.of(), List.of(slot), d.statsMin(), d.statsMax(), true); } @@ -256,7 +254,7 @@ private static CascadeStep encodeCascadeF64(double[] values, EncodeContext ctx) EncodeNode valNode = EncodeNode.leaf(EncodingId.VORTEX_PRIMITIVE, 1); EncodeNode partialRoot = new EncodeNode(EncodingId.VORTEX_ALP, ByteBuffer.wrap(metaBytes), new EncodeNode[]{null, idxNode, valNode}, new int[0]); - ChildSlot slot = new ChildSlot(I64_DTYPE, d.encodedArr(), 0); + ChildSlot slot = new ChildSlot(DType.I64, d.encodedArr(), 0); return new CascadeStep(partialRoot, List.of(idxBuf, valBuf), List.of(slot), d.statsMin(), d.statsMax(), true); } diff --git a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/AlpRdEncodingEncoder.java b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/AlpRdEncodingEncoder.java index 9c83dc8c..49145721 100644 --- a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/AlpRdEncodingEncoder.java +++ b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/AlpRdEncodingEncoder.java @@ -15,9 +15,6 @@ /// Write-only encoder for `vortex.alprd`. public final class AlpRdEncodingEncoder implements EncodingEncoder { - private static final DType U16_DTYPE = new DType.Primitive(PType.U16, false); - private static final DType U32_DTYPE = new DType.Primitive(PType.U32, false); - private static final DType U64_DTYPE = new DType.Primitive(PType.U64, false); private static final int SAMPLE_SIZE = 512; private static final int MAX_CUT = 16; @@ -53,7 +50,7 @@ public EncodeResult encode(DType dtype, Object data, EncodeContext ctx) { private static EncodeResult encodeF64(double[] values, EncodeContext ctx) { int n = values.length; if (n == 0) { - return emptyResult(U64_DTYPE, ctx); + return emptyResult(DType.U64, ctx); } int sampleLen = Math.min(SAMPLE_SIZE, n); @@ -83,7 +80,7 @@ private static EncodeResult encodeF64(double[] values, EncodeContext ctx) { return buildEncodeResult( best.dict, best.rightBitWidth, leftCodes, rightParts, - U64_DTYPE, excPos, excVals, ctx); + DType.U64, excPos, excVals, ctx); } private static Dictionary64 findBestDictionaryF64(double[] values, int sampleLen) { @@ -132,7 +129,7 @@ private static int countExceptionsF64(double[] values, int sampleLen, short[] di private static EncodeResult encodeF32(float[] values, EncodeContext ctx) { int n = values.length; if (n == 0) { - return emptyResult(U32_DTYPE, ctx); + return emptyResult(DType.U32, ctx); } int sampleLen = Math.min(SAMPLE_SIZE, n); @@ -162,7 +159,7 @@ private static EncodeResult encodeF32(float[] values, EncodeContext ctx) { return buildEncodeResult( best.dict, best.rightBitWidth, leftCodes, rightParts, - U32_DTYPE, excPos, excVals, ctx); + DType.U32, excPos, excVals, ctx); } private static Dictionary32 findBestDictionaryF32(float[] values, int sampleLen) { @@ -233,7 +230,7 @@ private static EncodeResult buildEncodeResult( List excPos, List excVals, EncodeContext ctx) { EncodingEncoder bp = ctx.lookupEncoder(EncodingId.FASTLANES_BITPACKED); - EncodeResult leftResult = bp.encode(U16_DTYPE, leftCodes, ctx); + EncodeResult leftResult = bp.encode(DType.U16, leftCodes, ctx); EncodeResult rightResult = bp.encode(rightDtype, rightPartsData, ctx); List allBuffers = new ArrayList<>(leftResult.buffers()); @@ -259,8 +256,8 @@ private static EncodeResult buildEncodeResult( excValsArr[i] = excVals.get(i); } - EncodeResult idxResult = bp.encode(U64_DTYPE, excPosArr, ctx); - EncodeResult valResult = bp.encode(U16_DTYPE, excValsArr, ctx); + EncodeResult idxResult = bp.encode(DType.U64, excPosArr, ctx); + EncodeResult valResult = bp.encode(DType.U16, excValsArr, ctx); int idxOffset = allBuffers.size(); allBuffers.addAll(idxResult.buffers()); @@ -292,9 +289,9 @@ private static EncodeResult buildEncodeResult( private static EncodeResult emptyResult(DType rightDtype, EncodeContext ctx) { EncodingEncoder bp = ctx.lookupEncoder(EncodingId.FASTLANES_BITPACKED); - EncodeResult leftResult = bp.encode(U16_DTYPE, new short[0], ctx); + EncodeResult leftResult = bp.encode(DType.U16, new short[0], ctx); EncodeResult rightResult = bp.encode(rightDtype, - rightDtype.equals(U32_DTYPE) ? new int[0] : new long[0], ctx); + rightDtype.equals(DType.U32) ? new int[0] : new long[0], ctx); List allBuffers = new ArrayList<>(leftResult.buffers()); int leftBufCount = allBuffers.size(); diff --git a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/ChunkedEncodingEncoder.java b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/ChunkedEncodingEncoder.java index deb8e949..a5a15bd8 100644 --- a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/ChunkedEncodingEncoder.java +++ b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/ChunkedEncodingEncoder.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; @@ -59,7 +58,7 @@ public EncodeResult encode(DType dtype, Object data, EncodeContext ctx) { offsets[i + 1] = offsets[i] + chunkLengths[i]; } - DType u64 = new DType.Primitive(PType.U64, false); + DType u64 = DType.U64; EncodeResult offsetsResult = ctx.lookupEncoder(EncodingId.VORTEX_PRIMITIVE).encode(u64, offsets, ctx); List allBuffers = new ArrayList<>(offsetsResult.buffers()); diff --git a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/DateTimePartsEncodingEncoder.java b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/DateTimePartsEncodingEncoder.java index 35f46c9f..c720310c 100644 --- a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/DateTimePartsEncodingEncoder.java +++ b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/DateTimePartsEncodingEncoder.java @@ -16,8 +16,6 @@ public final class DateTimePartsEncodingEncoder implements EncodingEncoder { private static final long SECONDS_PER_DAY = 86_400L; - private static final DType I64 = new DType.Primitive(PType.I64, false); - private static final DType I64_NULLABLE = new DType.Primitive(PType.I64, true); private static final io.github.dfa1.vortex.proto.PType I64_PROTO = io.github.dfa1.vortex.proto.PType.fromValue(PType.I64.ordinal()); @@ -70,12 +68,12 @@ public EncodeResult encode(DType dtype, Object data, EncodeContext ctx) { subseconds[i] = rem % divisor; } - DType daysDtype = d.nullable() ? I64_NULLABLE : I64; + DType daysDtype = d.nullable() ? DType.I64.asNullable() : DType.I64; EncodingEncoder primEnc = ctx.lookupEncoder(EncodingId.VORTEX_PRIMITIVE); EncodeResult daysResult = primEnc.encode(daysDtype, days, ctx); - EncodeResult secondsResult = primEnc.encode(I64, seconds, ctx); - EncodeResult subsecondsResult = primEnc.encode(I64, subseconds, ctx); + EncodeResult secondsResult = primEnc.encode(DType.I64, seconds, ctx); + EncodeResult subsecondsResult = primEnc.encode(DType.I64, subseconds, ctx); List allBuffers = new ArrayList<>(); allBuffers.addAll(daysResult.buffers()); @@ -139,11 +137,11 @@ public CascadeStep encodeCascade(DType dtype, Object data, EncodeContext encodeC new EncodeNode[3], new int[0]); - DType daysDtype = d.nullable() ? I64_NULLABLE : I64; + DType daysDtype = d.nullable() ? DType.I64.asNullable() : DType.I64; List children = List.of( new ChildSlot(daysDtype, days, 0), - new ChildSlot(I64, seconds, 1), - new ChildSlot(I64, subseconds, 2)); + new ChildSlot(DType.I64, seconds, 1), + new ChildSlot(DType.I64, subseconds, 2)); return new CascadeStep(partialRoot, List.of(), children, null, null, true); } diff --git a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/MaskedEncodingEncoder.java b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/MaskedEncodingEncoder.java index d6defd3b..62758601 100644 --- a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/MaskedEncodingEncoder.java +++ b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/MaskedEncodingEncoder.java @@ -45,7 +45,7 @@ public EncodeResult encode(DType dtype, Object data, EncodeContext ctx) { DType nonNullable = dtype.withNullable(false); EncodingEncoder inner = pickInner(nonNullable); EncodeResult valuesResult = inner.encode(nonNullable, nd.values(), ctx); - EncodeResult validityResult = new BoolEncodingEncoder().encode(new DType.Bool(false), nd.validity(), ctx); + EncodeResult validityResult = new BoolEncodingEncoder().encode(DType.BOOL, nd.validity(), ctx); int valuesBufCount = valuesResult.buffers().size(); EncodeNode validityNode = EncodeNode.remapBufferIndices(validityResult.rootNode(), valuesBufCount); diff --git a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/PatchedEncodingEncoder.java b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/PatchedEncodingEncoder.java index d430f451..225e46e4 100644 --- a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/PatchedEncodingEncoder.java +++ b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/PatchedEncodingEncoder.java @@ -79,8 +79,8 @@ static CascadeStep encodeCascade(DType dtype, Object data) { EncodeNode partialRoot = new EncodeNode(EncodingId.VORTEX_PATCHED, ByteBuffer.wrap(metaBytes), new EncodeNode[]{null, null, null, null}, new int[]{}); - DType u32Dtype = new DType.Primitive(PType.U32, false); - DType u16Dtype = new DType.Primitive(PType.U16, false); + DType u32Dtype = DType.U32; + DType u16Dtype = DType.U16; return new CascadeStep(partialRoot, List.of(), List.of( diff --git a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/UuidExtensionEncoder.java b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/UuidExtensionEncoder.java index 6d2959d5..14d8e41a 100644 --- a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/UuidExtensionEncoder.java +++ b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/UuidExtensionEncoder.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.extension.ExtensionId; import io.github.dfa1.vortex.writer.ExtensionEncoder; @@ -29,7 +28,7 @@ public ExtensionId extensionId() { @Override public DType.Extension dtype(boolean nullable) { - DType.Primitive u8 = new DType.Primitive(PType.U8, false); + DType.Primitive u8 = DType.U8; // Rust vortex.uuid metadata: 0 bytes means "no specific version" — but the field // must be present in the flatbuffer or the Rust reader's ok_or_else() check fails. return new DType.Extension( diff --git a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/VariantEncodingEncoder.java b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/VariantEncodingEncoder.java index f380637e..705f6e34 100644 --- a/writer/src/main/java/io/github/dfa1/vortex/writer/encode/VariantEncodingEncoder.java +++ b/writer/src/main/java/io/github/dfa1/vortex/writer/encode/VariantEncodingEncoder.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.encoding.EncodingId; import io.github.dfa1.vortex.proto.Scalar; @@ -29,8 +28,6 @@ /// array of constant variant scalars under the canonical variant array. public final class VariantEncodingEncoder implements EncodingEncoder { - private static final DType U64 = new DType.Primitive(PType.U64, false); - /// Public no-arg constructor required by [java.util.ServiceLoader]. public VariantEncodingEncoder() { } @@ -160,7 +157,7 @@ private static EncodeNode chunkedConstants(List runValues, List ru offsets[i + 1] = offsets[i] + runLengths.get(i); } - EncodeResult offsetsResult = ctx.lookupEncoder(EncodingId.VORTEX_PRIMITIVE).encode(U64, offsets, ctx); + EncodeResult offsetsResult = ctx.lookupEncoder(EncodingId.VORTEX_PRIMITIVE).encode(DType.U64, offsets, ctx); buffers.addAll(offsetsResult.buffers()); EncodeNode[] children = new EncodeNode[nruns + 1]; diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/BitpackedEncodingTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/BitpackedEncodingTest.java index cd1c0c9e..d61d34be 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/BitpackedEncodingTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/BitpackedEncodingTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.writer.encode.BitpackedEncodingEncoder; import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.reader.decode.BitpackedEncodingDecoder; @@ -25,7 +24,7 @@ class BitpackedEncodingTest { private static final DType.Struct I32_SCHEMA = new DType.Struct( List.of("value"), - List.of(new DType.Primitive(PType.I32, false)), + List.of(DType.I32), false); private static ReadRegistry bitpackedRegistry() { diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/ChunkImplTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/ChunkImplTest.java index abd0c182..84f9f389 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/ChunkImplTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/ChunkImplTest.java @@ -174,7 +174,7 @@ class Utf8 { @Test void stringArrayAccepted() { - assertThat(putGet(new DType.Utf8(false), new String[]{"a", "b"})).isInstanceOf(String[].class); + assertThat(putGet(DType.UTF8, new String[]{"a", "b"})).isInstanceOf(String[].class); } @Test @@ -184,13 +184,13 @@ void nullableAllowsNullElements() { @Test void nonNullableRejectsNullElement() { - assertThatThrownBy(() -> putGet(new DType.Utf8(false), new String[]{"a", null})) + assertThatThrownBy(() -> putGet(DType.UTF8, new String[]{"a", null})) .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("null at row 1"); } @Test void wrongTypeRejected() { - assertThatThrownBy(() -> putGet(new DType.Utf8(false), new int[]{1})) + assertThatThrownBy(() -> putGet(DType.UTF8, new int[]{1})) .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("expects String[]"); } } @@ -200,7 +200,7 @@ class Bool { @Test void boolArrayAccepted() { - assertThat(putGet(new DType.Bool(false), new boolean[]{true, false})).isInstanceOf(boolean[].class); + assertThat(putGet(DType.BOOL, new boolean[]{true, false})).isInstanceOf(boolean[].class); } @Test @@ -215,13 +215,13 @@ void boxedConvertsToNullableDataOnNullableColumn() { @Test void boxedRejectedOnNonNullableColumn() { - assertThatThrownBy(() -> putGet(new DType.Bool(false), new Boolean[]{true})) + assertThatThrownBy(() -> putGet(DType.BOOL, new Boolean[]{true})) .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("rejects Boolean[]"); } @Test void wrongTypeRejected() { - assertThatThrownBy(() -> putGet(new DType.Bool(false), new int[]{1})) + assertThatThrownBy(() -> putGet(DType.BOOL, new int[]{1})) .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("expects boolean[]"); } } diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/DeltaEncodingTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/DeltaEncodingTest.java index 5af74491..0864ae41 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/DeltaEncodingTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/DeltaEncodingTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.writer.encode.DeltaEncodingEncoder; import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.reader.VortexReader; @@ -24,7 +23,7 @@ class DeltaEncodingTest { private static final DType.Struct I64_SCHEMA = new DType.Struct( List.of("ts"), - List.of(new DType.Primitive(PType.I64, false)), + List.of(DType.I64), false); private static ReadRegistry deltaRegistry() { diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/DictEncodingTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/DictEncodingTest.java index ce55e01d..c242e0c8 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/DictEncodingTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/DictEncodingTest.java @@ -2,7 +2,6 @@ import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.writer.encode.DictEncodingEncoder; import io.github.dfa1.vortex.reader.ReadRegistry; @@ -27,7 +26,7 @@ class DictEncodingTest { private static final DType.Struct SCHEMA = new DType.Struct( List.of("category"), - List.of(new DType.Primitive(PType.I32, false)), + List.of(DType.I32), false); private static ReadRegistry dictRegistry() { diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictF64Test.java b/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictF64Test.java index 860089c1..033cc3cc 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictF64Test.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictF64Test.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.reader.VortexReader; import org.junit.jupiter.api.Test; @@ -26,7 +25,7 @@ class GlobalDictF64Test { private static final DType.Struct SCHEMA = new DType.Struct( List.of("rate"), - List.of(new DType.Primitive(PType.F64, false)), + List.of(DType.F64), false); @Test diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictPrimitiveTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictPrimitiveTest.java index 8d5cf440..096f256f 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictPrimitiveTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictPrimitiveTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.reader.VortexReader; import org.junit.jupiter.api.Test; @@ -26,7 +25,7 @@ class GlobalDictPrimitiveTest { private static DType.Struct i64Schema() { - return new DType.Struct(List.of("v"), List.of(new DType.Primitive(PType.I64, false)), false); + return new DType.Struct(List.of("v"), List.of(DType.I64), false); } private static long[] writeI64(Path file, long[][] chunks, WriteOptions options) throws IOException { @@ -150,7 +149,7 @@ void lowCardinality_i32_usesGlobalDict(@TempDir Path tmp) throws IOException { // Given — a low-cardinality I32 column drives the global dict build through the int[] // unique-array and codes paths (the narrower I8/I16 carriers are NOT round-tripped here: // the reader's lazy dict rejects them — see lowCardinality_i16_globalDict_readerRejects). - var schema = new DType.Struct(List.of("v"), List.of(new DType.Primitive(PType.I32, false)), false); + var schema = new DType.Struct(List.of("v"), List.of(DType.I32), false); int[] data = {10, 20, 30, 10, 20, 30, 10, 20}; Path file = tmp.resolve("i32.vortex"); try (var ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); @@ -175,7 +174,7 @@ void lowCardinality_i16_notDicted_roundTrips(@TempDir Path tmp) throws IOExcepti // excluded from dict candidacy — matching the Rust compressor, which does not dict narrow // ints (RustWritesJavaReadsIntegrationTest#jniWriter_javaReader_lowCardinalityI16) — so a // low-card I16 column encodes via the cascade and round-trips cleanly. - var schema = new DType.Struct(List.of("v"), List.of(new DType.Primitive(PType.I16, false)), false); + var schema = new DType.Struct(List.of("v"), List.of(DType.I16), false); short[] data = {1, 2, 3, 1, 2, 3, 1, 2}; Path file = tmp.resolve("i16.vortex"); try (var ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); @@ -208,7 +207,7 @@ void lowCardinality_i16_notDicted_roundTrips(@TempDir Path tmp) throws IOExcepti void lowCardinality_f64_usesGlobalDict(@TempDir Path tmp) throws IOException { // Given — F64 is admitted to the dict path (unlike F16/F32); a low-card float column must // round-trip through the float dict build. - var schema = new DType.Struct(List.of("v"), List.of(new DType.Primitive(PType.F64, false)), false); + var schema = new DType.Struct(List.of("v"), List.of(DType.F64), false); double[] dictVals = {1.5, 2.5, 3.5}; int rows = 900; double[] data = new double[rows]; diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictUtf8Test.java b/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictUtf8Test.java index 5c3de8f8..75563ae5 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictUtf8Test.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/GlobalDictUtf8Test.java @@ -23,7 +23,7 @@ class GlobalDictUtf8Test { private static final DType.Struct SCHEMA = new DType.Struct( List.of("status"), - List.of(new DType.Utf8(false)), + List.of(DType.UTF8), false); @Test diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/MultiChunkUtf8RoundTripTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/MultiChunkUtf8RoundTripTest.java index 968e0669..ffc9f6e7 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/MultiChunkUtf8RoundTripTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/MultiChunkUtf8RoundTripTest.java @@ -28,7 +28,7 @@ class MultiChunkUtf8RoundTripTest { private static final DType.Struct STRING_SCHEMA = new DType.Struct( - List.of("s"), List.of(new DType.Utf8(false)), false); + List.of("s"), List.of(DType.UTF8), false); @Test void manyBatchesUtf8WithCascading_columnIsChunkedMode(@TempDir Path tmp) throws IOException { diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/TypedChunkBuilderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/TypedChunkBuilderTest.java index c7b12ba7..305ad629 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/TypedChunkBuilderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/TypedChunkBuilderTest.java @@ -22,9 +22,9 @@ class TypedChunkBuilderTest { private static final DType.Struct SCHEMA = DType.structBuilder() - .field("timestamp", DType.i64()) - .field("symbol", DType.utf8()) - .field("price", DType.f64()) + .field("timestamp", DType.I64) + .field("symbol", DType.UTF8) + .field("price", DType.F64) .build(); @Test @@ -98,7 +98,7 @@ void nullable_i64Column_acceptsBoxedArrayWithNulls(@TempDir Path tmp) throws IOE // Given Path file = tmp.resolve("nullable.vortex"); DType.Struct nullableSchema = DType.structBuilder() - .field("v", DType.i64().asNullable()) + .field("v", DType.I64.asNullable()) .build(); try (var ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/VortexWriterTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/VortexWriterTest.java index ded0e0c8..e0d39986 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/VortexWriterTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/VortexWriterTest.java @@ -26,8 +26,8 @@ class VortexWriterTest { private static final DType.Struct SCHEMA = new DType.Struct( List.of("id", "value"), - List.of(new DType.Primitive(PType.I64, false), - new DType.Primitive(PType.F64, false)), + List.of(DType.I64, + DType.F64), false); private record ChunkSnapshot(long rowCount, java.util.Set columnNames) { @@ -96,7 +96,7 @@ void writeChunk_extensionCollectionColumn_rowCountValidatedAgainstSibling(@TempD var schema = new DType.Struct( List.of("birthdays", "id"), List.of(io.github.dfa1.vortex.writer.encode.DateExtensionEncoder.INSTANCE.dtype(false), - new DType.Primitive(PType.I64, false)), + DType.I64), false); List dates = List.of( java.time.LocalDate.of(1996, 2, 12), @@ -482,7 +482,7 @@ void create_withFullRegistry_roundTrips(@TempDir Path tmp) throws IOException { // encoders like ChunkedEncodingEncoder no longer claim raw primitive dtypes) keep selection // both stable across platforms and correct. var schema = new DType.Struct(List.of("v"), - List.of(new DType.Primitive(PType.I64, false)), false); + List.of(DType.I64), false); Path file = tmp.resolve("registry.vortex"); long[] data = {1L, 2L, 3L, 4L}; diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/WriterZoneMapTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/WriterZoneMapTest.java index fd9a41a6..00686764 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/WriterZoneMapTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/WriterZoneMapTest.java @@ -30,7 +30,7 @@ class WriterZoneMapTest { private static final DType.Struct SCHEMA = new DType.Struct( - List.of("v"), List.of(new DType.Primitive(PType.I64, false)), false); + List.of("v"), List.of(DType.I64), false); // Three zones of four rows: [0..3], [4..7], [8..11]. private static Path write(Path tmp, boolean zoneMaps) throws IOException { @@ -210,7 +210,7 @@ void chunkWithoutStats_emitsNullCountOnlyZoneMap(@TempDir Path tmp) throws IOExc // dropped (it requires every chunk to carry stats), but NULL_COUNT and SUM are still emitted // — SUM is independent (the empty zone's sum is simply null). DType.Struct schema = new DType.Struct( - List.of("v"), List.of(new DType.Primitive(PType.I64, false)), false); + List.of("v"), List.of(DType.I64), false); WriteOptions opts = new WriteOptions(2, true, 0.90, 0, false, false); Path file = tmp.resolve("partial.vtx"); try (var ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); @@ -234,7 +234,7 @@ void utf8Column_emitsStringMinMaxZoneMap(@TempDir Path tmp) throws IOException { // zone 1 = ["cherry", "date"]. vortex.varbin records full string min/max per chunk, so // the zone-map carries MAX+MIN+NULL_COUNT (string min/max), not null_count alone. DType.Struct schema = new DType.Struct( - List.of("s"), List.of(new DType.Utf8(false)), false); + List.of("s"), List.of(DType.UTF8), false); WriteOptions opts = new WriteOptions(2, true, 0.90, 0, false, false); Path file = tmp.resolve("utf8.vtx"); try (var ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); @@ -271,7 +271,7 @@ void extensionColumn_emitsStorageMinMaxZoneMap(@TempDir Path tmp) throws IOExcep // two zones of two rows: zone 0 = [10, 11], zone 1 = [20, 21]. ExtEncoding propagates the // storage primitive's min/max, so the zone-map carries MAX+MIN+NULL_COUNT — same as I64. DType ext = new DType.Extension( - "test.ext", new DType.Primitive(PType.I64, false), null, false); + "test.ext", DType.I64, null, false); DType.Struct schema = new DType.Struct(List.of("t"), List.of(ext), false); WriteOptions opts = new WriteOptions(2, true, 0.90, 0, false, false); Path file = tmp.resolve("ext.vtx"); @@ -309,7 +309,7 @@ void dictColumn_emitsStringMinMaxZoneMapWrappingDict(@TempDir Path tmp) throws I // computed on the logical Utf8 values, independent of the dict encoding: zone 0 = a..b, // zone 1 = a..c → MAX+MIN+NULL_COUNT, with the column wrapped as vortex.stats over the dict. DType.Struct schema = new DType.Struct( - List.of("s"), List.of(new DType.Utf8(false)), false); + List.of("s"), List.of(DType.UTF8), false); WriteOptions opts = new WriteOptions(6, true, 0.90, 0, true, false); Path file = tmp.resolve("dict.vtx"); try (var ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); @@ -346,7 +346,7 @@ void primitiveDictColumn_emitsNumericMinMaxZoneMapWrappingDict(@TempDir Path tmp // Given a low-cardinality I64 column across 2 chunks of 6 with heavy repeats → vortex.dict. // Zone-map min/max are computed on the logical I64 values: zone 0 = 1..2, zone 1 = 1..3. DType.Struct schema = new DType.Struct( - List.of("v"), List.of(new DType.Primitive(PType.I64, false)), false); + List.of("v"), List.of(DType.I64), false); WriteOptions opts = new WriteOptions(6, true, 0.90, 0, true, false); Path file = tmp.resolve("primdict.vtx"); try (var ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); @@ -399,7 +399,7 @@ private static DType.Struct statsTableDtype() { DType nullableI64 = new DType.Primitive(PType.I64, true); return new DType.Struct( List.of("max", "max_is_truncated", "min", "min_is_truncated", "null_count"), - List.of(nullableI64, new DType.Bool(false), nullableI64, new DType.Bool(false), + List.of(nullableI64, DType.BOOL, nullableI64, DType.BOOL, new DType.Primitive(PType.U64, true)), false); } @@ -409,7 +409,7 @@ private static DType.Struct numericStatsTableDtype() { DType nullableI64 = new DType.Primitive(PType.I64, true); return new DType.Struct( List.of("max", "max_is_truncated", "min", "min_is_truncated", "sum", "null_count"), - List.of(nullableI64, new DType.Bool(false), nullableI64, new DType.Bool(false), + List.of(nullableI64, DType.BOOL, nullableI64, DType.BOOL, nullableI64, new DType.Primitive(PType.U64, true)), false); } @@ -419,7 +419,7 @@ private static DType.Struct utf8StatsTableDtype() { DType nullableUtf8 = new DType.Utf8(true); return new DType.Struct( List.of("max", "max_is_truncated", "min", "min_is_truncated", "null_count"), - List.of(nullableUtf8, new DType.Bool(false), nullableUtf8, new DType.Bool(false), + List.of(nullableUtf8, DType.BOOL, nullableUtf8, DType.BOOL, new DType.Primitive(PType.U64, true)), false); } diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/ZoneMapPruningTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/ZoneMapPruningTest.java index 4fc7e639..9d147ed1 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/ZoneMapPruningTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/ZoneMapPruningTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.Chunk; import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.reader.RowFilter; @@ -28,7 +27,7 @@ class ZoneMapPruningTest { private static final DType.Struct SCHEMA = new DType.Struct( List.of("id"), - List.of(new DType.Primitive(PType.I64, false)), + List.of(DType.I64), false); // Three chunks: id in [1..50], [51..100], [101..150] diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/BitpackedConstantPatchesBroadcastTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/BitpackedConstantPatchesBroadcastTest.java index e1990c78..8c607c88 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/BitpackedConstantPatchesBroadcastTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/BitpackedConstantPatchesBroadcastTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.reader.decode.ArrayNode; import io.github.dfa1.vortex.reader.decode.DecodeContext; @@ -61,7 +60,7 @@ void bitpackedDecode_withConstantPatchesValues_broadcastsValueAcrossPatches() { ArrayNode root = ArrayNode.of(EncodingId.FASTLANES_BITPACKED, metaBuf, new ArrayNode[]{idxChild, valChild}, new int[]{0}); - DType dtype = new DType.Primitive(PType.I64, false); + DType dtype = DType.I64; ReadRegistry registry = ReadRegistry.loadAll(); DecodeContext ctx = new DecodeContext(root, dtype, n, new MemorySegment[]{packedSeg, idxBufSeg, valBufSeg}, diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ChunkedEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ChunkedEncodingEncoderTest.java index 76c0bac9..2f2da420 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ChunkedEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ChunkedEncodingEncoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.reader.array.LongArray; @@ -50,7 +49,7 @@ void roundTrip_twoChunks_i64_preservesValues() { // Given long[] chunk0 = {10L, 20L, 30L}; long[] chunk1 = {40L, 50L}; - DType i64 = new DType.Primitive(PType.I64, false); + DType i64 = DType.I64; ChunkedData data = new ChunkedData(List.of(chunk0, chunk1), new long[]{3, 2}); // When @@ -72,7 +71,7 @@ void roundTrip_twoChunks_i64_preservesValues() { void encodeNode_hasNoDirectBuffers_offsetsAsFirstChild() { // Given long[] chunk0 = {1L, 2L}; - DType i64 = new DType.Primitive(PType.I64, false); + DType i64 = DType.I64; ChunkedData data = new ChunkedData(List.of(chunk0), new long[]{2}); // When @@ -100,8 +99,8 @@ void roundTrip_twoChunks_concatenatesValues() { // Given long[] chunk0 = {10L, 20L, 30L}; long[] chunk1 = {40L, 50L}; - DType i64 = new DType.Primitive(PType.I64, false); - DType u64 = new DType.Primitive(PType.U64, false); + DType i64 = DType.I64; + DType u64 = DType.U64; EncodeResult offsetsResult = PRIM_ENCODER.encode(u64, new long[]{0L, 3L, 5L}, EncodeTestHelper.testCtx()); EncodeResult chunk0Result = PRIM_ENCODER.encode(i64, chunk0, EncodeTestHelper.testCtx()); @@ -140,8 +139,8 @@ void roundTrip_twoChunks_concatenatesValues() { void singleChunk_returnsSameValues() { // Given long[] data = {1L, 2L, 3L}; - DType i64 = new DType.Primitive(PType.I64, false); - DType u64 = new DType.Primitive(PType.U64, false); + DType i64 = DType.I64; + DType u64 = DType.U64; EncodeResult offsetsResult = PRIM_ENCODER.encode(u64, new long[]{0L, 3L}, EncodeTestHelper.testCtx()); EncodeResult chunkResult = PRIM_ENCODER.encode(i64, data, EncodeTestHelper.testCtx()); @@ -172,7 +171,7 @@ void singleChunk_returnsSameValues() { @Test void noChildren_throws() { // Given - DType i64 = new DType.Primitive(PType.I64, false); + DType i64 = DType.I64; ArrayNode root = ArrayNode.of(EncodingId.VORTEX_CHUNKED, null, new ArrayNode[]{}, new int[]{}); DecodeContext ctx = new DecodeContext(root, i64, 0L, new MemorySegment[]{}, REGISTRY, Arena.ofAuto()); diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/DateTimePartsEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/DateTimePartsEncodingEncoderTest.java index 7f4d047e..f90eb340 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/DateTimePartsEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/DateTimePartsEncodingEncoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.LongArray; import io.github.dfa1.vortex.reader.decode.ArrayNode; import io.github.dfa1.vortex.encoding.DTypes; @@ -42,7 +41,7 @@ private static DType timestampDType(TimeUnit unit) { meta.putShort((short) 0); meta.flip(); return new DType.Extension("vortex.timestamp", - new DType.Primitive(PType.I64, false), meta, false); + DType.I64, meta, false); } private static ArrayNode toArrayNode(EncodeNode node) { @@ -95,7 +94,7 @@ void encode_producesThreeChildren_noBuffersAtRoot() { void encode_missingMetadata_throws() { // Given DType noMeta = new DType.Extension("vortex.timestamp", - new DType.Primitive(PType.I64, false), null, false); + DType.I64, null, false); DateTimePartsData data = new DateTimePartsData(new long[]{0L}, false); // When / Then diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/DecimalEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/DecimalEncodingEncoderTest.java index 7f66ba7a..513ed0be 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/DecimalEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/DecimalEncodingEncoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.reader.decode.DecodeContext; @@ -52,7 +51,7 @@ void accepts_decimalDtype_true_primitiveReturnsFalse() { // Given // When / Then assertThat(ENCODER.accepts(new DType.Decimal((byte) 18, (byte) 2, false))).isTrue(); - assertThat(ENCODER.accepts(new DType.Primitive(PType.I64, false))).isFalse(); + assertThat(ENCODER.accepts(DType.I64)).isFalse(); } @ParameterizedTest(name = "precision={0} → valuesType={1}") diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ExtEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ExtEncodingEncoderTest.java index ec4736e6..37868156 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ExtEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ExtEncodingEncoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.LongArray; import io.github.dfa1.vortex.reader.decode.ArrayNode; import io.github.dfa1.vortex.reader.decode.DecodeContext; @@ -33,7 +32,7 @@ class Encode { void accepts_extensionDtype_returnsTrue() { // Given DType extDType = new DType.Extension("vortex.timestamp", - new DType.Primitive(PType.I64, false), null, false); + DType.I64, null, false); // When / Then assertThat(ENCODER.accepts(extDType)).isTrue(); @@ -42,14 +41,14 @@ void accepts_extensionDtype_returnsTrue() { @Test void accepts_primitiveDtype_returnsFalse() { // Given / When / Then - assertThat(ENCODER.accepts(new DType.Primitive(PType.I64, false))).isFalse(); + assertThat(ENCODER.accepts(DType.I64)).isFalse(); } @Test void encode_extensionWrappingI64_roundTrips() { // Given long[] data = {100L, 200L, 300L, 400L}; - DType storageDType = new DType.Primitive(PType.I64, false); + DType storageDType = DType.I64; DType extDType = new DType.Extension("vortex.timestamp", storageDType, null, false); // When @@ -90,7 +89,7 @@ class Cascade { void encodeCascade_exposesStorageAsOpenChild() { // Given long[] data = {100L, 200L, 300L, 400L}; - DType storageDType = new DType.Primitive(PType.I64, false); + DType storageDType = DType.I64; DType extDType = new DType.Extension("vortex.timestamp", storageDType, null, false); // When @@ -112,7 +111,7 @@ void encodeCascade_exposesStorageAsOpenChild() { void encodeCascade_rejectsNonExtensionDtype() { // Given / When / Then org.assertj.core.api.Assertions.assertThatThrownBy(() -> - ENCODER.encodeCascade(new DType.Primitive(PType.I64, false), new long[]{1L}, + ENCODER.encodeCascade(DType.I64, new long[]{1L}, EncodeTestHelper.testCtx())) .isInstanceOf(io.github.dfa1.vortex.core.VortexException.class) .hasMessageContaining("expected extension dtype"); @@ -128,7 +127,7 @@ void decode_extensionWrappingI64_returnsStorageArray() { long[] values = {10L, 20L, 30L, 40L}; MemorySegment buf = TestSegments.leLongs(values); - DType storageDType = new DType.Primitive(PType.I64, false); + DType storageDType = DType.I64; DType extDType = new DType.Extension("vortex.timestamp", storageDType, null, false); ArrayNode primitiveNode = ArrayNode.of(EncodingId.VORTEX_PRIMITIVE, null, new ArrayNode[0], new int[]{0}); diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/MaskedEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/MaskedEncodingEncoderTest.java index fef16f35..e1bd409a 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/MaskedEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/MaskedEncodingEncoderTest.java @@ -32,7 +32,7 @@ class MaskedEncodingEncoderTest { private static final ReadRegistry REGISTRY = TestRegistry.ofDecoders(DECODER, new PrimitiveEncodingDecoder(), new BoolEncodingDecoder()); private static EncodeResult maskedResult(int[] values, boolean[] validity) { - DType i32 = new DType.Primitive(PType.I32, false); + DType i32 = DType.I32; EncodeResult childResult = PRIM_ENCODER.encode(i32, values, EncodeTestHelper.testCtx()); List allBuffers = new ArrayList<>(childResult.buffers()); @@ -41,7 +41,7 @@ private static EncodeResult maskedResult(int[] values, boolean[] validity) { if (validity == null) { children = new EncodeNode[]{childResult.rootNode()}; } else { - DType boolDtype = new DType.Bool(false); + DType boolDtype = DType.BOOL; EncodeResult validityResult = BOOL_ENCODER.encode(boolDtype, validity, EncodeTestHelper.testCtx()); EncodeNode remapped = EncodeNode.remapBufferIndices( validityResult.rootNode(), childResult.buffers().size()); @@ -161,7 +161,7 @@ void threeChildrenThrows() { // Given DType i32Nullable = new DType.Primitive(PType.I32, true); - DType i32 = new DType.Primitive(PType.I32, false); + DType i32 = DType.I32; EncodeResult childResult = PRIM_ENCODER.encode(i32, new int[]{1}, EncodeTestHelper.testCtx()); EncodeNode childNode = childResult.rootNode(); EncodeNode maskedNode = new EncodeNode( diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PatchedEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PatchedEncodingEncoderTest.java index 567f2fc7..04af8ae2 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PatchedEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PatchedEncodingEncoderTest.java @@ -241,9 +241,9 @@ void encodeCascade_applicable_withFewOutliers() { // child 0: inner (same dtype), child 1: laneOffsets (U32), child 2: patchIdx (U16), child 3: patchVal (same dtype) assertThat(step.openChildren().get(0).childDtype()).isEqualTo(DTypes.I64); assertThat(step.openChildren().get(1).childDtype()) - .isEqualTo(new DType.Primitive(PType.U32, false)); + .isEqualTo(DType.U32); assertThat(step.openChildren().get(2).childDtype()) - .isEqualTo(new DType.Primitive(PType.U16, false)); + .isEqualTo(DType.U16); assertThat(step.openChildren().get(3).childDtype()).isEqualTo(DTypes.I64); } diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PcoEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PcoEncodingEncoderTest.java index 5b3a6bfb..4cbae3cb 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PcoEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PcoEncodingEncoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.encoding.PTypeIO; import io.github.dfa1.vortex.reader.ReadRegistry; import io.github.dfa1.vortex.reader.array.Array; @@ -28,14 +27,14 @@ class PcoEncodingEncoderTest { private static final PcoEncodingDecoder DECODER = new PcoEncodingDecoder(); private static final ReadRegistry REGISTRY = TestRegistry.ofDecoders(DECODER); - private static final DType I64 = new DType.Primitive(PType.I64, false); - private static final DType U64 = new DType.Primitive(PType.U64, false); - private static final DType I32 = new DType.Primitive(PType.I32, false); - private static final DType U32 = new DType.Primitive(PType.U32, false); - private static final DType I16 = new DType.Primitive(PType.I16, false); - private static final DType U16 = new DType.Primitive(PType.U16, false); - private static final DType F32 = new DType.Primitive(PType.F32, false); - private static final DType F64 = new DType.Primitive(PType.F64, false); + private static final DType I64 = DType.I64; + private static final DType U64 = DType.U64; + private static final DType I32 = DType.I32; + private static final DType U32 = DType.U32; + private static final DType I16 = DType.I16; + private static final DType U16 = DType.U16; + private static final DType F32 = DType.F32; + private static final DType F64 = DType.F64; static Stream i64Arrays() { return Stream.of( diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PrimitiveEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PrimitiveEncodingEncoderTest.java index 92f145b2..f72a3e56 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PrimitiveEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/PrimitiveEncodingEncoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.reader.array.IntArray; import io.github.dfa1.vortex.reader.array.MaskedArray; @@ -69,7 +68,7 @@ static Stream doubleArrays() { @MethodSource("longArrays") void encodeDecode_i64_isLossless(long[] data) { // Given - DType dtype = new DType.Primitive(PType.I64, false); + DType dtype = DType.I64; EncodeResult resultEncoded = ENCODER.encode(dtype, data, EncodeTestHelper.testCtx()); DecodeContext ctx = DecodeTestHelper.toDecodeContext(resultEncoded, data.length, dtype, REGISTRY); @@ -87,7 +86,7 @@ void encodeDecode_i64_isLossless(long[] data) { @MethodSource("intArrays") void encodeDecode_i32_isLossless(int[] data) { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; EncodeResult resultEncoded = ENCODER.encode(dtype, data, EncodeTestHelper.testCtx()); DecodeContext ctx = DecodeTestHelper.toDecodeContext(resultEncoded, data.length, dtype, REGISTRY); @@ -105,7 +104,7 @@ void encodeDecode_i32_isLossless(int[] data) { @MethodSource("doubleArrays") void encodeDecode_f64_isLossless(double[] data) { // Given - DType dtype = new DType.Primitive(PType.F64, false); + DType dtype = DType.F64; EncodeResult resultEncoded = ENCODER.encode(dtype, data, EncodeTestHelper.testCtx()); DecodeContext ctx = DecodeTestHelper.toDecodeContext(resultEncoded, data.length, dtype, REGISTRY); @@ -123,7 +122,7 @@ void encodeDecode_f64_isLossless(double[] data) { @MethodSource("longArrays") void encodedSize_equalsBytesInBuffer(long[] data) { // Given - DType dtype = new DType.Primitive(PType.I64, false); + DType dtype = DType.I64; // When EncodeResult result = ENCODER.encode(dtype, data, EncodeTestHelper.testCtx()); @@ -151,7 +150,7 @@ void decode_withValidityChild_returnsMaskedArray() { ReadRegistry registry = TestRegistry.ofDecoders(new PrimitiveEncodingDecoder(), new BoolEncodingDecoder()); - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; DecodeContext ctx = new DecodeContext( primNode, dtype, raw.length, new MemorySegment[]{valuesSeg, validitySeg}, @@ -182,7 +181,7 @@ void decode_noValidityChild_returnsPlainArray() { ArrayNode primNode = ArrayNode.of( EncodingId.VORTEX_PRIMITIVE, null, new ArrayNode[0], new int[]{0}); - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; DecodeContext ctx = new DecodeContext( primNode, dtype, raw.length, new MemorySegment[]{valuesSeg}, diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/RleEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/RleEncodingEncoderTest.java index 9480e7cb..fb99fd16 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/RleEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/RleEncodingEncoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.reader.array.Array; import io.github.dfa1.vortex.reader.array.IntArray; import io.github.dfa1.vortex.reader.array.MaskedArray; @@ -49,7 +48,7 @@ class Encode { @Test void roundTrip_empty_i32() { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; EncodeResult encoded = ENCODER.encode(dtype, new int[0], EncodeTestHelper.testCtx()); DecodeContext ctx = DecodeTestHelper.toDecodeContext(encoded, 0, dtype, REGISTRY); @@ -63,7 +62,7 @@ void roundTrip_empty_i32() { @Test void roundTrip_singleElement_i32() { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; int[] data = {42}; EncodeResult encoded = ENCODER.encode(dtype, data, EncodeTestHelper.testCtx()); DecodeContext ctx = DecodeTestHelper.toDecodeContext(encoded, data.length, dtype, REGISTRY); @@ -79,7 +78,7 @@ void roundTrip_singleElement_i32() { @Test void roundTrip_constantArray_i32() { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; int n = 2048; int[] data = new int[n]; for (int i = 0; i < n; i++) { @@ -101,7 +100,7 @@ void roundTrip_constantArray_i32() { @Test void roundTrip_classicRunLengthData_i32() { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; int[] data = {1, 1, 1, 2, 2, 3}; EncodeResult encoded = ENCODER.encode(dtype, data, EncodeTestHelper.testCtx()); DecodeContext ctx = DecodeTestHelper.toDecodeContext(encoded, data.length, dtype, REGISTRY); @@ -118,7 +117,7 @@ void roundTrip_classicRunLengthData_i32() { @Test void roundTrip_multipleChunks_i32() { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; int n = 3000; int[] data = new int[n]; for (int i = 0; i < n; i++) { @@ -140,7 +139,7 @@ void roundTrip_multipleChunks_i32() { @Test void roundTrip_i64() { // Given - DType dtype = new DType.Primitive(PType.I64, false); + DType dtype = DType.I64; long[] data = {100L, 100L, 200L, 300L, 300L, 300L}; EncodeResult encoded = ENCODER.encode(dtype, data, EncodeTestHelper.testCtx()); DecodeContext ctx = DecodeTestHelper.toDecodeContext(encoded, data.length, dtype, REGISTRY); @@ -158,7 +157,7 @@ void roundTrip_i64() { @ValueSource(ints = {1, 512, 1023, 1024, 1025, 2048, 2049}) void roundTrip_variousLengths_i32(int n) { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; int[] data = new int[n]; for (int i = 0; i < n; i++) { data[i] = i / 50; @@ -179,7 +178,7 @@ void roundTrip_variousLengths_i32(int n) { @Test void roundTrip_allDifferent_u16() { // Given - DType dtype = new DType.Primitive(PType.U16, false); + DType dtype = DType.U16; short[] data = new short[256]; for (int i = 0; i < 256; i++) { data[i] = (short) i; @@ -200,7 +199,7 @@ void roundTrip_allDifferent_u16() { @Test void roundTrip_negativeValues_i32() { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; int[] data = {-3, -3, -1, -1, 0, 0, 5}; EncodeResult encoded = ENCODER.encode(dtype, data, EncodeTestHelper.testCtx()); DecodeContext ctx = DecodeTestHelper.toDecodeContext(encoded, data.length, dtype, REGISTRY); @@ -221,7 +220,7 @@ class Decode { @Test void decode_exactlyOneChunk_correctLength() { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; int[] data = new int[1024]; for (int i = 0; i < 1024; i++) { data[i] = i / 10; @@ -239,7 +238,7 @@ void decode_exactlyOneChunk_correctLength() { @Test void decode_crossesChunkBoundary_correctValues() { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; int n = 2048; int[] data = new int[n]; for (int i = 0; i < n; i++) { @@ -260,7 +259,7 @@ void decode_crossesChunkBoundary_correctValues() { @Test void decode_nullableIndices_returnsMaskedArrayWithCorrectValidity() { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; int[] data = {10, 10, 20, 20}; EncodeResult encoded = ENCODER.encode(dtype, data, EncodeTestHelper.testCtx()); @@ -302,7 +301,7 @@ void decode_nullableIndices_returnsMaskedArrayWithCorrectValidity() { @Test void decode_partialLastChunk_correctLength() { // Given - DType dtype = new DType.Primitive(PType.I32, false); + DType dtype = DType.I32; int n = 1500; int[] data = new int[n]; for (int i = 0; i < n; i++) { diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/SequenceEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/SequenceEncodingEncoderTest.java index 24efe7e9..4071e5d4 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/SequenceEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/SequenceEncodingEncoderTest.java @@ -62,7 +62,7 @@ void accepts_primitive_true() { @Test void accepts_nonPrimitive_false() { // Given / When / Then - assertThat(ENCODER.accepts(new DType.Utf8(false))).isFalse(); + assertThat(ENCODER.accepts(DType.UTF8)).isFalse(); } @Test @@ -288,7 +288,7 @@ void encode_nonArithmeticSequence_throwsVortexException() { @Test void encode_nonPrimitiveDtype_throwsVortexException() { // Given / When / Then - assertThatThrownBy(() -> ENCODER.encode(new DType.Utf8(false), new long[]{1L}, EncodeTestHelper.testCtx())) + assertThatThrownBy(() -> ENCODER.encode(DType.UTF8, new long[]{1L}, EncodeTestHelper.testCtx())) .isInstanceOf(VortexException.class); } } @@ -425,7 +425,7 @@ void decode_f16_generatesCorrectSequence() { @Test void decode_nonPrimitiveDtype_throwsVortexException() { - DType utf8 = new DType.Utf8(false); + DType utf8 = DType.UTF8; DecodeContext ctx = makeCtx(intMeta(0, 1), utf8, 3); assertThatThrownBy(() -> DECODER.decode(ctx)).isInstanceOf(VortexException.class); } diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/TimeExtensionEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/TimeExtensionEncoderTest.java index 768755d7..7145234b 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/TimeExtensionEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/TimeExtensionEncoderTest.java @@ -34,7 +34,7 @@ void dtype_default_isMillisecondsOverI32() { // Then assertThat(TimeDtype.readUnit(result)).isEqualTo(TimeUnit.Milliseconds); - assertThat(result.storageDType()).isEqualTo(new DType.Primitive(PType.I32, false)); + assertThat(result.storageDType()).isEqualTo(DType.I32); } @Test @@ -54,7 +54,7 @@ void dtype_nanoseconds_usesI64() { // Then assertThat(TimeDtype.readUnit(result)).isEqualTo(TimeUnit.Nanoseconds); - assertThat(result.storageDType()).isEqualTo(new DType.Primitive(PType.I64, false)); + assertThat(result.storageDType()).isEqualTo(DType.I64); } @Test @@ -157,7 +157,7 @@ void encodeAll_daysUnit_throws() { ByteBuffer meta = ByteBuffer.allocate(1); meta.put(0, (byte) TimeUnit.Days.ordinal()); DType.Extension dtype = new DType.Extension( - ExtensionId.VORTEX_TIME.id(), new DType.Primitive(PType.I32, false), meta, false); + ExtensionId.VORTEX_TIME.id(), DType.I32, meta, false); // When / Then assertThatThrownBy(() -> SUT.encodeAll(dtype, List.of(T))) diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/VarBinEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/VarBinEncodingEncoderTest.java index 03037d96..82c1df76 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/VarBinEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/VarBinEncodingEncoderTest.java @@ -1,7 +1,6 @@ package io.github.dfa1.vortex.writer.encode; import io.github.dfa1.vortex.core.DType; -import io.github.dfa1.vortex.core.PType; import io.github.dfa1.vortex.core.VortexException; import io.github.dfa1.vortex.reader.array.VarBinArray; import io.github.dfa1.vortex.reader.decode.ArrayNode; @@ -67,7 +66,7 @@ void accepts_binaryDtype_returnsTrue() { void accepts_primitiveDtype_returnsFalse() { // Given // When - boolean result = ENCODER.accepts(new DType.Primitive(PType.I64, false)); + boolean result = ENCODER.accepts(DType.I64); // Then assertThat(result).isFalse(); diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/VariantEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/VariantEncodingEncoderTest.java index 34748826..fff9ce8d 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/VariantEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/VariantEncodingEncoderTest.java @@ -20,7 +20,7 @@ class VariantEncodingEncoderTest { private static final VariantEncodingEncoder SUT = new VariantEncodingEncoder(); - private static final DType.Variant VARIANT = new DType.Variant(false); + private static final DType.Variant VARIANT = DType.VARIANT; private static Scalar i32Scalar(long value) { // Inner typed scalar carrying its own i32 dtype, wrapped as a variant value diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ZigZagEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ZigZagEncodingEncoderTest.java index d797f1df..b9f31755 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ZigZagEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ZigZagEncodingEncoderTest.java @@ -113,7 +113,7 @@ void accepts_unsignedOrNonPrimitive_false() { // Given / When / Then assertThat(ENCODER.accepts(DTypes.U32)).isFalse(); assertThat(ENCODER.accepts(DTypes.F64)).isFalse(); - assertThat(ENCODER.accepts(new DType.Utf8(false))).isFalse(); + assertThat(ENCODER.accepts(DType.UTF8)).isFalse(); } @Nested diff --git a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ZstdEncodingEncoderTest.java b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ZstdEncodingEncoderTest.java index e2f1895e..cc3eedb1 100644 --- a/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ZstdEncodingEncoderTest.java +++ b/writer/src/test/java/io/github/dfa1/vortex/writer/encode/ZstdEncodingEncoderTest.java @@ -88,7 +88,7 @@ void encode_emptyArray_roundTrips() { @Test void encode_unsupportedDtype_throwsVortexException() { - assertThatThrownBy(() -> ENCODER.encode(new DType.Null(false), null, EncodeTestHelper.testCtx())) + assertThatThrownBy(() -> ENCODER.encode(DType.NULL, null, EncodeTestHelper.testCtx())) .isInstanceOf(VortexException.class); } } @@ -115,7 +115,7 @@ private static DecodeContext makeDictCtx( private static DecodeContext makeNullableCtx( byte[] meta, DType dtype, long n, boolean[] validityBits, byte[]... compressedFrames ) { - EncodeResult validityResult = BOOL_ENCODER.encode(new DType.Bool(false), validityBits, EncodeTestHelper.testCtx()); + EncodeResult validityResult = BOOL_ENCODER.encode(DType.BOOL, validityBits, EncodeTestHelper.testCtx()); EncodeNode remappedValidity = EncodeNode.remapBufferIndices( validityResult.rootNode(), compressedFrames.length);