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


Java AttributeValue类代码示例

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


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

示例1: update

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的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: fetchTheValue

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
private void fetchTheValue() {

        final GetItemRequest req = new GetItemRequest().withAttributesToGet("value")
                .withTableName(TableName)
                .withKey(Collections.singletonMap("id", new AttributeValue(this.id)));
        try {
            final GetItemResult result = ddb.getItem(req);
            synchronized (this.monitor) {
                if (result.getItem() == null) {
                    this.x = new RuntimeException("not found: id=" + this.id);
                } else {
                    this.v = result.getItem().get("value").getS();
                    if (this.v == null) {
                        this.x = new RuntimeException("found but no value for: id=" + this.id);
                    }
                }
            }
        } catch (final RuntimeException x) {
            synchronized (this.monitor) {
                this.x = x;
            }
        }

    }
 
开发者ID:aztecrex,项目名称:java-translatebot,代码行数:25,代码来源:DBValueRetriever.java

示例3: getUnprocessedCpcPlusMetaData

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
/**
 * Queries the DynamoDB GSI for unprocessed {@link Metadata} with a maximum of 96 items.
 *
 * Iterates over all of the different partitions, returning a maximum of three items from each.
 *
 * @return {@link List} of unprocessed {@link Metadata}
 */
public List<Metadata> getUnprocessedCpcPlusMetaData() {

	return IntStream.range(0, Constants.CPC_DYNAMO_PARTITIONS).mapToObj(partition -> {
		Map<String, AttributeValue> valueMap = new HashMap<>();
		valueMap.put(":cpcValue", new AttributeValue().withS(Constants.CPC_DYNAMO_PARTITION_START + partition));
		valueMap.put(":cpcProcessedValue", new AttributeValue().withS("false"));

		DynamoDBQueryExpression<Metadata> metadataQuery = new DynamoDBQueryExpression<Metadata>()
			.withIndexName("Cpc-CpcProcessed_CreateDate-index")
			.withKeyConditionExpression(Constants.DYNAMO_CPC_ATTRIBUTE + " = :cpcValue and begins_with(" +
				Constants.DYNAMO_CPC_PROCESSED_CREATE_DATE_ATTRIBUTE + ", :cpcProcessedValue)")
			.withExpressionAttributeValues(valueMap)
			.withConsistentRead(false)
			.withLimit(LIMIT);

		return mapper.queryPage(Metadata.class, metadataQuery).getResults().stream();
	}).flatMap(Function.identity()).collect(Collectors.toList());
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:26,代码来源:DbServiceImpl.java

示例4: get

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
/**
 * Get ticket.
 *
 * @param ticketId the ticket id
 * @return the ticket
 */
public Ticket get(final String ticketId) {
    final TicketDefinition metadata = this.ticketCatalog.find(ticketId);
    if (metadata != null) {
        final Map<String, AttributeValue> keys = new HashMap<>();

        keys.put(ColumnNames.ID.getName(), new AttributeValue(ticketId));
        final GetItemRequest request = new GetItemRequest()
                .withKey(keys)
                .withTableName(metadata.getProperties().getStorageName());

        LOGGER.debug("Submitting request [{}] to get ticket item [{}]", request, ticketId);

        final Map<String, AttributeValue> returnItem = amazonDynamoDBClient.getItem(request).getItem();
        if (returnItem != null) {
            final Ticket ticket = deserializeTicket(returnItem);
            LOGGER.debug("Located ticket [{}]", ticket);
            return ticket;
        }
    } else {
        LOGGER.warn("No ticket definition could be found in the catalog to match [{}]", ticketId);
    }
    return null;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:30,代码来源:DynamoDbTicketRegistryFacilitator.java

示例5: getNodes

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
@Override
public Map<String, AttributeValue> getNodes(WebsiteModel websiteModel) {

    try
    {
        ObjectMapper mapper = new ObjectMapper();
        String string = mapper.writeValueAsString(websiteModel);
        Item item = new Item().withJSON(Utils.params.nodes, string);
        return InternalUtils.toAttributeValues(item);
    }
    catch (JsonProcessingException e)
    {
        LOG.error(e.getMessage());
    }

    return new HashMap<>();
}
 
开发者ID:hafidsousa,项目名称:webcrawler,代码行数:18,代码来源:CrawlerBatchService.java

示例6: putItemResultMono

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
private Mono<Map<String, AttributeValue>> putItemResultMono(
        String seedUrl,
        EStatus status,
        String title,
        WebsiteModel websiteModel
) {

    PutItemRequest putItemRequest = new PutItemRequest();
    putItemRequest.setTableName(Utils.table.websites);

    Map<String, AttributeValue> newWebsite = new HashMap<>();

    if (Objects.nonNull(websiteModel)) newWebsite = crawlerBatchService.getNodes(websiteModel);
    newWebsite.put(Utils.params.url, new AttributeValue(seedUrl));
    newWebsite.put(Utils.params.status, new AttributeValue(status.name()));
    if (StringUtils.isNotEmpty(title)) newWebsite.put(Utils.params.title, new AttributeValue(title));

    putItemRequest.setItem(newWebsite);

    return Mono.fromFuture(
            Utils.makeCompletableFuture(
                    dynamoDBAsync.putItemAsync(putItemRequest)))
            .doOnError((throwable -> LOG.error(Utils.error.failed_dynamo_put, seedUrl)))
            .doOnSuccess((a) -> LOG.info(Utils.success.saved_dynamo, String.format("%s [%s]", seedUrl, status)))
            .map(((result) -> putItemRequest.getItem()));
}
 
开发者ID:hafidsousa,项目名称:webcrawler,代码行数:27,代码来源:CrawlerBatchTask.java

示例7: expired

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
@Override
public Iterable<Take> expired() {
    return new Mapped<>(
        this.table()
            .frame()
            .through(
                new QueryValve()
                    .withIndexName("expired")
                    .withConsistentRead(false)
                    .withSelect(Select.ALL_ATTRIBUTES)
            )
            .where("success", Conditions.equalTo(Boolean.toString(false)))
            .where(
                "when",
                new Condition()
                    .withComparisonOperator(ComparisonOperator.LT)
                    .withAttributeValueList(
                        new AttributeValue().withN(
                            Long.toString(System.currentTimeMillis())
                        )
                    )
            ),
        item -> new DyTake(item, this.delay)
    );
}
 
开发者ID:yegor256,项目名称:rehttp,代码行数:26,代码来源:DyBase.java

示例8: create

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的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

示例9: createAttributes

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的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

示例10: ocket

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
@Override
public String ocket(final long time) throws IOException {
    final Iterator<Item> items = this.region.table("logs")
        .frame()
        .through(new QueryValve().withLimit(1))
        .where("group", this.group())
        .where(
            "start",
            new Condition()
                .withComparisonOperator(ComparisonOperator.EQ)
                .withAttributeValueList(
                    new AttributeValue().withN(Long.toString(time))
                )
        )
        .iterator();
    if (!items.hasNext()) {
        throw new RsForward(
            new RsFlash("Can't find log"),
            "/scripts"
        );
    }
    return items.next().get("ocket").getS();
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:24,代码来源:DyScript.java

示例11: createsOnlyThreeOpenLogs

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的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

示例12: item

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
/**
 * The item to work with.
 * @return Item to work with
 * @throws Exception If some problem inside
 */
private static Item item() throws Exception {
    final Region region = new MkRegion(
        new H2Data().with(
            "domains",
            new String[] {"domain"},
            "owner", "usage", "total"
        )
    );
    final Table table = region.table("domains");
    table.put(
        new Attributes()
            .with("domain", "yegor256.com")
            .with("owner", new AttributeValue("yegor256"))
            .with("usage", new AttributeValue("<usage/>"))
            .with("total", new AttributeValue().withN("0"))
    );
    return table.frame()
        .where("domain", "yegor256.com")
        .iterator().next();
}
 
开发者ID:yegor256,项目名称:jare,代码行数:26,代码来源:DyUsageTest.java

示例13: execute

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
@Test
public void execute() {
    Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
    key.put("1", new AttributeValue("Key_1"));
    Map<String, AttributeValue> unprocessedKey = new HashMap<String, AttributeValue>();
    unprocessedKey.put("1", new AttributeValue("UNPROCESSED_KEY"));
    Map<String, KeysAndAttributes> keysAndAttributesMap = new HashMap<String, KeysAndAttributes>();
    KeysAndAttributes keysAndAttributes = new KeysAndAttributes().withKeys(key);
    keysAndAttributesMap.put("DOMAIN1", keysAndAttributes);
    exchange.getIn().setHeader(DdbConstants.BATCH_ITEMS, keysAndAttributesMap);

    command.execute();

    assertEquals(keysAndAttributesMap, ddbClient.batchGetItemRequest.getRequestItems());


    List<Map<String, AttributeValue>> batchResponse = (List<Map<String, AttributeValue>>)exchange.getIn().getHeader(DdbConstants.BATCH_RESPONSE, Map.class).get("DOMAIN1");
    AttributeValue value = batchResponse.get(0).get("attrName");

    KeysAndAttributes unProcessedAttributes = (KeysAndAttributes)exchange.getIn().getHeader(
            DdbConstants.UNPROCESSED_KEYS, Map.class).get("DOMAIN1");
    Map<String, AttributeValue> next = unProcessedAttributes.getKeys().iterator().next();

    assertEquals(new AttributeValue("attrValue"), value);
    assertEquals(unprocessedKey, next);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:BatchGetItemsCommandTest.java

示例14: createItemIfNotExists

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
boolean createItemIfNotExists(String key, long currentTimeMillis, Context context) {

		LambdaLogger logger = context.getLogger();
		AmazonDynamoDB client = createDynamoDBClient(cc);
		String functionName = context.getFunctionName();

		try {
			// Create a record if it does not exist
			PutItemRequest req = new PutItemRequest().withTableName(TABLE_NAME)
					.addItemEntry(COL_FUNCTION_NAME, new AttributeValue(functionName))
					.addItemEntry(COL_KEY, new AttributeValue(key))
					.addItemEntry(COL_CREATED_TIME, new AttributeValue().withN(Long.toString(currentTimeMillis)))
					.addExpectedEntry(COL_FUNCTION_NAME, new ExpectedAttributeValue().withExists(false))
					.addExpectedEntry(COL_KEY, new ExpectedAttributeValue().withExists(false));
			client.putItem(req);
			return true;
		} catch (ConditionalCheckFailedException e) {
			logger.log("Record exsited. functionName[" + functionName + "] key[" + key + "]");
			return false;
		} finally {
			client.shutdown();
		}
	}
 
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:24,代码来源:LambdaLock.java

示例15: getAttributeSizeBytes

import com.amazonaws.services.dynamodbv2.model.AttributeValue; //导入依赖的package包/类
private static int getAttributeSizeBytes(AttributeValue att) throws UnsupportedEncodingException {
  int byteSize = 0;
  if (att.getN() != null) {
    byteSize += att.getN().getBytes(CHARACTER_ENCODING).length;
  } else if (att.getS() != null) {
    byteSize += att.getS().getBytes(CHARACTER_ENCODING).length;
  } else if (att.getB() != null) {
    byteSize += att.getB().array().length;
  } else if (att.getNS() != null) {
    for (String number : att.getNS()) {
      byteSize += number.getBytes(CHARACTER_ENCODING).length;
    }
  } else if (att.getSS() != null) {
    for (String string : att.getSS()) {
      byteSize += string.getBytes(CHARACTER_ENCODING).length;
    }
  } else if (att.getBS() != null) {
    for (ByteBuffer byteBuffer : att.getBS()) {
      byteSize += byteBuffer.array().length;
    }
  }
  return byteSize;
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:24,代码来源:DynamoDBUtil.java


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