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