protected static <P extends ParaObject> void batchGet(Map<String, KeysAndAttributes> kna, Map<String, P> results) {
		if (kna == null || kna.isEmpty() || results == null) {
			return;
		}
		try {
			BatchGetItemResult result = getClient().batchGetItem(new BatchGetItemRequest().
					withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL).withRequestItems(kna));
			if (result == null) {
				return;
			}

			List<Map<String, AttributeValue>> res = result.getResponses().get(kna.keySet().iterator().next());

			for (Map<String, AttributeValue> item : res) {
				P obj = fromRow(item);
				if (obj != null) {
					results.put(obj.getId(), obj);
				}
			}
			logger.debug("batchGet(): total {}, cc {}", res.size(), result.getConsumedCapacity());

			if (result.getUnprocessedKeys() != null && !result.getUnprocessedKeys().isEmpty()) {
				Thread.sleep(1000);
				logger.warn("{} UNPROCESSED read requests!", result.getUnprocessedKeys().size());
				batchGet(result.getUnprocessedKeys(), results);
			}
		} catch (Exception e) {
			logger.error(null, e);
		}
	}
protected static < P extends ParaObject > void batchGet ( Map < String , KeysAndAttributes > kna , Map < String , P > results ) { if ( kna == null || kna . isEmpty ( ) || results == null ) { return ; } try { BatchGetItemResult result = getClient ( ) . batchGetItem ( new BatchGetItemRequest ( ) . withReturnConsumedCapacity ( ReturnConsumedCapacity . TOTAL ) . withRequestItems ( kna ) ) ; if ( result == null ) { return ; } List < Map < String , AttributeValue > > res = result . getResponses ( ) . get ( kna . keySet ( ) . iterator ( ) . next ( ) ) ; for ( Map < String , AttributeValue > item : res ) { P obj = fromRow ( item ) ; if ( obj != null ) { results . put ( obj . getId ( ) , obj ) ; } } logger . debug ( "batchGet(): total {}, cc {}" , res . size ( ) , result . getConsumedCapacity ( ) ) ; if ( result . getUnprocessedKeys ( ) != null && ! result . getUnprocessedKeys ( ) . isEmpty ( ) ) { Thread . sleep ( 1000 ) ; logger . warn ( "{} UNPROCESSED read requests!" , result . getUnprocessedKeys ( ) . size ( ) ) ; batchGet ( result . getUnprocessedKeys ( ) , results ) ; } } catch ( Exception e ) { logger . error ( null , e ) ; } }
Reads multiple items from DynamoDB, in batch.
@param <P> type of object
@param kna a map of row key->data
@param results a map of ID->ParaObject