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.
This writer converts Spark's internal row format to Arrow vectors and writes them to a Vortex file using the Vortex writer API.
-
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.Rows are batched and converted to Arrow format before writing.
- 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
-