本文整理汇总了Java中com.amazonaws.services.dynamodbv2.document.BatchGetItemOutcome类的典型用法代码示例。如果您正苦于以下问题:Java BatchGetItemOutcome类的具体用法?Java BatchGetItemOutcome怎么用?Java BatchGetItemOutcome使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BatchGetItemOutcome类属于com.amazonaws.services.dynamodbv2.document包,在下文中一共展示了BatchGetItemOutcome类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveMultipleItemsBatchGet
import com.amazonaws.services.dynamodbv2.document.BatchGetItemOutcome; //导入依赖的package包/类
private static void retrieveMultipleItemsBatchGet() {
try {
TableKeysAndAttributes forumTableKeysAndAttributes = new TableKeysAndAttributes(forumTableName);
forumTableKeysAndAttributes.addHashOnlyPrimaryKeys("Name", "Amazon S3", "Amazon DynamoDB");
TableKeysAndAttributes threadTableKeysAndAttributes = new TableKeysAndAttributes(threadTableName);
threadTableKeysAndAttributes.addHashAndRangePrimaryKeys("ForumName", "Subject",
"Amazon DynamoDB","DynamoDB Thread 1",
"Amazon DynamoDB","DynamoDB Thread 2",
"Amazon S3","S3 Thread 1");
Map<String, TableKeysAndAttributes> requestItems = new HashMap<String, TableKeysAndAttributes>();
requestItems.put(forumTableName, forumTableKeysAndAttributes);
requestItems.put(threadTableName, threadTableKeysAndAttributes);
System.out.println("Making the request.");
BatchGetItemOutcome outcome = dynamoDB.batchGetItem(forumTableKeysAndAttributes,
threadTableKeysAndAttributes);
do {
for (String tableName : outcome.getTableItems().keySet()) {
System.out.println("Items in table " + tableName);
List<Item> items = outcome.getTableItems().get(tableName);
for (Item item : items) {
System.out.println(item.toJSONPretty());
}
}
// Check for unprocessed keys which could happen if you exceed provisioned
// throughput or reach the limit on response size.
Map<String, KeysAndAttributes> unprocessedKeys = outcome.getUnprocessedKeys();
if (outcome.getUnprocessedKeys().size() == 0) {
System.out.println("No unprocessed keys found");
} else {
System.out.println("Retrieving the unprocessed keys");
outcome = dynamoDB.batchGetItemUnprocessed(unprocessedKeys);
}
} while (outcome.getUnprocessedKeys().size() > 0);
} catch (Exception e) {
System.err.println("Failed to retrieve items.");
System.err.println(e.getMessage());
}
}