public class DefaultTableStoreWriter extends Object implements TableStoreWriter
| 构造器和说明 |
|---|
DefaultTableStoreWriter(AsyncClientInterface ots,
String tableName,
WriterConfig config,
TableStoreCallback<RowChange,ConsumedCapacity> callback,
Executor executor) |
DefaultTableStoreWriter(String endpoint,
ServiceCredentials credentials,
String instanceName,
String tableName,
WriterConfig config,
ClientConfiguration cc,
TableStoreCallback<RowChange,RowWriteResult> resultCallback) |
DefaultTableStoreWriter(String endpoint,
ServiceCredentials credentials,
String instanceName,
String tableName,
WriterConfig config,
TableStoreCallback<RowChange,RowWriteResult> resultCallback) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addRowChange(List<RowChange> rowChanges,
List<RowChange> dirtyRows)
Batch write rows to the local buffer.
|
void |
addRowChange(RowChange rowChange)
Add a row of data to the local buffer.
|
Future<WriterResult> |
addRowChangeWithFuture(List<RowChange> rowChanges)
Batch write rows to the local buffer.
|
Future<WriterResult> |
addRowChangeWithFuture(RowChange rowChange)
The interface function is the same as
TableStoreWriter.addRowChange(com.alicloud.openservices.tablestore.model.RowChange),
but it will return a Future of the write result, indicating the success or failure status of writing this row. |
void |
close()
Closes the TableStoreWriter.
|
void |
flush()
Actively flush the data in the buffer.
|
TableStoreCallback<RowChange,ConsumedCapacity> |
getCallback() |
TableStoreCallback<RowChange,RowWriteResult> |
getResultCallback()
Get the set Callback.
|
WriterConfig |
getWriterConfig()
Get the configuration of the limit item.
|
WriterStatistics |
getWriterStatistics()
Get the statistical information during data import.
|
void |
setCallback(TableStoreCallback<RowChange,ConsumedCapacity> callback) |
void |
setResultCallback(TableStoreCallback<RowChange,RowWriteResult> resultCallback)
Set Callback, which will provide feedback when data writing succeeds or fails.
|
void |
startFlushTimer(int flushInterval) |
boolean |
tryAddRowChange(RowChange rowChange)
Same with
TableStoreWriter.addRowChange(RowChange), but it won't be blocked if the buffer is full. |
public DefaultTableStoreWriter(AsyncClientInterface ots, String tableName, WriterConfig config, TableStoreCallback<RowChange,ConsumedCapacity> callback, Executor executor)
public DefaultTableStoreWriter(String endpoint, ServiceCredentials credentials, String instanceName, String tableName, WriterConfig config, TableStoreCallback<RowChange,RowWriteResult> resultCallback)
public DefaultTableStoreWriter(String endpoint, ServiceCredentials credentials, String instanceName, String tableName, WriterConfig config, ClientConfiguration cc, TableStoreCallback<RowChange,RowWriteResult> resultCallback)
public void addRowChange(RowChange rowChange)
TableStoreWriterWriterConfig.maxPKColumnSize and WriterConfig.maxAttrColumnSize.
- Whether the number of attribute columns in this row exceeds WriterConfig.maxColumnsCount.
- Whether the size of this row exceeds WriterConfig.maxBatchSize.
- Whether there are any column names in the attribute columns that are the same as those in the primary key columns.
If the data is determined to be dirty before being written to the buffer, this portion of the data will not trigger a CallBack invocation.
These checks introduce additional CPU consumption on the SDK side, but they are necessary to reduce unnecessary RPC overhead and prevent dirty data from contaminating rows in the same batch write operation.
Note: If the buffer is full, this operation will be blocked.
If the row is judged to be dirty data, this interface will throw a ClientException.addRowChange 在接口中 TableStoreWriterrowChange - The row to be writtenpublic Future<WriterResult> addRowChangeWithFuture(RowChange rowChange)
TableStoreWriterTableStoreWriter.addRowChange(com.alicloud.openservices.tablestore.model.RowChange),
but it will return a Future of the write result, indicating the success or failure status of writing this row.addRowChangeWithFuture 在接口中 TableStoreWriterrowChange - The row to be written.public boolean tryAddRowChange(RowChange rowChange)
TableStoreWriterTableStoreWriter.addRowChange(RowChange), but it won't be blocked if the buffer is full.tryAddRowChange 在接口中 TableStoreWriterpublic void startFlushTimer(int flushInterval)
public void addRowChange(List<RowChange> rowChanges, List<RowChange> dirtyRows) throws ClientException
TableStoreWriterTableStoreWriter.addRowChange(RowChange).
If there is any dirty data in the rows being written in the batch, this function will throw a ClientException,
and all dirty data will be written to dirtyRows.addRowChange 在接口中 TableStoreWriterrowChanges - Rows for batch writingdirtyRows - List used to return the dirty dataClientException - if there is any dirty datapublic Future<WriterResult> addRowChangeWithFuture(List<RowChange> rowChanges) throws ClientException
TableStoreWriterTableStoreWriter.addRowChange(RowChange); dirty data will be directly updated in the WriterResponse statistics.addRowChangeWithFuture 在接口中 TableStoreWriterrowChanges - Rows for batch writingClientException - If there is dirty datapublic void setCallback(TableStoreCallback<RowChange,ConsumedCapacity> callback)
public void setResultCallback(TableStoreCallback<RowChange,RowWriteResult> resultCallback)
TableStoreWriterAsyncClientInterface,
where the callback corresponds one-to-one with each request and can be independent.
However, the Callback here corresponds to RowChange, and all RowChanges share this callback.setResultCallback 在接口中 TableStoreWriterpublic TableStoreCallback<RowChange,ConsumedCapacity> getCallback()
getCallback 在接口中 TableStoreWriterTableStoreWriter.getResultCallback()public TableStoreCallback<RowChange,RowWriteResult> getResultCallback()
TableStoreWritergetResultCallback 在接口中 TableStoreWriterpublic WriterConfig getWriterConfig()
TableStoreWritergetWriterConfig 在接口中 TableStoreWriterpublic WriterStatistics getWriterStatistics()
TableStoreWritergetWriterStatistics 在接口中 TableStoreWriterpublic void flush()
throws ClientException
TableStoreWriterflush 在接口中 TableStoreWriterClientExceptionpublic void close()
TableStoreWriterTableStoreWriter.addRowChange(com.alicloud.openservices.tablestore.model.RowChange) is called to write data into the buffer during or after the close process, there is no guarantee that this part of the data will be written to TableStore.
The mutual exclusion between addRowChange and close operations must be ensured by the caller. It is essential to ensure that no other threads continue to use this writer before calling close; otherwise, unexpected behavior may occur.close 在接口中 TableStoreWriterCopyright © 2025. All Rights Reserved.