Use the writeRecords()
method to write an incremental set of records to the Record Store.
To perform an incremental write:
Create a connection to a Record Store server by calling the
create()
method:RecordStoreLocator locator = RecordStoreLocator.create(host, port, instanceName);
Create a Record Store instance by calling the
getService()
method:RecordStore recordStore = locator.getService();
Start a
READ_WRITE
transaction by calling thestartTransaction()
method:TransactionId transactionId = recordStore.startTransaction(TransactionType.READ_WRITE);
Write a batch of records by calling the
writeRecords()
method:recordStore.writeRecords(recordBatch1);
Repeat this step to write other batches of records to the Record Store.
Commit the transaction by calling the
commitTransaction()
method:recordStore.commitTransaction(transactionId);
Example 5. Example of performing an incremental write
RecordStoreLocator locator = RecordStoreLocator.create(host, port, instanceName); RecordStore recordStore = locator.getService(); TransactionId transactionId = recordStore.startTransaction(TransactionType.READ_WRITE); recordStore.writeRecords(recordBatch1); recordStore.writeRecords(recordBatch2); recordStore.commitTransaction(transactionId);