Package dev.vortex.spark.write
Class VortexOutputWriter
java.lang.Object
org.apache.spark.sql.execution.datasources.OutputWriter
dev.vortex.spark.write.VortexOutputWriter
public final class VortexOutputWriter
extends org.apache.spark.sql.execution.datasources.OutputWriter
Writes Spark InternalRow data to a Vortex file.
Each row is appended straight into a batch of Arrow vectors as it arrives, and a full batch is handed to the Vortex writer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringOption sizing the row batch converted to Arrow and handed to Vortex at a time.static final StringOption sizing the write batch for Vortex alone, overriding "batch.size". -
Constructor Summary
ConstructorsConstructorDescriptionVortexOutputWriter(String filePath, org.apache.spark.sql.types.StructType schema, VortexOptions options, dev.vortex.io.NativeWritable writable) Creates a writer for the task path assigned by Spark's commit protocol. -
Method Summary
-
Field Details
-
BATCH_SIZE_OPTION
Option sizing the row batch converted to Arrow and handed to Vortex at a time.- See Also:
-
WRITE_BATCH_SIZE_OPTION
Option sizing the write batch for Vortex alone, overriding "batch.size".- See Also:
-
-
Constructor Details
-
VortexOutputWriter
public VortexOutputWriter(String filePath, org.apache.spark.sql.types.StructType schema, VortexOptions options, dev.vortex.io.NativeWritable writable) Creates a writer for the task path assigned by Spark's commit protocol.- Parameters:
filePath- the path where the Vortex file will be writtenschema- the schema of the data to writeoptions- additional write options
-
-
Method Details
-
write
public void write(org.apache.spark.sql.catalyst.InternalRow row) Writes a single row to the Vortex file.The row is consumed before this method returns: Spark reuses the row object for the next call.
- Specified by:
writein classorg.apache.spark.sql.execution.datasources.OutputWriter- Parameters:
row- the row to write
-
close
public void close()Flushes the last batch and finalizes the file.After a failed
write(org.apache.spark.sql.catalyst.InternalRow), or in a task that has already failed, the last batch is dropped because the file is never committed. In both cases this releases everything and logs what fails instead of throwing, because Spark's abort closes a task's writers one after another and stops at the first that throws.- Specified by:
closein classorg.apache.spark.sql.execution.datasources.OutputWriter
-
path
- Specified by:
pathin classorg.apache.spark.sql.execution.datasources.OutputWriter
-