当前位置: 首页>>代码示例>>Java>>正文


Java BatchGetItemOutcome类代码示例

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

}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:54,代码来源:DocumentAPIBatchGet.java


注:本文中的com.amazonaws.services.dynamodbv2.document.BatchGetItemOutcome类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。