final Map<String, KeysAndAttributes> requestItems,
final Map<String, List<Object>> resultSet,
final DynamoDBMapperConfig config) {
BatchGetItemResult batchGetItemResult = null;
BatchGetItemRequest batchGetItemRequest = new BatchGetItemRequest()
.withRequestMetricCollector(config.getRequestMetricCollector());
batchGetItemRequest.setRequestItems(requestItems);
int retries = 0;
int noOfItemsInOriginalRequest = requestItems.size();
do {
if ( batchGetItemResult != null ) {
retries++;
if (noOfItemsInOriginalRequest == batchGetItemResult
.getUnprocessedKeys().size()){
pauseExponentially(retries);
if (retries > BATCH_GET_MAX_RETRY_COUNT_ALL_KEYS) {
throw new AmazonClientException(
"Batch Get Item request to server hasn't received any data. Please try again later.");
}
}
batchGetItemRequest.setRequestItems(batchGetItemResult.getUnprocessedKeys());
}
batchGetItemResult = db.batchGetItem(batchGetItemRequest);
Map<String, List<Map<String, AttributeValue>>> responses = batchGetItemResult.getResponses();
for ( String tableName : responses.keySet() ) {