Java 类com.amazonaws.services.dynamodbv2.model.BatchGetItemRequest 实例源码

项目:Camel    文件:AmazonDDBClientMock.java   
@SuppressWarnings("unchecked")
@Override
public BatchGetItemResult batchGetItem(BatchGetItemRequest batchGetItemRequest) {
    this.batchGetItemRequest = batchGetItemRequest;
    Map<String, List<Map<String, AttributeValue>>> responseMap = new HashMap<String, List<Map<String, AttributeValue>>>();
    List<Map<String, AttributeValue>> p = new ArrayList<Map<String, AttributeValue>>();
    p.add(getAttributes());
    responseMap.put("DOMAIN1", p);
    Map<String, AttributeValue> keysMap = new HashMap<String, AttributeValue>();
    keysMap.put("1", new AttributeValue("UNPROCESSED_KEY"));
    Map<String, KeysAndAttributes> unprocessedKeys = new HashMap<String, KeysAndAttributes>();
    unprocessedKeys.put("DOMAIN1", new KeysAndAttributes().withKeys(keysMap));

    return new BatchGetItemResult()
            .withResponses(responseMap)
            .withUnprocessedKeys(unprocessedKeys);
}
项目:amazon-kinesis-aggregators    文件:DynamoQueryEngine.java   
private List<Map<String, AttributeValue>> batchGetDataByKeys(
        final String tableName, final KeysAndAttributes keys) {
    Map<String, KeysAndAttributes> requestMap = new HashMap<>();
    keys.setConsistentRead(true);
    requestMap.put(tableName, keys);

    BatchGetItemResult result = null;
    try {
        result = dynamoClient.batchGetItem(new BatchGetItemRequest(
                requestMap));
    } catch (AmazonServiceException e) {
        LOG.error(e);
        throw e;
    }

    return result.getResponses().get(this.tableName);
}
项目:AbacusUtil    文件:AsyncDynamoDBExecutor.java   
public CompletableFuture<Map<String, List<Map<String, Object>>>> batchGetItem(final BatchGetItemRequest batchGetItemRequest) {
    return asyncExecutor.execute(new Callable<Map<String, List<Map<String, Object>>>>() {
        @Override
        public Map<String, List<Map<String, Object>>> call() throws Exception {
            return dbExecutor.batchGetItem(batchGetItemRequest);
        }
    });
}
项目:AbacusUtil    文件:AsyncDynamoDBExecutor.java   
public <T> CompletableFuture<Map<String, List<T>>> batchGetItem(final Class<T> targetClass, final BatchGetItemRequest batchGetItemRequest) {
    return asyncExecutor.execute(new Callable<Map<String, List<T>>>() {
        @Override
        public Map<String, List<T>> call() throws Exception {
            return dbExecutor.batchGetItem(targetClass, batchGetItemRequest);
        }
    });
}
项目:Camel    文件:BatchGetItemsCommand.java   
@Override
public void execute() {
    BatchGetItemResult result = ddbClient.batchGetItem(
            new BatchGetItemRequest().withRequestItems(determineBatchItems()));

    Map tmp = new HashMap<>();
    tmp.put(DdbConstants.BATCH_RESPONSE, result.getResponses());
    tmp.put(DdbConstants.UNPROCESSED_KEYS, result.getUnprocessedKeys());
    addToResults(tmp);        
}
项目:para    文件:AWSDynamoUtils.java   
/**
 * 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
 */
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);
    }
}
项目:AbacusUtil    文件:DynamoDBExecutor.java   
@SuppressWarnings("rawtypes")
public Map<String, List<Map<String, Object>>> batchGetItem(final BatchGetItemRequest batchGetItemRequest) {
    return (Map) batchGetItem(Map.class, batchGetItemRequest);
}
项目:AbacusUtil    文件:DynamoDBExecutor.java   
public <T> Map<String, List<T>> batchGetItem(final Class<T> targetClass, final BatchGetItemRequest batchGetItemRequest) {
    return toEntities(targetClass, dynamoDB.batchGetItem(batchGetItemRequest).getResponses());
}