Performing a baseline write

Create a deleteAllRecord, then use the writeRecords() method to write a baseline set of records to the Record Store.

To perform a baseline write:

  1. Create a connection to a Record Store server by calling the create() method and passing in a ServiceAddress object and a Record Store Instance name:
    ServiceAddress address = new ServiceAddress(host, port, contextPath); 
    RecordStoreLocator locator = RecordStoreLocator.create(address, instanceName);
  2. Create a Record Store instance by calling the getService() method:
    RecordStore recordStore = locator.getService();
  3. Start a READ_WRITE transaction by calling the startTransaction() method:
    TransactionId transactionId = recordStore.startTransaction(TransactionType.READ_WRITE);
  4. Create a new record called deleteAllRecord with a property value of DELETE:
    Record deleteAllRecord = new Record();
    
    deleteAllRecord.addPropertyValue(new PropertyValue("Endeca.Action", "DELETE"));
  5. Add deleteAllRecord as the first record in a record batch:
    recordBatch1.addFirst(deleteAllRecord);
  6. Write the first batch of records by calling the writeRecords() method:
    recordStore.writeRecords(recordBatch1);
    Repeat this step to write other batches of records to the Record Store.
  7. Commit the transaction by calling the commitTransaction() method:
    recordStore.commitTransaction(transactionId);

Example of performing a baseline write

ServiceAddress address = new ServiceAddress(host, port, contextPath); 
RecordStoreLocator locator = RecordStoreLocator.create(address, instanceName);

RecordStore recordStore = locator.getService();

TransactionId transactionId = recordStore.startTransaction(TransactionType.READ_WRITE);

Record deleteAllRecord = new Record();

deleteAllRecord.addPropertyValue(new PropertyValue("Endeca.Action", "DELETE"));

recordBatch1.addFirst(deleteAllRecord);

recordStore.writeRecords(recordBatch1);

recordStore.writeRecords(recordBatch2);

recordStore.commitTransaction(transactionId);