if ( !requestItems.containsKey(tableName) ) {
requestItems.put(tableName, new LinkedList<WriteRequest>());
}
requestItems.get(tableName).add(
new WriteRequest().withPutRequest(new PutRequest().withItem(transformAttributes(clazz, attributeValues))));
}
for ( Object toDelete : objectsToDelete ) {
Class<?> clazz = toDelete.getClass();
String tableName = getTableName(clazz, config);
Method hashKeyGetter = reflector.getHashKeyGetter(clazz);
AttributeValue hashKeyElement = getHashKeyElement(safeInvoke(hashKeyGetter, toDelete), hashKeyGetter);
AttributeValue rangeKeyElement = null;
Method rangeKeyGetter = reflector.getRangeKeyGetter(clazz);
if ( rangeKeyGetter != null ) {
rangeKeyElement = getRangeKeyElement(safeInvoke(rangeKeyGetter, toDelete), rangeKeyGetter);
}
Key objectKey = new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement);
if ( !requestItems.containsKey(tableName) ) {
requestItems.put(tableName, new LinkedList<WriteRequest>());
}
requestItems.get(tableName).add(
new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(objectKey)));
}
// Break into chunks of 25 items and make service requests to DynamoDB
while ( !requestItems.isEmpty() ) {
HashMap<String, List<WriteRequest>> batch = new HashMap<String, List<WriteRequest>>();
int i = 0;
Iterator<Entry<String, List<WriteRequest>>> tableIter = requestItems.entrySet().iterator();
while ( tableIter.hasNext() && i < 25 ) {
Entry<String, List<WriteRequest>> tableRequest = tableIter.next();
batch.put(tableRequest.getKey(), new LinkedList<WriteRequest>());
Iterator<WriteRequest> writeRequestIter = tableRequest.getValue().iterator();
while ( writeRequestIter.hasNext() && i++ < 25 ) {
WriteRequest writeRequest = writeRequestIter.next();
batch.get(tableRequest.getKey()).add(writeRequest);
writeRequestIter.remove();
}
// If we've processed all the write requests for this table,