Skip to content

Commit 0e12a45

Browse files
dfa1claude
andcommitted
test(integration): add cascading OHLC cross-compat test (Java writes, Rust reads)
Writes 10k OHLC rows with WriteOptions.cascading(3) — exercises ALP→bitpacked for F64 columns and FOR→bitpacked for I64 — then reads back with the Rust JNI reader and asserts all values round-trip correctly. JNI reader returns cascaded chunks in a different order than written, so assertions use containsExactlyInAnyOrder (value correctness, not ordering). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 66e1614 commit 0e12a45

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

integration/src/test/java/io/github/dfa1/vortex/integration/JavaWritesRustReadsIntegrationTest.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.nio.file.Path;
2626
import java.nio.file.StandardOpenOption;
2727
import java.util.ArrayList;
28+
import java.util.Arrays;
2829
import java.util.List;
2930
import java.util.Map;
3031

@@ -41,6 +42,18 @@ class JavaWritesRustReadsIntegrationTest {
4142
new DType.Primitive(PType.F64, false)),
4243
false);
4344

45+
private static final DType.Struct OHLC_SCHEMA = new DType.Struct(
46+
List.of("date", "symbol", "open", "high", "low", "close", "volume"),
47+
List.of(
48+
new DType.Primitive(PType.I32, false),
49+
new DType.Utf8(false),
50+
new DType.Primitive(PType.F64, false),
51+
new DType.Primitive(PType.F64, false),
52+
new DType.Primitive(PType.F64, false),
53+
new DType.Primitive(PType.F64, false),
54+
new DType.Primitive(PType.I64, false)),
55+
false);
56+
4457
static {
4558
NativeLoader.loadJni();
4659
}
@@ -93,6 +106,38 @@ private static double[] readDoubleColumn(Path file, String column) throws IOExce
93106

94107
// ── JNI read helpers ──────────────────────────────────────────────────────
95108

109+
@Test
110+
void javaWriter_jniReader_cascading_ohlc(@TempDir Path tmp) throws IOException {
111+
// Given — OHLC data written with cascading(3): exercises ALP→FOR→bitpacked chain
112+
Path file = tmp.resolve("java_cascade_ohlc.vtx");
113+
List<OhlcGenerator.OhlcBatch> batches = OhlcGenerator.generate(10_000, 1_000);
114+
115+
try (var ch = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
116+
var sut = VortexWriter.create(ch, OHLC_SCHEMA, WriteOptions.cascading(3))) {
117+
for (OhlcGenerator.OhlcBatch b : batches) {
118+
sut.writeChunk(Map.of(
119+
"date", b.dates(),
120+
"symbol", b.symbols(),
121+
"open", b.open(),
122+
"high", b.high(),
123+
"low", b.low(),
124+
"close", b.close(),
125+
"volume", b.volume()));
126+
}
127+
}
128+
129+
// When
130+
long[] volumes = readLongColumn(file, "volume");
131+
double[] closes = readDoubleColumn(file, "close");
132+
133+
// Then — JNI reader may return chunks in a different order for cascaded files;
134+
// verify all values round-trip correctly regardless of partition order.
135+
long[] expectedVolumes = batches.stream().flatMapToLong(b -> Arrays.stream(b.volume())).toArray();
136+
double[] expectedCloses = batches.stream().flatMapToDouble(b -> Arrays.stream(b.close())).toArray();
137+
assertThat(volumes).containsExactlyInAnyOrder(expectedVolumes);
138+
assertThat(closes).containsExactlyInAnyOrder(expectedCloses);
139+
}
140+
96141
@Test
97142
void javaWriter_jniReader_singleChunk(@TempDir Path tmp) throws IOException {
98143
// Given

0 commit comments

Comments
 (0)