Example usage for com.amazonaws.services.dynamodbv2.model PutItemResult getAttributes

List of usage examples for com.amazonaws.services.dynamodbv2.model PutItemResult getAttributes

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model PutItemResult getAttributes.

Prototype


public java.util.Map<String, AttributeValue> getAttributes() 

Source Link

Document

The attribute values as they appeared before the PutItem operation, but only if ReturnValues is specified as ALL_OLD in the request.

Usage

From source file:AmazonDynamoDBSample_PutThrottled.java

License:Open Source License

private static Thread newItemCreationThread(String tableName, final int thrdNo) {
    final int ITEM_COUNTS = 1000 * 1000;
    return new Thread(() -> {
        for (int c = 0; c < ITEM_COUNTS; c++) {
            Map<String, AttributeValue> item = new HashMap<>();
            String pk = String.format("pk name: thrd %d creates %dth item", thrdNo, c);
            item.put("name", new AttributeValue(pk));

            PutItemRequest req = new PutItemRequest(tableName, item);
            req.setReturnValues(ReturnValue.ALL_OLD);
            PutItemResult res = null;
            long t = System.currentTimeMillis();
            try {
                res = dynamoDB.putItem(req);
            } catch (Exception exob) {
                exob.printStackTrace();/*from   w w w . j a  v  a 2 s. c o  m*/
            }
            assert 0 == res.getAttributes().size();
            System.out.printf("%s. takes %d ms\n", pk, System.currentTimeMillis() - t);
        }
    });
}