本文整理匯總了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());
}
}