• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AttributeValueUpdate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



AttributeValueUpdate类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了AttributeValueUpdate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: update

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
@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();
    }

}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:20,代码来源:GenericDynamoDB.java


示例2: create

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:19,代码来源:GenericDynamoDB.java


示例3: createAttributes

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
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;
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:23,代码来源:GenericDynamoDB.java


示例4: createsOnlyThreeOpenLogs

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
@Test
public void createsOnlyThreeOpenLogs() throws Exception {
    final User user = new DyUser(new Dynamo(), "yegor256");
    final Script script = user.script("test5");
    final AttributeValueUpdate upd = new AttributeValueUpdate().withValue(
        new AttributeValue().withN(
            Long.toString(System.currentTimeMillis())
        )
    ).withAction(AttributeAction.PUT);
    // @checkstyle MagicNumber (1 line)
    for (int idx = 0; idx < 3; ++idx) {
        final Item item = script.open().iterator().next();
        item.put("finish", upd);
    }
    MatcherAssert.assertThat(
        script.open(),
        Matchers.emptyIterable()
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:20,代码来源:DyScriptITCase.java


示例5: updateItem

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
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);
}
 
开发者ID:gnethercutt,项目名称:dynamodb-streams-kafka,代码行数:17,代码来源:StreamAdapterDemoHelper.java


示例6: sendUpdateRequest

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
/**
 * Sends an update request to the service and returns true if the request is successful.
 */
public boolean sendUpdateRequest(Map<String, AttributeValue> primaryKey, Map<String, AttributeValueUpdate> updateItems,
        Map<String, ExpectedAttributeValue> expectedItems) throws Exception {
    if (updateItems.isEmpty()) {
        return false; // No update, return false
    }
    UpdateItemRequest updateItemRequest = new UpdateItemRequest().withTableName(tableName).withKey(primaryKey).withReturnValues(ReturnValue.UPDATED_NEW)
            .withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL).withAttributeUpdates(updateItems);
    if (expectedItems != null) {
        updateItemRequest.withExpected(expectedItems);
    }

    UpdateItemResult result = dynamoDBClient.updateItem(updateItemRequest);
    if(!isRunningOnDDBLocal) {
        // DDB Local does not support rate limiting
        tableWriteRateLimiter.adjustRateWithConsumedCapacity(result.getConsumedCapacity());
    }
    return true;
}
 
开发者ID:awslabs,项目名称:dynamodb-online-index-violation-detector,代码行数:22,代码来源:TableWriter.java


示例7: genUpdateItemsForRecord

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
protected Map<String, AttributeValueUpdate> genUpdateItemsForRecord() {
    Map<String, AttributeValueUpdate> updateItems = null;
    AttributeValue GSIHashKeyUpdateValue = tableWriter.genAttributeValueForGSIKey(options.getGsiHashKeyType(), getNextGsiHashKeyUpdateValue());
    AttributeValue GSIRangeKeyUpdateValue = tableWriter.genAttributeValueForGSIKey(options.getGsiRangeKeyType(), getNextGsiRangeKeyUpdateValue());
    
    // Find if gsi hash key/range key has violations. This will be needed when both hash and range violations
    // are to be found but only one has a violation.
    String gsiHashKeyName = getNextGsiHashKeyViolationType() == null ? null : options.getGsiHashKeyName();
    String gsiRangeKeyName = getNextGsiRangeKeyViolationType() == null ? null : options.getGsiRangeKeyName();
    
    boolean deleteBlank = getNextDeleteBlankAttribute();
    if (deleteBlank) {
        updateItems = genUpdateItemsWithEmptyAttributeDeleted(gsiHashKeyName, GSIHashKeyUpdateValue, gsiRangeKeyName,
                GSIRangeKeyUpdateValue);
    } else {
        updateItems = genUpdateItemsWithEmptyAttributeKept(gsiHashKeyName, GSIHashKeyUpdateValue, gsiRangeKeyName,
                GSIRangeKeyUpdateValue);
    }
    return updateItems;
}
 
开发者ID:awslabs,项目名称:dynamodb-online-index-violation-detector,代码行数:21,代码来源:Correction.java


示例8: genUpdateItemsWithEmptyAttributeKept

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
/**
 * Do nothing to an attribute if update value for it is null.
 */
