本文整理汇总了Java中com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression.withHashKeyValues方法的典型用法代码示例。如果您正苦于以下问题:Java DynamoDBQueryExpression.withHashKeyValues方法的具体用法?Java DynamoDBQueryExpression.withHashKeyValues怎么用?Java DynamoDBQueryExpression.withHashKeyValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression
的用法示例。
在下文中一共展示了DynamoDBQueryExpression.withHashKeyValues方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression; //导入方法依赖的package包/类
/**
* Run Queries against dynamodb
* @param clazz
* @param itemKey
* @param indexName
* @param operator
* @param rangeKeyConditions
* @param limit
* @param consistentRead
* @return items
*/
public <T> List<T> query(final Class<T> clazz, final T itemKey, final String indexName, final ConditionalOperator operator, final Map<String, Condition> rangeKeyConditions, final int limit, final boolean consistentRead){
final DynamoDBQueryExpression<T> expression = new DynamoDBQueryExpression<T>();
expression.withHashKeyValues(itemKey);
expression.withConsistentRead(consistentRead);
/**
* Optional Query parameters
*/
if(!Strings.isNullOrEmpty(indexName)){
expression.withIndexName(indexName);
}
if(operator!=null){
expression.withConditionalOperator(operator);
}
if(rangeKeyConditions != null && rangeKeyConditions.size()>0){
expression.withRangeKeyConditions(rangeKeyConditions);
}
if(limit>0){
expression.withLimit(limit);
}
List<T> items = this.query(clazz, expression);
if(items==null){
return new ArrayList<T>();
}else{
return items;
}
}
示例2: getRanges
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression; //导入方法依赖的package包/类
/***
* Get range keys for a given hashKey
* @param clazz
* @param itemHash
* @return rangeKeys
*/
public <T> List<T> getRanges(final Class<T> clazz, final T itemHash, int limit, Map<String, AttributeValue> startKey){
final Map<String, AttributeValue> starKey = Maps.newHashMap();
final DynamoDBQueryExpression<T> query = new DynamoDBQueryExpression<T>();
query.withHashKeyValues(itemHash);
if(limit>0 && starKey!=null){
query.withLimit(limit);
query.withExclusiveStartKey(starKey);
}
return this.mapper.query(clazz, query);
}
示例3: getDrafts
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression; //导入方法依赖的package包/类
@Override
public List<RecipeDraft> getDrafts(int userId) throws IOException {
RecipeDraft recipeDraft = new RecipeDraft();
recipeDraft.setUserId(userId);
DynamoDBQueryExpression<RecipeDraft> queryExpression = new DynamoDBQueryExpression<>();
queryExpression.withHashKeyValues(recipeDraft);
return mapper.query(RecipeDraft.class, queryExpression);
}
示例4: countDrafts
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression; //导入方法依赖的package包/类
@Override
public int countDrafts(int userId) throws IOException {
RecipeDraft recipeDraft = new RecipeDraft();
recipeDraft.setUserId(userId);
DynamoDBQueryExpression<RecipeDraft> queryExpression = new DynamoDBQueryExpression<>();
queryExpression.withHashKeyValues(recipeDraft);
return mapper.count(RecipeDraft.class, queryExpression);
}
示例5: buildQueryExpression
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression; //导入方法依赖的package包/类
public DynamoDBQueryExpression<T> buildQueryExpression() {
DynamoDBQueryExpression<T> queryExpression = new DynamoDBQueryExpression<T>();
if (isHashKeySpecified()) {
T hashKeyPrototype = entityInformation.getHashKeyPropotypeEntityForHashKey(getHashKeyPropertyValue());
queryExpression.withHashKeyValues(hashKeyPrototype);
queryExpression.withRangeKeyConditions(new HashMap<String, Condition>());
}
if (isRangeKeySpecified() && !isApplicableForGlobalSecondaryIndex()) {
Condition rangeKeyCondition = createSingleValueCondition(getRangeKeyPropertyName(), ComparisonOperator.EQ,
getRangeKeyAttributeValue(), getRangeKeyAttributeValue().getClass(), true);
queryExpression.withRangeKeyCondition(getRangeKeyAttributeName(), rangeKeyCondition);
applySortIfSpecified(queryExpression, Arrays.asList(new String[] { getRangeKeyPropertyName() }));
} else if (isOnlyASingleAttributeConditionAndItIsOnEitherRangeOrIndexRangeKey()
|| (isApplicableForGlobalSecondaryIndex())) {
Entry<String, List<Condition>> singlePropertyConditions = propertyConditions.entrySet().iterator().next();
List<String> allowedSortProperties = new ArrayList<String>();
for (Entry<String, List<Condition>> singlePropertyCondition : propertyConditions.entrySet()) {
if (entityInformation.getGlobalSecondaryIndexNamesByPropertyName().keySet()
.contains(singlePropertyCondition.getKey())) {
allowedSortProperties.add(singlePropertyCondition.getKey());
}
}
if (allowedSortProperties.size() == 0) {
allowedSortProperties.add(singlePropertyConditions.getKey());
}
for (Entry<String, List<Condition>> singleAttributeConditions : attributeConditions.entrySet()) {
for (Condition condition : singleAttributeConditions.getValue()) {
queryExpression.withRangeKeyCondition(singleAttributeConditions.getKey(), condition);
}
}
applySortIfSpecified(queryExpression, allowedSortProperties);
if (getGlobalSecondaryIndexName() != null) {
queryExpression.setIndexName(getGlobalSecondaryIndexName());
}
} else {
applySortIfSpecified(queryExpression, Arrays.asList(new String[] { getRangeKeyPropertyName() }));
}
return queryExpression;
}
开发者ID:michaellavelle,项目名称:spring-data-dynamodb,代码行数:47,代码来源:DynamoDBEntityWithHashAndRangeKeyCriteria.java