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()); } }
public TableKeysAndAttributes decorate(TableKeysAndAttributes tableKeysAndAttributes);