private void processBatchGetRequest(
            final Map<String, Class<?>> classesByTableName,
            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);

        BatchLoadRetryStrategy batchLoadStrategy = config.getBatchLoadRetryStrategy();

        BatchLoadContext batchLoadContext = new BatchLoadContext(batchGetItemRequest);

        int retries = 0;

        do {
            if ( batchGetItemResult != null ) {
                retries++;
                batchLoadContext.setRetriesAttempted(retries);
                if (!isNullOrEmpty(batchGetItemResult.getUnprocessedKeys())) {
                    pause(batchLoadStrategy.getDelayBeforeNextRetry(batchLoadContext));
                    batchGetItemRequest.setRequestItems(
                        batchGetItemResult.getUnprocessedKeys());
                }
            }

            batchGetItemResult = db.batchGetItem(
                    applyBatchOperationUserAgent(batchGetItemRequest));

            Map<String, List<Map<String, AttributeValue>>> responses = batchGetItemResult.getResponses();
            for ( String tableName : responses.keySet() ) {
                List<Object> objects = null;
                if ( resultSet.get(tableName) != null ) {
                    objects = resultSet.get(tableName);
                } else {
                    objects = new LinkedList<Object>();
                }

                Class<?> clazz = classesByTableName.get(tableName);

                for ( Map<String, AttributeValue> item : responses.get(tableName) ) {
                    AttributeTransformer.Parameters<?> parameters =
                        toParameters(item, clazz, tableName, config);
                    objects.add(privateMarshallIntoObject(parameters));
                }

                resultSet.put(tableName, objects);
            }

            batchLoadContext.setBatchGetItemResult(batchGetItemResult);

            // the number of unprocessed keys and  Batch Load Strategy will drive the number of retries
        } while ( batchLoadStrategy.shouldRetry(batchLoadContext) );

        if (!isNullOrEmpty(batchGetItemResult.getUnprocessedKeys())) {
            throw new BatchGetItemException(
                    "The BatchGetItemResult has unprocessed keys after max retry attempts. Catch the BatchGetItemException to get the list of unprocessed keys.",
                    batchGetItemResult.getUnprocessedKeys(), resultSet);
        }
    }
private void processBatchGetRequest ( final Map < String , Class < ? > > classesByTableName , 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 ) ; BatchLoadRetryStrategy batchLoadStrategy = config . getBatchLoadRetryStrategy ( ) ; BatchLoadContext batchLoadContext = new BatchLoadContext ( batchGetItemRequest ) ; int retries = 0 ; do { if ( batchGetItemResult != null ) { retries ++ ; batchLoadContext . setRetriesAttempted ( retries ) ; if ( ! isNullOrEmpty ( batchGetItemResult . getUnprocessedKeys ( ) ) ) { pause ( batchLoadStrategy . getDelayBeforeNextRetry ( batchLoadContext ) ) ; batchGetItemRequest . setRequestItems ( batchGetItemResult . getUnprocessedKeys ( ) ) ; } } batchGetItemResult = db . batchGetItem ( applyBatchOperationUserAgent ( batchGetItemRequest ) ) ; Map < String , List < Map < String , AttributeValue > > > responses = batchGetItemResult . getResponses ( ) ; for ( String tableName : responses . keySet ( ) ) { List < Object > objects = null ; if ( resultSet . get ( tableName ) != null ) { objects = resultSet . get ( tableName ) ; } else { objects = new LinkedList < Object > ( ) ; } Class < ? > clazz = classesByTableName . get ( tableName ) ; for ( Map < String , AttributeValue > item : responses . get ( tableName ) ) { AttributeTransformer . Parameters < ? > parameters = toParameters ( item , clazz , tableName , config ) ; objects . add ( privateMarshallIntoObject ( parameters ) ) ; } resultSet . put ( tableName , objects ) ; } batchLoadContext . setBatchGetItemResult ( batchGetItemResult ) ; } while ( batchLoadStrategy . shouldRetry ( batchLoadContext ) ) ; if ( ! isNullOrEmpty ( batchGetItemResult . getUnprocessedKeys ( ) ) ) { throw new BatchGetItemException ( "The BatchGetItemResult has unprocessed keys after max retry attempts. Catch the BatchGetItemException to get the list of unprocessed keys." , batchGetItemResult . getUnprocessedKeys ( ) , resultSet ) ; } }
@param config never null