Example usage for com.amazonaws.services.dynamodbv2.model PutItemRequest setReturnValues

List of usage examples for com.amazonaws.services.dynamodbv2.model PutItemRequest setReturnValues

Introduction

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

Prototype


public void setReturnValues(ReturnValue returnValues) 

Source Link

Document

Use ReturnValues if you want to get the item attributes as they appeared before they were updated with the PutItem 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;//  ww  w  .ja  va  2s . c o m
            long t = System.currentTimeMillis();
            try {
                res = dynamoDB.putItem(req);
            } catch (Exception exob) {
                exob.printStackTrace();
            }
            assert 0 == res.getAttributes().size();
            System.out.printf("%s. takes %d ms\n", pk, System.currentTimeMillis() - t);
        }
    });
}