下面列出了怎么用com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void create(Entry entry) {
readWriteLock.writeLock().lock();
try {
Map<String, AttributeValue> keys = createKey(entry);
Map<String, AttributeValueUpdate> attributes = createAttributes(entry);
Map<String, ExpectedAttributeValue> expected = expectNotExists();
try {
executeUpdate(keys, attributes, expected);
} catch (ConditionalCheckFailedException e) {
throw new AlreadyExistsException("DynamoDB store entry already exists:" + keys.toString());
}
} finally {
readWriteLock.writeLock().unlock();
}
}
@Override
public void update(Entry entry, Entry existingEntry) {
readWriteLock.writeLock().lock();
try {
Map<String, AttributeValue> keys = createKey(entry);
Map<String, AttributeValueUpdate> attributes = createAttributes(entry);
Map<String, ExpectedAttributeValue> expected = expectExists(existingEntry);
try {
executeUpdate(keys, attributes, expected);
} catch (ConditionalCheckFailedException e) {
throw new DoesNotExistException("Precondition to update entry in DynamoDB failed:" + keys.toString());
}
} finally {
readWriteLock.writeLock().unlock();
}
}
private Map<String, AttributeValueUpdate> createAttributes(Entry entry) {
Map<String, AttributeValueUpdate> attributes = new HashMap<>();
attributes.put(SCHEMA_VERSION_FIELD_NAME, new AttributeValueUpdate()
.withAction(AttributeAction.PUT)
.withValue(new AttributeValue().withN(SCHEMA_VERSION)));
attributes.put(OPTIMISTIC_LOCK_FIELD_NAME, new AttributeValueUpdate()
.withAction(AttributeAction.PUT)
.withValue(new AttributeValue().withS(sha(entry))));
for (Map.Entry<Integer, String> e : attributeMappings.entrySet()) {
Object value = getValue(entry, e.getValue());
if (value != null) {
attributes.put(e.getKey().toString(),
new AttributeValueUpdate()
.withAction(AttributeAction.PUT)
.withValue(getAttribute(value)));
}
}
return attributes;
}
@Test
public void test_updateItem_WithAllParameters() throws Exception {
createTable();
putItem(TEST_ATTRIBUTE, TEST_ATTRIBUTE_VALUE);
String UPDATE_ATTRIBUTE_VALUE = "UpdateAttributeValue1";
Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
key.put(TEST_ATTRIBUTE, new AttributeValue()
.withS(TEST_ATTRIBUTE_VALUE));
Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<String, AttributeValueUpdate>();
attributeUpdates.put(TEST_ATTRIBUTE, new AttributeValueUpdate()
.withAction(AttributeAction.PUT)
.withValue(new AttributeValue()
.withS(UPDATE_ATTRIBUTE_VALUE)));
String returnValues = "";
UpdateItemResult result = dynamoDb.updateItem(TEST_TABLE_NAME, key, attributeUpdates, returnValues);
Double units = result.getConsumedCapacity().getCapacityUnits();
GetItemResult getItemResult = getItem(TEST_ATTRIBUTE, UPDATE_ATTRIBUTE_VALUE);
String updatedValue = getItemResult.getItem().get(TEST_ATTRIBUTE).getS();
assertThat(units.doubleValue(), equalTo(1.0));
assertThat(updatedValue, equalTo(UPDATE_ATTRIBUTE_VALUE));
}
public static void updateItem(AmazonDynamoDBClient client, String tableName, String id, String val) {
java.util.Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
key.put("Id", new AttributeValue().withN(id));
Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<String, AttributeValueUpdate>();
AttributeValueUpdate update = new AttributeValueUpdate()
.withAction(AttributeAction.PUT)
.withValue(new AttributeValue().withS(val));
attributeUpdates.put("attribute-2", update);
UpdateItemRequest updateItemRequest = new UpdateItemRequest()
.withTableName(tableName)
.withKey(key)
.withAttributeUpdates(attributeUpdates);
client.updateItem(updateItemRequest);
}
@Before
public void setup() {
dynamodb.reset();
uncommittedFacade = new TransactionManagerDynamoDBFacade(manager, Transaction.IsolationLevel.UNCOMMITTED);
committedFacade = new TransactionManagerDynamoDBFacade(manager, Transaction.IsolationLevel.COMMITTED);
key0 = newKey(INTEG_HASH_TABLE_NAME);
item0 = new HashMap<String, AttributeValue>(key0);
item0.put("s_someattr", new AttributeValue("val"));
item0Filtered = new HashMap<String, AttributeValue>(item0);
item0.put("attr_not_to_get", new AttributeValue("val_not_to_get"));
attributesToGet = Arrays.asList(ID_ATTRIBUTE, "s_someattr"); // not including attr_not_to_get
update = Collections.singletonMap(
"s_someattr",
new AttributeValueUpdate().withValue(new AttributeValue("val2")));
item0Updated = new HashMap<String, AttributeValue>(item0);
item0Updated.put("s_someattr", new AttributeValue("val2"));
}
@Test
public void getThenUpdateNewItem() {
Transaction t1 = manager.newTransaction();
Map<String, AttributeValue> key1 = newKey(INTEG_HASH_TABLE_NAME);
Map<String, AttributeValue> item1 = new HashMap<String, AttributeValue>(key1);
item1.put("asdf", new AttributeValue("didn't exist"));
Map<String, AttributeValueUpdate> updates1 = new HashMap<String, AttributeValueUpdate>();
updates1.put("asdf", new AttributeValueUpdate(new AttributeValue("didn't exist"), AttributeAction.PUT));
Map<String, AttributeValue> getResult = t1.getItem(new GetItemRequest().withTableName(INTEG_HASH_TABLE_NAME).withKey(key1)).getItem();
assertItemLocked(INTEG_HASH_TABLE_NAME, key1, t1.getId(), true, false);
assertNull(getResult);
Map<String, AttributeValue> updateResult = t1.updateItem(new UpdateItemRequest().withTableName(INTEG_HASH_TABLE_NAME).withKey(key1)
.withAttributeUpdates(updates1).withReturnValues(ReturnValue.ALL_NEW)).getAttributes();
assertItemLocked(INTEG_HASH_TABLE_NAME, key1, item1, t1.getId(), true, true);
assertEquals(item1, updateResult);
t1.commit();
assertItemNotLocked(INTEG_HASH_TABLE_NAME, key1, item1, true);
}
@Test
public void getThenUpdateExistingItem() {
Transaction t1 = manager.newTransaction();
Map<String, AttributeValue> item0a = new HashMap<String, AttributeValue>(item0);
item0a.put("wef", new AttributeValue("new attr"));
Map<String, AttributeValueUpdate> updates1 = new HashMap<String, AttributeValueUpdate>();
updates1.put("wef", new AttributeValueUpdate(new AttributeValue("new attr"), AttributeAction.PUT));
Map<String, AttributeValue> getResult = t1.getItem(new GetItemRequest().withTableName(INTEG_HASH_TABLE_NAME).withKey(key0)).getItem();
assertItemLocked(INTEG_HASH_TABLE_NAME, key0, item0, t1.getId(), false, false);
assertEquals(item0, getResult);
Map<String, AttributeValue> updateResult = t1.updateItem(new UpdateItemRequest().withTableName(INTEG_HASH_TABLE_NAME).withKey(key0)
.withAttributeUpdates(updates1).withReturnValues(ReturnValue.ALL_NEW)).getAttributes();
assertItemLocked(INTEG_HASH_TABLE_NAME, key0, item0a, t1.getId(), false, true);
assertEquals(item0a, updateResult);
t1.commit();
assertItemNotLocked(INTEG_HASH_TABLE_NAME, key0, item0a, true);
}
@Test
public void updateItemAllOldInsert() {
Transaction t1 = manager.newTransaction();
Map<String, AttributeValue> key1 = newKey(INTEG_HASH_TABLE_NAME);
Map<String, AttributeValue> item1 = new HashMap<String, AttributeValue>(key1);
item1.put("asdf", new AttributeValue("wef"));
Map<String, AttributeValueUpdate> updates = new HashMap<String, AttributeValueUpdate>();
updates.put("asdf", new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(new AttributeValue("wef")));
Map<String, AttributeValue> result1 = t1.updateItem(new UpdateItemRequest()
.withTableName(INTEG_HASH_TABLE_NAME)
.withKey(key1)
.withAttributeUpdates(updates)
.withReturnValues(ReturnValue.ALL_OLD)).getAttributes();
assertItemLocked(INTEG_HASH_TABLE_NAME, key1, item1, t1.getId(), true, true);
assertNull(result1);
t1.commit();
assertItemNotLocked(INTEG_HASH_TABLE_NAME, key1, item1, true);
}
@Test
public void updateItemAllOldOverwrite() {
Transaction t1 = manager.newTransaction();
Map<String, AttributeValue> item1 = new HashMap<String, AttributeValue>(item0);
item1.put("asdf", new AttributeValue("wef"));
Map<String, AttributeValueUpdate> updates = new HashMap<String, AttributeValueUpdate>();
updates.put("asdf", new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(new AttributeValue("wef")));
Map<String, AttributeValue> result1 = t1.updateItem(new UpdateItemRequest()
.withTableName(INTEG_HASH_TABLE_NAME)
.withKey(key0)
.withAttributeUpdates(updates)
.withReturnValues(ReturnValue.ALL_OLD)).getAttributes();
assertItemLocked(INTEG_HASH_TABLE_NAME, key0, item1, t1.getId(), false, true);
assertEquals(result1, item0);
t1.commit();
assertItemNotLocked(INTEG_HASH_TABLE_NAME, key0, item1, true);
}
@Test
public void updateItemAllNewInsert() {
Transaction t1 = manager.newTransaction();
Map<String, AttributeValue> key1 = newKey(INTEG_HASH_TABLE_NAME);
Map<String, AttributeValue> item1 = new HashMap<String, AttributeValue>(key1);
item1.put("asdf", new AttributeValue("wef"));
Map<String, AttributeValueUpdate> updates = new HashMap<String, AttributeValueUpdate>();
updates.put("asdf", new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(new AttributeValue("wef")));
Map<String, AttributeValue> result1 = t1.updateItem(new UpdateItemRequest()
.withTableName(INTEG_HASH_TABLE_NAME)
.withKey(key1)
.withAttributeUpdates(updates)
.withReturnValues(ReturnValue.ALL_NEW)).getAttributes();
assertItemLocked(INTEG_HASH_TABLE_NAME, key1, item1, t1.getId(), true, true);
assertEquals(result1, item1);
t1.commit();
assertItemNotLocked(INTEG_HASH_TABLE_NAME, key1, item1, true);
}
@Test
public void updateItemAllNewOverwrite() {
Transaction t1 = manager.newTransaction();
Map<String, AttributeValue> item1 = new HashMap<String, AttributeValue>(item0);
item1.put("asdf", new AttributeValue("wef"));
Map<String, AttributeValueUpdate> updates = new HashMap<String, AttributeValueUpdate>();
updates.put("asdf", new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(new AttributeValue("wef")));
Map<String, AttributeValue> result1 = t1.updateItem(new UpdateItemRequest()
.withTableName(INTEG_HASH_TABLE_NAME)
.withKey(key0)
.withAttributeUpdates(updates)
.withReturnValues(ReturnValue.ALL_NEW)).getAttributes();
assertItemLocked(INTEG_HASH_TABLE_NAME, key0, item1, t1.getId(), false, true);
assertEquals(result1, item1);
t1.commit();
assertItemNotLocked(INTEG_HASH_TABLE_NAME, key0, item1, true);
}
@Test
public void roundTripUpdateAll() {
UpdateItem r1 = new UpdateItem();
Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
key.put(HASH_ATTR_NAME, new AttributeValue("a"));
Map<String, AttributeValueUpdate> updates = new HashMap<String, AttributeValueUpdate>();
updates.put("attr_ss", new AttributeValueUpdate().withAction("PUT").withValue(new AttributeValue().withSS("a", "b")));
updates.put("attr_n", new AttributeValueUpdate().withAction("PUT").withValue(new AttributeValue().withN("1")));
updates.put("attr_ns", new AttributeValueUpdate().withAction("PUT").withValue(new AttributeValue().withNS("1", "2")));
updates.put("attr_b", new AttributeValueUpdate().withAction("PUT").withValue(new AttributeValue().withB(ByteBuffer.wrap(new String("asdf").getBytes()))));
updates.put("attr_bs", new AttributeValueUpdate().withAction("PUT").withValue(new AttributeValue().withBS(ByteBuffer.wrap(new String("asdf").getBytes()), ByteBuffer.wrap(new String("asdf").getBytes()))));
r1.setRequest(new UpdateItemRequest()
.withTableName(TABLE_NAME)
.withKey(key)
.withAttributeUpdates(updates));
byte[] r1Bytes = Request.serialize("123", r1).array();
Request r2 = Request.deserialize("123", ByteBuffer.wrap(r1Bytes));
byte[] r2Bytes = Request.serialize("123", r2).array();
assertArrayEquals(r1Bytes, r2Bytes);
}
@Test
public void roundTripUpdateAllJSON() {
UpdateItem r1 = new UpdateItem();
Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
key.put(HASH_ATTR_NAME, new AttributeValue("a"));
Map<String, AttributeValueUpdate> updates = new HashMap<String, AttributeValueUpdate>();
updates.put("attr_m", new AttributeValueUpdate().withAction("PUT").withValue(new AttributeValue().withM(JSON_M_ATTR_VAL)));
r1.setRequest(new UpdateItemRequest()
.withTableName(TABLE_NAME)
.withKey(key)
.withAttributeUpdates(updates));
byte[] r1Bytes = Request.serialize("123", r1).array();
Request r2 = Request.deserialize("123", ByteBuffer.wrap(r1Bytes));
byte[] r2Bytes = Request.serialize("123", r2).array();
assertArrayEquals(r1Bytes, r2Bytes);
}
@Override
public UpdateItemResult updateItem(
String tableName,
Map<String, AttributeValue> key,
Map<String, AttributeValueUpdate> attributeUpdates) {
throw new UnsupportedOperationException();
}
private void executeUpdate(Map<String, AttributeValue> keys, Map<String, AttributeValueUpdate> attributes, Map<String, ExpectedAttributeValue> expected) {
UpdateItemRequest updateEntry = new UpdateItemRequest()
.withTableName(tableName)
.withKey(keys)
.withAttributeUpdates(attributes)
.withExpected(expected);
client.updateItem(updateEntry);
}
/**
* Make an update.
* @param action The action
* @return The update
*/
public AttributeValueUpdate update(final AttributeAction action) {
return new AttributeValueUpdate()
.withAction(action)
.withValue(
new AttributeValue().withN(
Long.toString(this.longValue())
)
);
}
/**
* Update item into FragmentCheckpoint table for the given input parameters
*
* @param streamName KVS Stream name
* @param fragmentNumber Last processed fragment's fragment number
* @param producerTime Last processed fragment's producer time
* @param serverTime Last processed fragment's server time
* @param updatedTime Time when the entry is going to be updated.
*/
public void updateItem(final String streamName, final String fragmentNumber,
final Long producerTime, final Long serverTime, final Long updatedTime) {
try {
final Map<String,AttributeValue> key = new HashMap<>();
key.put(KVS_STREAM_NAME, new AttributeValue().withS(streamName));
final Map<String,AttributeValueUpdate> updates = new HashMap<>();
updates.put(FRAGMENT_NUMBER, new AttributeValueUpdate().withValue(
new AttributeValue().withS(fragmentNumber)));
updates.put(UPDATED_TIME, new AttributeValueUpdate().withValue(
new AttributeValue().withN(updatedTime.toString())));
updates.put(PRODUCER_TIME, new AttributeValueUpdate().withValue(
new AttributeValue().withN(producerTime.toString())));
updates.put(SERVER_TIME, new AttributeValueUpdate().withValue(
new AttributeValue().withN(serverTime.toString())));
final UpdateItemRequest updateItemRequest = new UpdateItemRequest()
{{
setTableName(TABLE_NAME);
setKey(key);
setAttributeUpdates(updates);
}};
final UpdateItemResult result = ddbClient.updateItem(updateItemRequest);
log.info("Item updated : {}", result.getAttributes());
} catch (final Exception e) {
log.warn("Error while updating item in the table!", e);
}
}
/**
* Save XML.
* @param xml The XML to save
* @throws IOException If fails
*/
private void save(final String xml) throws IOException {
this.item.put(
"usage",
new AttributeValueUpdate()
.withValue(new AttributeValue().withS(xml))
.withAction(AttributeAction.PUT)
);
}
/**
* Save total.
* @param total Total usage
* @throws IOException If fails
*/
private void save(final long total) throws IOException {
this.item.put(
"total",
new AttributeValueUpdate()
.withValue(new AttributeValue().withN(Long.toString(total)))
.withAction(AttributeAction.PUT)
);
}
public static void updateItem(AmazonDynamoDB dynamoDBClient, String tableName, String id, String val) {
java.util.Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
key.put("Id", new AttributeValue().withN(id));
Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<String, AttributeValueUpdate>();
AttributeValueUpdate update = new AttributeValueUpdate().withAction(AttributeAction.PUT)
.withValue(new AttributeValue().withS(val));
attributeUpdates.put("attribute-2", update);
UpdateItemRequest updateItemRequest = new UpdateItemRequest().withTableName(tableName).withKey(key)
.withAttributeUpdates(attributeUpdates);
dynamoDBClient.updateItem(updateItemRequest);
}
public static int calculateItemUpdateSizeInBytes(final Map<String, AttributeValueUpdate> item) {
int size = 0;
if (item == null) {
return size;
}
for (Map.Entry<String, AttributeValueUpdate> entry : item.entrySet()) {
final String name = entry.getKey();
final AttributeValueUpdate update = entry.getValue();
size += name.getBytes(UTF8).length;
size += calculateAttributeSizeInBytes(update.getValue());
}
return size;
}
@Override
public Collection<MutateWorker> createMutationWorkers(final Map<StaticBuffer, KCVMutation> mutationMap, final DynamoDbStoreTransaction txh) {
final List<MutateWorker> workers = Lists.newLinkedList();
for (Map.Entry<StaticBuffer, KCVMutation> entry : mutationMap.entrySet()) {
final StaticBuffer hashKey = entry.getKey();
final KCVMutation mutation = entry.getValue();
final Map<String, AttributeValue> key = new ItemBuilder().hashKey(hashKey)
.build();
// Using ExpectedAttributeValue map to handle large mutations in a single request
// Large mutations would require multiple requests using expressions
final Map<String, ExpectedAttributeValue> expected =
new SingleExpectedAttributeValueBuilder(this, txh, hashKey).build(mutation);
final Map<String, AttributeValueUpdate> attributeValueUpdates =
new SingleUpdateBuilder().deletions(mutation.getDeletions())
.additions(mutation.getAdditions())
.build();
final UpdateItemRequest request = super.createUpdateItemRequest()
.withKey(key)
.withReturnValues(ReturnValue.ALL_NEW)
.withAttributeUpdates(attributeValueUpdates)
.withExpected(expected);
final MutateWorker worker;
if (mutation.hasDeletions() && !mutation.hasAdditions()) {
worker = new SingleUpdateWithCleanupWorker(request, client.getDelegate());
} else {
worker = new UpdateItemWorker(request, client.getDelegate());
}
workers.add(worker);
}
return workers;
}
public SingleUpdateBuilder put(final StaticBuffer column, final StaticBuffer value) {
updates.put(encodeKeyBuffer(column),
new AttributeValueUpdate()
.withAction(AttributeAction.PUT)
.withValue(encodeValue(value)));
return this;
}
@Override
public Object handleRequest(Object input, Context context) {
context.getLogger().log("input: " + input);
if (input.toString().equals("{}") || input.toString().equals("")) {
context.getLogger().log("input is empty: abort");
return "{\"status\":\"error\",\"message\":\"input at lambda function is empty\"}";
}
dynamoDB = new AmazonDynamoDBClient().withRegion(Region
.getRegion(Regions.EU_WEST_1));
HashMap<String, String> mapInput = (HashMap<String, String>) input;
Map<String, AttributeValue> employeeKey = new HashMap<String, AttributeValue>();
String employeeId = mapInput.get("employee_id");
context.getLogger().log("employee_id: " + employeeId);
employeeKey.put("employee_id", new AttributeValue().withS(employeeId));
Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<String, AttributeValueUpdate>();
attributeUpdates.put("approval", new AttributeValueUpdate()
.withValue(new AttributeValue().withS("approved")));
UpdateItemRequest updateItemRequest = new UpdateItemRequest()
.withKey(employeeKey).withAttributeUpdates(attributeUpdates)
.withTableName("lambda-reimbursment");
UpdateItemResult updateItemResult = dynamoDB
.updateItem(updateItemRequest);
context.getLogger().log("Result: " + updateItemResult);
return "{'status':'done'}";
}
void updateRow(String storeName,
Map<String, AttributeValue> key,
Map<String, AttributeValueUpdate> attributeUpdates) {
String tableName = storeToTableName(storeName);
m_logger.debug("Updating row in table {}, key={}", tableName, DynamoDBService.getDDBKey(key));
Timer timer = new Timer();
boolean bSuccess = false;
for (int attempts = 1; !bSuccess; attempts++) {
try {
m_ddbClient.updateItem(tableName, key, attributeUpdates);
if (attempts > 1) {
m_logger.info("updateRow() succeeded on attempt #{}", attempts);
}
bSuccess = true;
m_logger.debug("Time to update table {}, key={}: {}",
new Object[]{tableName, DynamoDBService.getDDBKey(key), timer.toString()});
} catch (ProvisionedThroughputExceededException e) {
if (attempts >= m_max_commit_attempts) {
String errMsg = "All retries exceeded; abandoning updateRow() for table: " + tableName;
m_logger.error(errMsg, e);
throw new RuntimeException(errMsg, e);
}
m_logger.warn("updateRow() attempt #{} failed: {}", attempts, e);
try {
Thread.sleep(attempts * m_retry_wait_millis);
} catch (InterruptedException ex2) {
// ignore
}
}
}
}
private void updateRowColumnUpdates(String storeName,
Map<String, AttributeValue> key,
List<DColumn> colList) {
Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<>();
for (DColumn col : colList) {
AttributeValue attrValue = mapColumnValue(storeName, col);
attributeUpdates.put(col.getName(), new AttributeValueUpdate(attrValue, AttributeAction.PUT));
}
m_service.updateRow(storeName, key, attributeUpdates);
}
private void updateRowColumnDeletes(String storeName,
Map<String, AttributeValue> key,
List<String> colNames) {
Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<>();
for (String colName : colNames) {
attributeUpdates.put(colName, new AttributeValueUpdate().withAction(AttributeAction.DELETE));
}
m_service.updateRow(storeName, key, attributeUpdates);
}
public UpdatePointRequest(GeoPoint geoPoint, AttributeValue rangeKeyValue) {
updateItemRequest = new UpdateItemRequest();
updateItemRequest.setKey(new HashMap<String, AttributeValue>());
updateItemRequest.setAttributeUpdates(new HashMap<String, AttributeValueUpdate>());
this.geoPoint = geoPoint;
this.rangeKeyValue = rangeKeyValue;
}
private void updatePoint(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
GeoPoint geoPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(requestObject.getString("rangeKey"));
String schoolName = requestObject.getString("schoolName");
AttributeValueUpdate schoolNameValueUpdate = null;
String memo = requestObject.getString("memo");
AttributeValueUpdate memoValueUpdate = null;
if (schoolName == null || schoolName.equalsIgnoreCase("")) {
schoolNameValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.DELETE);
} else {
AttributeValue schoolNameAttributeValue = new AttributeValue().withS(schoolName);
schoolNameValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(
schoolNameAttributeValue);
}
if (memo == null || memo.equalsIgnoreCase("")) {
memoValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.DELETE);
} else {
AttributeValue memoAttributeValue = new AttributeValue().withS(memo);
memoValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(memoAttributeValue);
}
UpdatePointRequest updatePointRequest = new UpdatePointRequest(geoPoint, rangeKeyAttributeValue);
updatePointRequest.getUpdateItemRequest().addAttributeUpdatesEntry("schoolName", schoolNameValueUpdate);
updatePointRequest.getUpdateItemRequest().addAttributeUpdatesEntry("memo", memoValueUpdate);
UpdatePointResult updatePointResult = geoDataManager.updatePoint(updatePointRequest);
printUpdatePointResult(updatePointResult, out);
}