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

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

Introduction

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

Prototype


public void setTableName(String tableName) 

Source Link

Document

The name of the table containing the item to update.

Usage

From source file:amazon.dynamodb.config.DynamoDBManager.java

License:Open Source License

public UpdatePointResult updatePoint(UpdatePointRequest updatePointRequest) {
    long geohash = S2Manager.generateGeohash(updatePointRequest.getGeoPoint());
    long hashKey = S2Manager.generateHashKey(geohash, config.getHashKeyLength());

    UpdateItemRequest updateItemRequest = updatePointRequest.getUpdateItemRequest();
    updateItemRequest.setTableName(config.getTableName());

    AttributeValue hashKeyValue = new AttributeValue().withN(String.valueOf(hashKey));
    updateItemRequest.getKey().put(config.getHashKeyAttributeName(), hashKeyValue);
    updateItemRequest.getKey().put(config.getRangeKeyAttributeName(), updatePointRequest.getRangeKeyValue());

    // Geohash and geoJson cannot be updated.
    updateItemRequest.getAttributeUpdates().remove(config.getGeohashAttributeName());
    updateItemRequest.getAttributeUpdates().remove(config.getGeoJsonAttributeName());

    UpdateItemResult updateItemResult = config.getDynamoDBClient().updateItem(updateItemRequest);
    UpdatePointResult updatePointResult = new UpdatePointResult(updateItemResult);

    return updatePointResult;
}

From source file:com.nandanu.halomama.controller.DynamoDBRouter.java

License:Open Source License

public void incrementSeen(String userNameTwitter, String createdDate) {
    UpdateItemRequest upd = new UpdateItemRequest();

    upd.setTableName(Constants.TABLE_NAME);

    AttributeValue unt = new AttributeValue();
    unt.setS(userNameTwitter);/* w  w  w .j a  v  a2  s  . c  o m*/
    AttributeValue cd = new AttributeValue();
    cd.setS(createdDate);

    upd.addKeyEntry(Constants.TAG_USERNAME, unt);
    upd.addKeyEntry(Constants.TAG_CREATED_DATE, cd);

    AttributeValue s = new AttributeValue();
    s.setN("1");

    AttributeValueUpdate seen = new AttributeValueUpdate(s, AttributeAction.ADD);

    upd.addAttributeUpdatesEntry(Constants.TAG_SEEN, seen);

    dDBClient.updateItem(upd);

}