当前位置: 首页>>代码示例>>Java>>正文


Java UpdateItemRequest.setAttributeUpdates方法代码示例

本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.UpdateItemRequest.setAttributeUpdates方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateItemRequest.setAttributeUpdates方法的具体用法?Java UpdateItemRequest.setAttributeUpdates怎么用?Java UpdateItemRequest.setAttributeUpdates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.dynamodbv2.model.UpdateItemRequest的用法示例。


在下文中一共展示了UpdateItemRequest.setAttributeUpdates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: UpdatePointRequest

import com.amazonaws.services.dynamodbv2.model.UpdateItemRequest; //导入方法依赖的package包/类
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;
}
 
开发者ID:awslabs,项目名称:dynamodb-geo,代码行数:9,代码来源:UpdatePointRequest.java

示例2: update

import com.amazonaws.services.dynamodbv2.model.UpdateItemRequest; //导入方法依赖的package包/类
@Override
public <T extends Message> boolean update(T item, Modifier... modifiers) throws DataStoreException {
  DynamoClassMapping<T> tableInfo = getClassMapping(item);

  log.debug("Update {} {} [{}]", item.getClass().getSimpleName(), item, modifiers);

  UpdateItemRequest request = new UpdateItemRequest();
  request.setTableName(tableInfo.getDynamoTableName());
  request.setKey(tableInfo.buildCompleteKey(item));

  Map<String, ExpectedAttributeValue> expected = Maps.newHashMap();
  expected.put(FIELD_HASH_KEY, new ExpectedAttributeValue().withComparisonOperator(ComparisonOperator.NOT_NULL));

  for (Modifier modifier : modifiers) {
    if (modifier instanceof WhereModifier) {
      WhereModifier where = (WhereModifier) modifier;
      Map<FieldDescriptor, Object> matcherFields = where.getMatcher().getAllFields();
      for (Map.Entry<FieldDescriptor, Object> matcherField : matcherFields.entrySet()) {
        FieldDescriptor fieldDescriptor = matcherField.getKey();
        Object fieldValue = matcherField.getValue();
        tableInfo.addFilter(expected, fieldDescriptor, fieldValue);
      }
    } else {
      throw new UnsupportedOperationException();
    }
  }

  Map<String, AttributeValueUpdate> attributeUpdates = tableInfo.mapToUpdate(item);

  request.setAttributeUpdates(attributeUpdates);
  request.setExpected(expected);
  if (expected.size() > 1) {
    request.setConditionalOperator(ConditionalOperator.AND);
  }

  try {
    UpdateItemResult response = dynamoDB.updateItem(request);
    return true;
  } catch (ConditionalCheckFailedException e) {
    log.debug("Update failed (conditional check failed)");
    return false;
  }
}
 
开发者ID:justinsb,项目名称:cloudata,代码行数:44,代码来源:DynamodbDataStore.java


注:本文中的com.amazonaws.services.dynamodbv2.model.UpdateItemRequest.setAttributeUpdates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。