in java/example_code/dynamodb/src/main/java/com/amazonaws/codesamples/lowlevel/LowLevelLocalSecondaryIndexExample.java [230:374]
public static void loadData() {
System.out.println("Loading data into table " + tableName + "...");
HashMap<String, AttributeValue> item = new HashMap<String, AttributeValue>();
item.put("CustomerId", new AttributeValue().withS("alice@example.com"));
item.put("OrderId", new AttributeValue().withN("1"));
item.put("IsOpen", new AttributeValue().withN("1"));
item.put("OrderCreationDate", new AttributeValue().withN("20130101"));
item.put("ProductCategory", new AttributeValue().withS(" Book"));
item.put("ProductName", new AttributeValue().withS(" The Great Outdoors"));
item.put("OrderStatus", new AttributeValue().withS("PACKING ITEMS"));
/* no ShipmentTrackingId attribute */
PutItemRequest putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item)
.withReturnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE);
PutItemResult result = client.putItem(putItemRequest);
System.out.println("Item collection metrics: " + result.getItemCollectionMetrics());
item = new HashMap<String, AttributeValue>();
item.put("CustomerId", new AttributeValue().withS("alice@example.com"));
item.put("OrderId", new AttributeValue().withN("2"));
item.put("IsOpen", new AttributeValue().withN("1"));
item.put("OrderCreationDate", new AttributeValue().withN("20130221"));
item.put("ProductCategory", new AttributeValue().withS("Bike"));
item.put("ProductName", new AttributeValue().withS("Super Mountain"));
item.put("OrderStatus", new AttributeValue().withS("ORDER RECEIVED"));
/* no ShipmentTrackingId attribute */
putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item)
.withReturnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE);
result = client.putItem(putItemRequest);
System.out.println("Item collection metrics: " + result.getItemCollectionMetrics());
item = new HashMap<String, AttributeValue>();
item.put("CustomerId", new AttributeValue().withS("alice@example.com"));
item.put("OrderId", new AttributeValue().withN("3"));
/* no IsOpen attribute */
item.put("OrderCreationDate", new AttributeValue().withN("20130304"));
item.put("ProductCategory", new AttributeValue().withS("Music"));
item.put("ProductName", new AttributeValue().withS("A Quiet Interlude"));
item.put("OrderStatus", new AttributeValue().withS("IN TRANSIT"));
item.put("ShipmentTrackingId", new AttributeValue().withS("176493"));
putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item)
.withReturnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE);
result = client.putItem(putItemRequest);
System.out.println("Item collection metrics: " + result.getItemCollectionMetrics());
item = new HashMap<String, AttributeValue>();
item.put("CustomerId", new AttributeValue().withS("bob@example.com"));
item.put("OrderId", new AttributeValue().withN("1"));
/* no IsOpen attribute */
item.put("OrderCreationDate", new AttributeValue().withN("20130111"));
item.put("ProductCategory", new AttributeValue().withS("Movie"));
item.put("ProductName", new AttributeValue().withS("Calm Before The Storm"));
item.put("OrderStatus", new AttributeValue().withS("SHIPPING DELAY"));
item.put("ShipmentTrackingId", new AttributeValue().withS("859323"));
putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item)
.withReturnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE);
result = client.putItem(putItemRequest);
System.out.println("Item collection metrics: " + result.getItemCollectionMetrics());
item = new HashMap<String, AttributeValue>();
item.put("CustomerId", new AttributeValue().withS("bob@example.com"));
item.put("OrderId", new AttributeValue().withN("2"));
/* no IsOpen attribute */
item.put("OrderCreationDate", new AttributeValue().withN("20130124"));
item.put("ProductCategory", new AttributeValue().withS("Music"));
item.put("ProductName", new AttributeValue().withS("E-Z Listening"));
item.put("OrderStatus", new AttributeValue().withS("DELIVERED"));
item.put("ShipmentTrackingId", new AttributeValue().withS("756943"));
putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item)
.withReturnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE);
result = client.putItem(putItemRequest);
System.out.println("Item collection metrics: " + result.getItemCollectionMetrics());
item = new HashMap<String, AttributeValue>();
item.put("CustomerId", new AttributeValue().withS("bob@example.com"));
item.put("OrderId", new AttributeValue().withN("3"));
/* no IsOpen attribute */
item.put("OrderCreationDate", new AttributeValue().withN("20130221"));
item.put("ProductCategory", new AttributeValue().withS("Music"));
item.put("ProductName", new AttributeValue().withS("Symphony 9"));
item.put("OrderStatus", new AttributeValue().withS("DELIVERED"));
item.put("ShipmentTrackingId", new AttributeValue().withS("645193"));
putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item)
.withReturnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE);
result = client.putItem(putItemRequest);
System.out.println("Item collection metrics: " + result.getItemCollectionMetrics());
item = new HashMap<String, AttributeValue>();
item.put("CustomerId", new AttributeValue().withS("bob@example.com"));
item.put("OrderId", new AttributeValue().withN("4"));
item.put("IsOpen", new AttributeValue().withN("1"));
item.put("OrderCreationDate", new AttributeValue().withN("20130222"));
item.put("ProductCategory", new AttributeValue().withS("Hardware"));
item.put("ProductName", new AttributeValue().withS("Extra Heavy Hammer"));
item.put("OrderStatus", new AttributeValue().withS("PACKING ITEMS"));
/* no ShipmentTrackingId attribute */
putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item)
.withReturnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE);
result = client.putItem(putItemRequest);
System.out.println("Item collection metrics: " + result.getItemCollectionMetrics());
item = new HashMap<String, AttributeValue>();
item.put("CustomerId", new AttributeValue().withS("bob@example.com"));
item.put("OrderId", new AttributeValue().withN("5"));
/* no IsOpen attribute */
item.put("OrderCreationDate", new AttributeValue().withN("20130309"));
item.put("ProductCategory", new AttributeValue().withS("Book"));
item.put("ProductName", new AttributeValue().withS("How To Cook"));
item.put("OrderStatus", new AttributeValue().withS("IN TRANSIT"));
item.put("ShipmentTrackingId", new AttributeValue().withS("440185"));
putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item)
.withReturnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE);
result = client.putItem(putItemRequest);
System.out.println("Item collection metrics: " + result.getItemCollectionMetrics());
item = new HashMap<String, AttributeValue>();
item.put("CustomerId", new AttributeValue().withS("bob@example.com"));
item.put("OrderId", new AttributeValue().withN("6"));
/* no IsOpen attribute */
item.put("OrderCreationDate", new AttributeValue().withN("20130318"));
item.put("ProductCategory", new AttributeValue().withS("Luggage"));
item.put("ProductName", new AttributeValue().withS("Really Big Suitcase"));
item.put("OrderStatus", new AttributeValue().withS("DELIVERED"));
item.put("ShipmentTrackingId", new AttributeValue().withS("893927"));
putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item)
.withReturnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE);
result = client.putItem(putItemRequest);
System.out.println("Item collection metrics: " + result.getItemCollectionMetrics());
item = new HashMap<String, AttributeValue>();
item.put("CustomerId", new AttributeValue().withS("bob@example.com"));
item.put("OrderId", new AttributeValue().withN("7"));
/* no IsOpen attribute */
item.put("OrderCreationDate", new AttributeValue().withN("20130324"));
item.put("ProductCategory", new AttributeValue().withS("Golf"));
item.put("ProductName", new AttributeValue().withS("PGA Pro II"));
item.put("OrderStatus", new AttributeValue().withS("OUT FOR DELIVERY"));
item.put("ShipmentTrackingId", new AttributeValue().withS("383283"));
putItemRequest = new PutItemRequest().withTableName(tableName).withItem(item)
.withReturnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE);
result = client.putItem(putItemRequest);
System.out.println("Item collection metrics: " + result.getItemCollectionMetrics());
}