Package dev.vortex.spark.write
Class VortexDataWriter
java.lang.Object
dev.vortex.spark.write.VortexDataWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.spark.sql.connector.write.DataWriter<org.apache.spark.sql.catalyst.InternalRow>
public final class VortexDataWriter
extends Object
implements org.apache.spark.sql.connector.write.DataWriter<org.apache.spark.sql.catalyst.InternalRow>, AutoCloseable
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.
-
Constructor Summary
ConstructorsConstructorDescriptionVortexDataWriter
(String filePath, org.apache.spark.sql.types.StructType schema, org.apache.spark.sql.util.CaseInsensitiveStringMap options) Creates a new VortexDataWriter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
Aborts the write operation and cleans up resources.void
close()
Closes the writer and releases resources.org.apache.spark.sql.connector.write.WriterCommitMessage
commit()
Commits the write operation and returns a commit message.void
write
(org.apache.spark.sql.catalyst.InternalRow row) Writes a single row to the Vortex file.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.spark.sql.connector.write.DataWriter
currentMetricsValues
-
Constructor Details
-
VortexDataWriter
public VortexDataWriter(String filePath, org.apache.spark.sql.types.StructType schema, org.apache.spark.sql.util.CaseInsensitiveStringMap options) Creates a new VortexDataWriter.- Parameters:
filePath
- the path where the Vortex file will be writtenschema
- the schema of the data to writeoptions
- additional write options
-
-
Method Details
-
write
Writes a single row to the Vortex file.Rows are batched and converted to Arrow format before writing.
- Specified by:
write
in interfaceorg.apache.spark.sql.connector.write.DataWriter<org.apache.spark.sql.catalyst.InternalRow>
- Parameters:
row
- the row to write- Throws:
IOException
- if writing fails
-
commit
Commits the write operation and returns a commit message.This flushes any remaining rows and closes the Vortex writer.
- Specified by:
commit
in interfaceorg.apache.spark.sql.connector.write.DataWriter<org.apache.spark.sql.catalyst.InternalRow>
- Returns:
- a commit message with file information
- Throws:
IOException
- if commit fails
-
abort
Aborts the write operation and cleans up resources.This deletes any partially written file.
- Specified by:
abort
in interfaceorg.apache.spark.sql.connector.write.DataWriter<org.apache.spark.sql.catalyst.InternalRow>
- Throws:
IOException
- if abort fails
-
close
Closes the writer and releases resources.This method ensures resources are cleaned up even if commit() or abort() were not called, making the class safe for use with try-with-resources.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-