List of usage examples for com.amazonaws.services.dynamodbv2.model UpdateItemRequest setTableName
public void setTableName(String tableName)
The name of the table containing the item to update.
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); }