ベースライン書込みの実行

deleteAllRecordを作成し、次にwriteRecords()メソッドを使用してレコードのベースライン・セットをレコード・ストアに書き込みます。

ベースライン書込みを実行するには:

  1. create()メソッドをコールし、ServiceAddressオブジェクトおよびレコード・ストア・インスタンス名を渡して、レコード・ストア・サーバーへの接続を作成します。
    ServiceAddress address = new ServiceAddress(host, port, contextPath); 
    RecordStoreLocator locator = RecordStoreLocator.create(address, instanceName);
  2. getService()メソッドをコールして、レコード・ストア・インスタンスを作成します。
    RecordStore recordStore = locator.getService();
  3. startTransaction()メソッドをコールして、READ_WRITEトランザクションを開始します。
    TransactionId transactionId = recordStore.startTransaction(TransactionType.READ_WRITE);
  4. プロパティ値DELETEを指定してdeleteAllRecordという名前の新しいレコードを作成します。
    Record deleteAllRecord = new Record();
    
    deleteAllRecord.addPropertyValue(new PropertyValue("Endeca.Action", "DELETE"));
  5. レコード・バッチに最初のレコードとしてdeleteAllRecordを追加します。
    recordBatch1.addFirst(deleteAllRecord);
  6. writeRecords()メソッドをコールして、レコードの最初のバッチを書き込みます。
    recordStore.writeRecords(recordBatch1);
    この手順を繰り返して、レコードの他のバッチをレコード・ストアに書き込みます。
  7. commitTransaction()メソッドをコールして、トランザクションをコミットします。
    recordStore.commitTransaction(transactionId);

ベースライン書込みの実行例

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);