diff --git a/java/vortex-spark/src/main/java/dev/vortex/spark/write/VortexDataWriter.java b/java/vortex-spark/src/main/java/dev/vortex/spark/write/VortexDataWriter.java index dfadd320a43..48f47284550 100644 --- a/java/vortex-spark/src/main/java/dev/vortex/spark/write/VortexDataWriter.java +++ b/java/vortex-spark/src/main/java/dev/vortex/spark/write/VortexDataWriter.java @@ -192,9 +192,6 @@ private void writeBatch() throws IOException { vectorSchemaRoot.setRowCount(batchRows.size()); // Export via Arrow C Data Interface and write to Vortex - for (FieldVector vector : vectorSchemaRoot.getFieldVectors()) { - bytesWritten += vector.getBufferSize(); - } try (ArrowArray arrowArray = ArrowArray.allocateNew(allocator); ArrowSchema arrowSchema = ArrowSchema.allocateNew(allocator)) { Data.exportVectorSchemaRoot(allocator, vectorSchemaRoot, null, arrowArray, arrowSchema); @@ -327,10 +324,10 @@ public WriterCommitMessage commit() throws IOException { writeBatch(); } - // Close the Vortex writer to finalize the file + // Finalize the file; the summary carries its physical size if (vortexWriter != null) { try { - vortexWriter.close(); + bytesWritten = vortexWriter.finish().fileSize(); } finally { vortexWriter = null; // Always null out the reference }