public Map<String, AttributeValueUpdate> genUpdateItemsWithEmptyAttributeKept(String GSIHashKeyName, AttributeValue GSIHashKeyUpdateValue,
        String GSIRangeKeyName, AttributeValue GSIRangeKeyUpdateValue) {
    Map<String, AttributeValueUpdate> updateItems = new HashMap<String, AttributeValueUpdate>();
    
    boolean updateFound = false;
    if (GSIHashKeyName != null && GSIHashKeyUpdateValue != null) {
        updateItems.put(GSIHashKeyName, new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(GSIHashKeyUpdateValue));
        updateFound = true;
    }

    if (GSIRangeKeyName != null && GSIRangeKeyUpdateValue != null) {
        updateItems.put(GSIRangeKeyName, new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(GSIRangeKeyUpdateValue));
        updateFound = true;
    }
    
    if(updateFound) {
        violationUpdateRequests++;
    }
    return updateItems;
}
 
开发者ID:awslabs,项目名称:dynamodb-online-index-violation-detector,代码行数:24,代码来源:Correction.java


示例9: test_updateItem_WithAllParameters

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
@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));
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:27,代码来源:AmazonDynamoDBStubTest.java


示例10: updateEntityByUniqueId

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
/**
 * Move or rename entity to other folder
 * 
 * @param entity
 * 				- current entity want to move or rename
 * @param newParent
 * 				- parent of entity
 * @param newEntityName
 * 				- new name of entity
 * @param isRenamingAction
 * 				- TRUE is renaming file, otherwise FALSE
 * @return TRUE/FALSE
 */
@Override
public boolean updateEntityByUniqueId(String tableName, Entity entity, Folder newParent, 
        String newEntityName, boolean isRenamingAction) {
	HashMap<String, AttributeValue> primaryKey = new HashMap<String, AttributeValue>();
       primaryKey.put(AttributeKey.UUID, new AttributeValue().withS(entity.getId().toString()));
       
       Map<String, AttributeValueUpdate> updateItems = new HashMap<String, AttributeValueUpdate>();
       updateItems.put(AttributeKey.ENTITY_NAME, new AttributeValueUpdate()
       	.withAction(AttributeAction.PUT).withValue(new AttributeValue().withS(newEntityName)));
       updateItems.put(AttributeKey.MODIFIED_DATE, new AttributeValueUpdate()
   		.withAction(AttributeAction.PUT).withValue(new AttributeValue().withS(DateUtils.dateToString(new Date()))));
       
       if (!isRenamingAction) {
       	updateItems.put(AttributeKey.PARENT_UUID, new AttributeValueUpdate()
   			.withAction(AttributeAction.PUT).withValue(new AttributeValue()
   			.withS(newParent.getId().toString())));
       }
       
       UpdateItemResult updateStatus = dynamoDBService.updateItem(tableName, primaryKey, updateItems);
       if (updateStatus != null) {
           return true;
       }
       
	return false;
}
 
开发者ID:dgks0n,项目名称:milton-aws,代码行数:39,代码来源:DynamoDBManagerImpl.java


示例11: updateRow

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
private void updateRow(String key, String appid, Map<String, AttributeValue> row) {
	if (StringUtils.isBlank(key) || StringUtils.isBlank(appid) || row == null || row.isEmpty()) {
		return;
	}
	Map<String, AttributeValueUpdate> rou = new HashMap<>();
	try {
		for (Entry<String, AttributeValue> attr : row.entrySet()) {
			rou.put(attr.getKey(), new AttributeValueUpdate(attr.getValue(), AttributeAction.PUT));
		}
		UpdateItemRequest updateItemRequest = new UpdateItemRequest(getTableNameForAppid(appid),
				Collections.singletonMap(Config._KEY, new AttributeValue(getKeyForAppid(key, appid))), rou);
		client().updateItem(updateItemRequest);
	} catch (Exception e) {
		logger.error("Could not update row in DB - appid={}, key={}", appid, key, e);
	}
}
 
开发者ID:Erudika,项目名称:para,代码行数:17,代码来源:AWSDynamoDAO.java


示例12: toString

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
@Override
public String toString() {
    final Collection<String> terms =
        new ArrayList<String>(this.attrs.size());
    for (final Map.Entry<String, AttributeValueUpdate> attr
        : this.attrs.entrySet()) {
        terms.add(
            String.format(
                "%s=%s",
                attr.getKey(),
                attr.getValue()
            )
        );
    }
    return Joiner.on("; ").join(terms);
}
 
开发者ID:jcabi,项目名称:jcabi-dynamo,代码行数:17,代码来源:AttributeUpdates.java


示例13: storesAndReadsSingleAttribute

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
/**
 * MkRegion can store and read items.
 * @throws Exception If some problem inside
 */
