本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.Condition类的典型用法代码示例。如果您正苦于以下问题:Java Condition类的具体用法?Java Condition怎么用?Java Condition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Condition类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了Condition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expired
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的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)
);
}
示例2: ocket
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的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();
}
示例3: executeOperation
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
@Override
public boolean executeOperation() {
final FoodDO itemToFind = new FoodDO();
itemToFind.setFoodId(getDemoPartitionValue());
final Condition rangeKeyCondition = new Condition()
.withComparisonOperator(ComparisonOperator.LT.toString())
.withAttributeValueList(new AttributeValue().withS(DEMO_SORT_VALUE));
final DynamoDBQueryExpression<FoodDO> queryExpression = new DynamoDBQueryExpression<FoodDO>()
.withHashKeyValues(itemToFind)
.withRangeKeyCondition(DEMO_SORT_KEY, rangeKeyCondition)
.withConsistentRead(false)
.withLimit(RESULTS_PER_RESULT_GROUP);
results = mapper.query(FoodDO.class, queryExpression);
if (results != null) {
resultsIterator = results.iterator();
if (resultsIterator.hasNext()) {
return true;
}
}
return false;
}
示例4: executeOperation
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
@Override
public boolean executeOperation() {
final ListDO itemToFind = new ListDO();
itemToFind.setUserId(getDemoPartitionValue());
final Condition rangeKeyCondition = new Condition()
.withComparisonOperator(ComparisonOperator.LT.toString())
.withAttributeValueList(new AttributeValue().withS(DEMO_SORT_VALUE));
final DynamoDBQueryExpression<ListDO> queryExpression = new DynamoDBQueryExpression<ListDO>()
.withHashKeyValues(itemToFind)
.withRangeKeyCondition(DEMO_SORT_KEY, rangeKeyCondition)
.withConsistentRead(false)
.withLimit(RESULTS_PER_RESULT_GROUP);
results = mapper.query(ListDO.class, queryExpression);
if (results != null) {
resultsIterator = results.iterator();
if (resultsIterator.hasNext()) {
return true;
}
}
return false;
}
示例5: executeOperation
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
@Override
public boolean executeOperation() {
final CommentDO itemToFind = new CommentDO();
itemToFind.setUserId(getDemoPartitionValue());
final Condition rangeKeyCondition = new Condition()
.withComparisonOperator(ComparisonOperator.LT.toString())
.withAttributeValueList(new AttributeValue().withS(DEMO_SORT_VALUE));
final DynamoDBQueryExpression<CommentDO> queryExpression = new DynamoDBQueryExpression<CommentDO>()
.withHashKeyValues(itemToFind)
.withRangeKeyCondition(DEMO_SORT_KEY, rangeKeyCondition)
.withConsistentRead(false)
.withLimit(RESULTS_PER_RESULT_GROUP);
results = mapper.query(CommentDO.class, queryExpression);
if (results != null) {
resultsIterator = results.iterator();
if (resultsIterator.hasNext()) {
return true;
}
}
return false;
}
示例6: scanTable
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
public RetryResult<ScanResult> scanTable(
String tableName, DynamoDBQueryFilter dynamoDBQueryFilter, Integer segment, Integer
totalSegments, Map<String, AttributeValue> exclusiveStartKey, long limit, Reporter reporter) {
final ScanRequest scanRequest = new ScanRequest(tableName)
.withExclusiveStartKey(exclusiveStartKey)
.withLimit(Ints.checkedCast(limit))
.withSegment(segment)
.withTotalSegments(totalSegments)
.withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL);
if (dynamoDBQueryFilter != null) {
Map<String, Condition> scanFilter = dynamoDBQueryFilter.getScanFilter();
if (!scanFilter.isEmpty()) {
scanRequest.setScanFilter(scanFilter);
}
}
RetryResult<ScanResult> retryResult = getRetryDriver().runWithRetry(new Callable<ScanResult>() {
@Override
public ScanResult call() {
log.debug("Executing DynamoDB scan: " + scanRequest);
return dynamoDB.scan(scanRequest);
}
}, reporter, PrintCounter.DynamoDBReadThrottle);
return retryResult;
}
示例7: accountGetAccountByToken
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
public Account accountGetAccountByToken(String token) {
Condition hashKeyCondition = new Condition();
hashKeyCondition.withComparisonOperator(ComparisonOperator.EQ).withAttributeValueList(new AttributeValue().withS(token));
Map<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put("accountToken", hashKeyCondition);
QueryRequest queryRequest = new QueryRequest();
queryRequest.withTableName("accountsv2");
queryRequest.withIndexName("accountToken-index");
queryRequest.withKeyConditions(keyConditions);
QueryResult result = dynamoDB.query(queryRequest);
for(Map<String, AttributeValue> item : result.getItems()) {
Account mappedItem = mapper.marshallIntoObject(Account.class, item);
// Only want the First one
return mappedItem;
}
return null;
}
示例8: execute
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
@Test
public void execute() {
Map<String, Condition> scanFilter = new HashMap<String, Condition>();
Condition condition = new Condition()
.withComparisonOperator(ComparisonOperator.GT.toString())
.withAttributeValueList(new AttributeValue().withN("1985"));
scanFilter.put("year", condition);
exchange.getIn().setHeader(DdbConstants.SCAN_FILTER, scanFilter);
command.execute();
Map<String, AttributeValue> mapAssert = new HashMap<String, AttributeValue>();
mapAssert.put("1", new AttributeValue("LAST_KEY"));
ConsumedCapacity consumed = (ConsumedCapacity) exchange.getIn().getHeader(DdbConstants.CONSUMED_CAPACITY);
assertEquals(scanFilter, ddbClient.scanRequest.getScanFilter());
assertEquals(Integer.valueOf(10), exchange.getIn().getHeader(DdbConstants.SCANNED_COUNT, Integer.class));
assertEquals(Integer.valueOf(1), exchange.getIn().getHeader(DdbConstants.COUNT, Integer.class));
assertEquals(Double.valueOf(1.0), consumed.getCapacityUnits());
assertEquals(mapAssert, exchange.getIn().getHeader(DdbConstants.LAST_EVALUATED_KEY, Map.class));
Map<?, ?> items = (Map<?, ?>) exchange.getIn().getHeader(DdbConstants.ITEMS, List.class).get(0);
assertEquals(new AttributeValue("attrValue"), items.get("attrName"));
}
示例9: populateScanExpression
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
private void populateScanExpression(List<Expression<?>> expressions, Condition condition,
DynamoDBScanExpression scanExpression) {
List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
String attributeName = null;
for (Expression<?> expression : expressions) {
Object result = expression.accept(this, scanExpression);
if (result instanceof String) {
if (attributeName != null) {
throw new RuntimeException("Already in use");
}
attributeName = (String) result;
} else if (result instanceof AttributeValue) {
attributeValueList.add((AttributeValue) result);
} else {
throw new UnsupportedOperationException("Invalid result: " + result);
}
}
condition.setAttributeValueList(attributeValueList);
scanExpression.addFilterCondition(attributeName, condition);
}
示例10: findRootFolder
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
/**
* The findRootFolder method retrieves an root item
*
* @return
*/
@Override
public Folder findRootFolder(String tableName) {
Condition condition = new Condition().withComparisonOperator(ComparisonOperator.EQ.toString())
.withAttributeValueList(new AttributeValue().withS(AttributeKey.NOT_EXIST));
Map<String, Condition> conditions = new HashMap<String, Condition>();
conditions.put(AttributeKey.PARENT_UUID, condition);
List<Map<String, AttributeValue>> items = dynamoDBService.getItem(tableName, conditions);
List<Entity> children = DynamoDBEntityMapper.convertItemsToEntities(null, items);
if (children == null || children.isEmpty()) {
return null;
}
return (Folder) children.get(0);
}
示例11: findEntityByParent
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
/**
* The findEntityByParent method enables you to retrieve multiple items
* from one table.
*
* @param parent
* @return
*/
@Override
public List<Entity> findEntityByParent(String tableName, Folder parent) {
if (parent == null) {
return Collections.emptyList();
}
Condition condition = new Condition().withComparisonOperator(ComparisonOperator.EQ.toString())
.withAttributeValueList(new AttributeValue().withS(parent.getId().toString()));
Map<String, Condition> conditions = new HashMap<String, Condition>();
conditions.put(AttributeKey.PARENT_UUID, condition);
List<Map<String, AttributeValue>> items = dynamoDBService.getItem(tableName, conditions);
List<Entity> children = DynamoDBEntityMapper.convertItemsToEntities(parent, items);
if (children == null || children.isEmpty()) {
return Collections.emptyList();
}
return children;
}
示例12: findEntityByParentAndType
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
/**
* The findEntityByParentAndType method enables you to retrieve multiple items
* from one table.
*
* @param parent
* @param isDirectory
* @return a list of entities
*/
@Override
public List<Entity> findEntityByParentAndType(String tableName, Folder parent, boolean isDirectory) {
if (parent == null) {
return Collections.emptyList();
}
Map<String, Condition> conditions = new HashMap<String, Condition>();
Condition parentUniqueId = new Condition().withComparisonOperator(ComparisonOperator.EQ.toString())
.withAttributeValueList(new AttributeValue().withS(parent.getId().toString()));
conditions.put(AttributeKey.PARENT_UUID, parentUniqueId);
Condition entityType = new Condition().withComparisonOperator(ComparisonOperator.EQ.toString())
.withAttributeValueList(new AttributeValue().withN(Integer.toString(isDirectory ? 1 : 0)));
conditions.put(AttributeKey.IS_DIRECTORY, entityType);
List<Map<String, AttributeValue>> items = dynamoDBService.getItem(tableName, conditions);
List<Entity> children = DynamoDBEntityMapper.convertItemsToEntities(parent, items);
if (children == null || children.isEmpty()) {
return Collections.emptyList();
}
return children;
}
示例13: getLandUnits
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
@Override
public List<LandUnit> getLandUnits(Long userId) {
List<LandUnit> retval = new ArrayList<LandUnit>();
try {
/*
* Scan items for movies with user id attribute.
*/
Map<String, Condition> scanFilter = new HashMap<String, Condition>();
Condition condition = new Condition()
.withComparisonOperator(ComparisonOperator.EQ.toString())
.withAttributeValueList(new AttributeValue().withN(userId.toString()));
scanFilter.put(LandUnit.USER_ID_ATTR_NAME, condition);
ScanRequest scanRequest =
new ScanRequest(LANDUNIT_DYNAMO_DB_TABLE_NAME).withScanFilter(scanFilter);
ScanResult scanResult = dynamoDB.scan(scanRequest);
LOG.debug("DDB Scan Result: " + scanResult);
retval = mapItemsToLandUnit(scanResult.getItems());
} catch (Exception e) {
LOG.error("Unable to retrieve land units from DDB " + e.getMessage());
}
return retval;
}
示例14: getMaxVersion
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
@Override
public long getMaxVersion(final String materialName) {
final List<Map<String, AttributeValue>> items = ddb.query(
new QueryRequest()
.withTableName(tableName)
.withConsistentRead(Boolean.TRUE)
.withKeyConditions(
Collections.singletonMap(
DEFAULT_HASH_KEY,
new Condition().withComparisonOperator(
ComparisonOperator.EQ).withAttributeValueList(
new AttributeValue().withS(materialName))))
.withLimit(1).withScanIndexForward(false)
.withAttributesToGet(DEFAULT_RANGE_KEY)).getItems();
if (items.isEmpty()) {
return -1L;
} else {
return Long.parseLong(items.get(0).get(DEFAULT_RANGE_KEY).getN());
}
}
示例15: removeAccessTokenUsingRefreshToken
import com.amazonaws.services.dynamodbv2.model.Condition; //导入依赖的package包/类
public void removeAccessTokenUsingRefreshToken(String refreshToken) {
String tokenId = null;
try {
tokenId = dynamoDBTemplate.queryUnique(schema.getAccessTableName(), schema.getAccessIndexRefreshToken(), //
Collections.singletonMap(schema.getAccessColumnRefreshToken(), new Condition().withAttributeValueList(new AttributeValue(extractTokenKey(refreshToken))).withComparisonOperator(ComparisonOperator.EQ)),//
new ObjectExtractor<String>() {
public String extract(Map<String, AttributeValue> values) {
return values.get(schema.getAccessColumnTokenId()).getS();
}
}, schema.getAccessColumnTokenId());
} catch (EmptyResultDataAccessException | IncorrectResultSizeDataAccessException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Failed to find access token for refresh token " + refreshToken);
}
}
if (tokenId == null) {
return;
}
dynamoDBTemplate.delete(schema.getAccessTableName(), Collections.singletonMap(schema.getAccessColumnTokenId(), new AttributeValue(tokenId)));
}