diff --git a/java/vortex-jni/src/main/java/dev/vortex/api/VortexWriter.java b/java/vortex-jni/src/main/java/dev/vortex/api/VortexWriter.java index a62243aab07..e59a7972587 100644 --- a/java/vortex-jni/src/main/java/dev/vortex/api/VortexWriter.java +++ b/java/vortex-jni/src/main/java/dev/vortex/api/VortexWriter.java @@ -125,6 +125,23 @@ public synchronized long bytesWritten() { return bytesWritten; } + /** + * Return the number of uncompressed bytes accepted by the writer but not yet written to the sink. + * + *
Together with {@link #bytesWritten()}, this lets callers estimate the in-progress file size: bytes that
+ * reached the sink are already compressed, while buffered bytes are still uncompressed and will shrink by roughly
+ * the file's observed compression ratio once flushed. After {@link #finish()}, this is zero.
+ */
+ public synchronized long bufferedBytes() {
+ if (summary != null) {
+ return 0;
+ }
+ Preconditions.checkState(!closed.get(), "writer closed without a write summary");
+ long bufferedBytes = NativeWriter.bufferedBytes(pointer);
+ Preconditions.checkState(bufferedBytes >= 0, "native writer returned an invalid buffered byte count");
+ return bufferedBytes;
+ }
+
/**
* Flush pending batches, finalize the file, and return its statistics and physical sizes.
*
diff --git a/java/vortex-jni/src/main/java/dev/vortex/jni/NativeWriter.java b/java/vortex-jni/src/main/java/dev/vortex/jni/NativeWriter.java
index 4f61a381438..f0c0a7471ad 100644
--- a/java/vortex-jni/src/main/java/dev/vortex/jni/NativeWriter.java
+++ b/java/vortex-jni/src/main/java/dev/vortex/jni/NativeWriter.java
@@ -37,6 +37,9 @@ public static native long create(
/** Number of bytes successfully written to the underlying sink so far. */
public static native long bytesWritten(long writerPointer);
+ /** Number of uncompressed bytes buffered by the native writer that have not yet reached the sink. */
+ public static native long bufferedBytes(long writerPointer);
+
/** Flush and close the writer. Must be called exactly once. */
public static native void close(long writerPointer);
diff --git a/vortex-jni/src/writer.rs b/vortex-jni/src/writer.rs
index 53649eef4ab..ebfadc4727a 100644
--- a/vortex-jni/src/writer.rs
+++ b/vortex-jni/src/writer.rs
@@ -47,6 +47,7 @@ use vortex::error::VortexResult;
use vortex::error::vortex_err;
use vortex::expr::stats::Stat;
use vortex::expr::stats::StatsProvider;
+use vortex::file::ALLOWED_ENCODINGS;
use vortex::file::CountingVortexWrite;
use vortex::file::WriteOptionsSessionExt;
use vortex::file::WriteStrategyBuilder;
@@ -58,6 +59,7 @@ use vortex::io::object_store::ObjectStoreWrite;
use vortex::io::runtime::BlockingRuntime;
use vortex::io::runtime::Task;
use vortex::io::session::RuntimeSessionExt;
+use vortex::layout::LayoutStrategy;
use vortex::session::VortexSession;
use vortex::utils::aliases::hash_map::HashMap;
use vortex_arrow::ArrowSessionExt;
@@ -99,21 +101,18 @@ fn resolve_store(
}
}
-fn write_options_for_schema(
- session: &VortexSession,
- write_schema: &DType,
-) -> vortex::file::VortexWriteOptions {
+fn write_strategy_for_schema(write_schema: &DType) -> Arc