List of usage examples for com.amazonaws.services.dynamodbv2 AmazonDynamoDB batchWriteItem
BatchWriteItemResult batchWriteItem(java.util.Map<String, java.util.List<WriteRequest>> requestItems);
From source file:com.netflix.config.sources.DynamoDbIntegrationTestHelper.java
License:Apache License
static void addElements(AmazonDynamoDB dbClient, String tableName) { Map<String, List<WriteRequest>> requestMap = new HashMap<String, List<WriteRequest>>(1); List<WriteRequest> writeList = new ArrayList<WriteRequest>(3); Map<String, AttributeValue> item1 = new HashMap<String, AttributeValue>(1); item1.put(DynamoDbConfigurationSource.defaultKeyAttribute, new AttributeValue().withS("test1")); item1.put(DynamoDbConfigurationSource.defaultValueAttribute, new AttributeValue().withS("val1")); writeList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(item1))); HashMap<String, AttributeValue> item2 = new HashMap<String, AttributeValue>(1); item2.put(DynamoDbConfigurationSource.defaultKeyAttribute, new AttributeValue().withS("test2")); item2.put(DynamoDbConfigurationSource.defaultValueAttribute, new AttributeValue().withS("val2")); writeList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(item2))); HashMap<String, AttributeValue> item3 = new HashMap<String, AttributeValue>(1); item3.put(DynamoDbConfigurationSource.defaultKeyAttribute, new AttributeValue().withS("test3")); item3.put(DynamoDbConfigurationSource.defaultValueAttribute, new AttributeValue().withS("val3")); writeList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(item3))); requestMap.put(tableName, writeList); BatchWriteItemRequest request = new BatchWriteItemRequest().withRequestItems(requestMap); dbClient.batchWriteItem(request); }