@Test
public void storesAndReadsSingleAttribute() throws Exception {
    final String table = "ideas";
    final String key = "number";
    final String attr = "total";
    final Region region = new MkRegion(
        new H2Data().with(table, new String[] {key}, attr)
    );
    final Table tbl = region.table(table);
    tbl.put(
        new Attributes()
            .with(key, "32443")
            .with(attr, "0")
    );
    final Item item = tbl.frame().iterator().next();
    item.put(
        attr,
        new AttributeValueUpdate().withValue(
            new AttributeValue().withN("2")
        ).withAction(AttributeAction.PUT)
    );
    MatcherAssert.assertThat(item.get(attr).getN(), Matchers.equalTo("2"));
}
 
开发者ID:jcabi,项目名称:jcabi-dynamo,代码行数:28,代码来源:MkRegionTest.java


示例14: putThrowsException

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
/**
 * AttributesUpdates can throw exception when put is called.
 */
@Test
public void putThrowsException() {
    boolean passed;
    try {
        new AttributeUpdates().put(
            "key9", Mockito.mock(AttributeValueUpdate.class)
        );
        passed = false;
    } catch (final UnsupportedOperationException ex) {
        passed = true;
    }
    if (!passed) {
        Assert.fail("#put should not be supported");
    }
}
 
开发者ID:jcabi,项目名称:jcabi-dynamo,代码行数:19,代码来源:AttributeUpdatesTest.java


示例15: executeUpdate

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
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);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:10,代码来源:GenericDynamoDB.java


示例16: update

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
@Override
public void update(final String bash) throws IOException {
    this.item().put(
        "bash",
        new AttributeValueUpdate()
            .withValue(new AttributeValue().withS(bash))
            .withAction(AttributeAction.PUT)
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:10,代码来源:DyScript.java


示例17: flush

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
@Override
public void flush() throws IOException {
    this.item().put(
        "hour",
        new AttributeValueUpdate().withValue(
            new AttributeValue().withN("0")
        ).withAction(AttributeAction.PUT)
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:10,代码来源:DyScript.java


示例18: track

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
@Override
public void track(final long seconds) throws IOException {
    if (seconds > TimeUnit.MINUTES.toSeconds(2L)) {
        final Item item = this.item();
        item.put(
            "used",
            new AttributeValueUpdate().withValue(
                new AttributeValue().withN(Long.toString(seconds))
            ).withAction(AttributeAction.ADD)
        );
        if (this.overdue() && item.has("stripe_customer")) {
            this.rebill();
        }
    }
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:16,代码来源:DyScript.java


示例19: pay

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
@Override
public void pay(final long cents, final String token, final String email)
    throws IOException {
    final String customer;
    try {
        customer = Customer.create(
            new StickyMap<String, Object>(
                new MapEntry<>("email", email),
                new MapEntry<>("source", token)
            ),
            new RequestOptions.RequestOptionsBuilder().setApiKey(
                Manifests.read("ThreeCopies-StripeSecret")
            ).build()
        ).getId();
    } catch (final APIException | APIConnectionException
        | AuthenticationException | CardException
        | InvalidRequestException ex) {
        throw new IOException(ex);
    }
    this.item().put(
        new AttributeUpdates()
            .with(
                "stripe_cents",
                new AttributeValueUpdate().withValue(
                    new AttributeValue().withN(Long.toString(cents))
                ).withAction(AttributeAction.PUT)
            )
            .with(
                "stripe_customer",
                new AttributeValueUpdate().withValue(
                    new AttributeValue().withS(customer)
                ).withAction(AttributeAction.PUT)
            )
    );
    this.rebill();
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:37,代码来源:DyScript.java


示例20: rebill

import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; //导入依赖的package包/类
/**
 * Charge him again.
 * @throws IOException If fails
 */
private void rebill() throws IOException {
    final Item item = this.item();
    final Long cents = Long.parseLong(item.get("stripe_cents").getN());
    final String customer = item.get("stripe_customer").getS();
    try {
        Charge.create(
            new StickyMap<String, Object>(
                new MapEntry<>("amount", cents),
                new MapEntry<>("currency", "usd"),
                new MapEntry<>(
                    "description",
                    String.format("ThreeCopies: %s", this.name)
                ),
                new MapEntry<>("customer", customer)
            ),
            new RequestOptions.RequestOptionsBuilder().setApiKey(
                Manifests.read("ThreeCopies-StripeSecret")
            ).build()
        );
    } catch (final APIException | APIConnectionException
        | AuthenticationException | CardException
        | InvalidRequestException ex) {
        throw new IOException(ex);
    }
    this.item().put(
        "paid",
        new AttributeValueUpdate().withValue(
            new AttributeValue().withN(
                Long.toString(cents * TimeUnit.HOURS.toSeconds(1L))
            )
        ).withAction(AttributeAction.ADD)
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:38,代码来源:DyScript.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OtrCryptoEngineImpl类代码示例发布时间:2022-05-21
下一篇:
Java TextAreaPeer类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap