public synchronized BatchWriteItemResult batchWriteItem(BatchWriteItemRequest request) {
BatchWriteItemResult batchWriteItemResult = new BatchWriteItemResult();
HashMap<String, BatchWriteResponse> responses = new HashMap<String, BatchWriteResponse>();
for (String tableName : request.getRequestItems().keySet()) {
BatchWriteResponse batchWriteResponse = new BatchWriteResponse();
List<WriteRequest> writeRequests = request.getRequestItems().get(tableName);
for (WriteRequest writeRequest : writeRequests) {
PutRequest putRequest = writeRequest.getPutRequest();
if (putRequest != null) {
this.tables.get(tableName).putItem(putRequest.getItem());
}
DeleteRequest deleteRequest = writeRequest.getDeleteRequest();
if (deleteRequest != null) {
Key key = deleteRequest.getKey();
if (key != null) {
this.tables.get(tableName).removeItem(key.getHashKeyElement().getS());
}
}
}
batchWriteResponse.setConsumedCapacityUnits(1.0);
responses.put(tableName, batchWriteResponse);
}
batchWriteItemResult.setResponses(responses);
batchWriteItemResult.setUnprocessedItems(new HashMap<String, List<WriteRequest>>());
return batchWriteItemResult;