Example usage for com.amazonaws.services.dynamodbv2.model UpdateItemRequest getUpdateExpression

List of usage examples for com.amazonaws.services.dynamodbv2.model UpdateItemRequest getUpdateExpression

Introduction

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

Prototype


public String getUpdateExpression() 

Source Link

Document

An expression that defines one or more attributes to be updated, the action to be performed on them, and new values for them.

Usage

From source file:com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbDelegate.java

License:Open Source License

UpdateItemResult updateItem(final UpdateItemRequest request) throws BackendException {
    setUserAgent(request);//from  www  .  j av  a  2  s.c o  m
    UpdateItemResult result;
    final int bytes;
    if (request.getUpdateExpression() != null) {
        bytes = calculateExpressionBasedUpdateSize(request);
    } else {
        bytes = calculateItemUpdateSizeInBytes(request.getAttributeUpdates());
    }
    getBytesHistogram(UPDATE_ITEM, request.getTableName()).update(bytes);
    final int wcu = computeWcu(bytes);
    timedWriteThrottle(UPDATE_ITEM, request.getTableName(), wcu);

    final Timer.Context apiTimerContext = getTimerContext(UPDATE_ITEM, request.getTableName());
    try {
        result = client.updateItem(request);
    } catch (Exception e) {
        throw processDynamoDbApiException(e, UPDATE_ITEM, request.getTableName());
    } finally {
        apiTimerContext.stop();
    }
    meterConsumedCapacity(UPDATE_ITEM, result.getConsumedCapacity());

    return result;
}

From source file:com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbDelegate.java

License:Open Source License

/**
 * This method calculates a lower bound of the size of a new item created with UpdateItem UpdateExpression. It does not
 * account for the size of the attribute names of the document paths in the attribute names map and it assumes that the
 * UpdateExpression only uses the SET action to assign to top-level attributes.
 * @param request UpdateItem request that uses update expressions
 * @return the size of the post-update image of the item
 *///  www. j  a  v  a  2  s. c  o m
private int calculateExpressionBasedUpdateSize(final UpdateItemRequest request) {
    if (request == null || request.getUpdateExpression() == null) {
        throw new IllegalArgumentException("request did not use update expression");
    }
    int size = calculateItemSizeInBytes(request.getKey());
    for (AttributeValue value : request.getExpressionAttributeValues().values()) {
        size += calculateAttributeSizeInBytes(value);
    }
    return size;
}

From source file:com.rapid7.diskstorage.dynamodb.DynamoDBDelegate.java

License:Open Source License

public UpdateItemResult updateItem(UpdateItemRequest request) throws BackendException {
    setUserAgent(request);/*  w w  w  .ja  v  a 2s  . c o m*/
    UpdateItemResult result;
    final int bytes = request.getUpdateExpression() != null ? calculateExpressionBasedUpdateSize(request)
            : calculateItemUpdateSizeInBytes(request.getAttributeUpdates());
    getBytesHistogram(UPDATE_ITEM, request.getTableName()).update(bytes);
    final int wcu = computeWcu(bytes);
    timedWriteThrottle(UPDATE_ITEM, request.getTableName(), wcu);

    final Timer.Context apiTimerContext = getTimerContext(UPDATE_ITEM, request.getTableName());
    try {
        result = client.updateItem(request);
    } catch (Exception e) {
        throw processDynamoDBAPIException(e, UPDATE_ITEM, request.getTableName());
    } finally {
        apiTimerContext.stop();
    }
    meterConsumedCapacity(UPDATE_ITEM, result.getConsumedCapacity());

    return result;
}

From source file:com.rapid7.diskstorage.dynamodb.DynamoDBDelegate.java

License:Open Source License

/**
 * This method calculates a lower bound of the size of a new item created with UpdateItem UpdateExpression. It does not
 * account for the size of the attribute names of the document paths in the attribute names map and it assumes that the
 * UpdateExpression only uses the SET action to assign to top-level attributes.
 * @param request UpdateItem request that uses update expressions
 * @return the size of the post-update image of the item
 *//*w  ww  .  j a v  a2  s . c  o  m*/
private int calculateExpressionBasedUpdateSize(UpdateItemRequest request) {
    if (request == null || request.getUpdateExpression() == null) {
        throw new IllegalArgumentException("request did not use update expression");
    }
    int size = calculateItemSizeInBytes(request.getKey());
    for (AttributeValue value : request.getExpressionAttributeValues().values()) {
        size += calculateAttributeSizeInBytes(value);
    }
    return size;
}