From 961d17f4599f67198e5c3c132f0842f05a828061 Mon Sep 17 00:00:00 2001 From: jackylee Date: Wed, 26 Aug 2026 08:22:33 +0800 Subject: [PATCH] docs(java): replace the Java API example that no longer compiles The example imported dev.vortex.api.File and dev.vortex.api.Array, both removed in #7527. The page predates that removal and offers no pointer to the API that replaced them, so the first thing a JNI user copies fails to compile. Rewritten around the read path that exists today: Session, DataSource.open, scan, and Partition.scanArrow, following the loop the vortex-jni tests use. Signed-off-by: jackylee --- docs/api/java/index.rst | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/docs/api/java/index.rst b/docs/api/java/index.rst index 9cb815a0aba..9d19f16d7e7 100644 --- a/docs/api/java/index.rst +++ b/docs/api/java/index.rst @@ -46,14 +46,31 @@ Here's a basic example of using the Vortex Java API to read a Vortex file: .. code-block:: java - import dev.vortex.api.File; - import dev.vortex.api.Array; - - // Open a Vortex file - File vortexFile = File.open("path/to/file.vortex"); - - // Read arrays from the file - Array array = vortexFile.readArray(); - - // Work with the array data - System.out.println("Array length: " + array.getLength()); + import dev.vortex.api.DataSource; + import dev.vortex.api.Partition; + import dev.vortex.api.Scan; + import dev.vortex.api.ScanOptions; + import dev.vortex.api.Session; + import dev.vortex.arrow.ArrowAllocation; + import org.apache.arrow.memory.BufferAllocator; + import org.apache.arrow.vector.VectorSchemaRoot; + import org.apache.arrow.vector.ipc.ArrowReader; + + BufferAllocator allocator = ArrowAllocation.rootAllocator(); + Session session = Session.create(); + DataSource source = DataSource.open(session, "path/to/file.vortex"); + + // A scan yields one partition per chunk of the file. + Scan scan = source.scan(ScanOptions.of()); + while (scan.hasNext()) { + Partition partition = scan.next(); + try (ArrowReader reader = partition.scanArrow(allocator)) { + while (reader.loadNextBatch()) { + VectorSchemaRoot batch = reader.getVectorSchemaRoot(); + System.out.println("read " + batch.getRowCount() + " rows"); + } + } + } + +Data crosses the JNI boundary as Arrow record batches, so the buffers stay in native memory and +are read from Java through the Arrow C Data Interface.