public class TableArrowWriter extends Object implements ArrowWriter
It serializes and caches the VectorSchemaRoot batches written by the user in memory.
When the flush() method is called, it packages all cached batch data into a single
Arrow IPC Stream format request and sends it over the network at once.
This design ensures the safety of reusable VectorSchemaRoot objects for users, but consumes more memory to cache the data.
Note: This class is not thread-safe for concurrent write operations.
| Modifier and Type | Method and Description |
|---|---|
List<Blob> |
batchUploadBlob(long columnId,
List<byte[]> dataList)
Uploads multiple blobs in a single batch request.
|
long |
bytesWritten() |
void |
close() |
org.apache.arrow.vector.VectorSchemaRoot |
createVectorSchemaRoot()
Creates a new VectorSchemaRoot instance that is compatible with this writer.
|
void |
flush() |
org.apache.arrow.memory.BufferAllocator |
getAllocator() |
RecordWriter |
getAsRecordWriter(long rowCountPerBatch) |
long |
getCachedSize() |
String |
getLastRequestId()
Returns the request ID of the last successful write (flush).
|
WriteSchema |
getWriteSchema() |
Blob |
uploadBlob(long columnId,
InputStream data) |
void |
writeBatch(org.apache.arrow.vector.VectorSchemaRoot root) |
public void writeBatch(org.apache.arrow.vector.VectorSchemaRoot root)
writeBatch in interface ArrowWriterpublic org.apache.arrow.vector.VectorSchemaRoot createVectorSchemaRoot()
The caller is responsible for managing the lifecycle of the returned VectorSchemaRoot,
specifically by calling VectorSchemaRoot.close() in a try-with-resources block
to prevent memory leaks.
public long bytesWritten()
bytesWritten in interface ArrowWriterpublic void flush()
public Blob uploadBlob(long columnId, InputStream data)
public List<Blob> batchUploadBlob(long columnId, List<byte[]> dataList)
This is significantly more efficient than calling uploadBlob(long, InputStream)
repeatedly, as all blobs are uploaded in a single HTTP request instead of N individual requests.
Note: This method is not supported for tables with primary keys (Delta Tables).
columnId - the column ID of the BLOB columndataList - a list of byte arrays, each containing the raw data for one blobBlob references in the same order as the input listClientException - if called on a Delta Table or if the server response is inconsistentpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic WriteSchema getWriteSchema()
public String getLastRequestId()
public org.apache.arrow.memory.BufferAllocator getAllocator()
public RecordWriter getAsRecordWriter(long rowCountPerBatch)
getAsRecordWriter in interface ArrowWriterpublic long getCachedSize()
Copyright © 2026 Alibaba Cloud Computing. All rights reserved.