本文整理汇总了Java中com.amazonaws.services.dynamodbv2.document.RangeKeyCondition类的典型用法代码示例。如果您正苦于以下问题:Java RangeKeyCondition类的具体用法?Java RangeKeyCondition怎么用?Java RangeKeyCondition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RangeKeyCondition类属于com.amazonaws.services.dynamodbv2.document包,在下文中一共展示了RangeKeyCondition类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Override
public Iterable<MAVLinkRecord> query(String deviceId, Date startTime, Date endTime, Integer msgId) throws IOException {
RangeKeyCondition timeInterval;
if (startTime == null && endTime == null) {
timeInterval = null;
} else if (startTime == null && endTime != null) {
timeInterval = new RangeKeyCondition(ATTR_TIME).le(endTime.getTime());
} else if (startTime != null && endTime == null) {
timeInterval = new RangeKeyCondition(ATTR_TIME).ge(startTime.getTime());
} else {
timeInterval = new RangeKeyCondition(ATTR_TIME).between(startTime.getTime(), endTime.getTime());
}
QueryFilter filter = new QueryFilter(ATTR_MSG_ID).eq(msgId);
return new MAVLinkRecordIterable(table.query(ATTR_DEVICE_ID, deviceId, timeInterval, filter).iterator());
}
示例2: addRangeKeyConditionToQuerySpec
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
private static <T extends Item> void addRangeKeyConditionToQuerySpec(final QuerySpec querySpec,
final CompoundAttributeQuery compoundAttributeQuery, final Class<T> itemClass) {
final String supportingConditionStringValue = compoundAttributeQuery.getSupportingCondition().getValues().iterator()
.next();
final Operators comparisonOperator = compoundAttributeQuery.getSupportingCondition().getComparisonOperator();
final Class<?> supportingAttributeType = compoundAttributeQuery.getSupportingAttributeType(itemClass);
try {
final Object supportingConditionValue = supportingAttributeType.getConstructor(String.class).newInstance(supportingConditionStringValue);
final RangeKeyCondition rangeKeyCondition = RangeKeyConditionBuilder
.build(compoundAttributeQuery.getSupportingAttributeName(), supportingConditionValue, comparisonOperator);
querySpec.withRangeKeyCondition(rangeKeyCondition);
} catch (final Exception e) {
throw new PersistenceResourceFailureException(
String.format("Could not add range key condition for query: %s on item %s.", compoundAttributeQuery,
itemClass.getSimpleName()),
e);
}
}
示例3: build
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
public static RangeKeyCondition build(final String attributeName, final Object value,
final Operators comparisonOperator) {
Check.isNotEmptyOrNull("attributeName", attributeName);
Check.isNotNull("conditionValue", value);
final RangeKeyCondition rangeKeyCondition = new RangeKeyCondition(attributeName);
switch (comparisonOperator) {
case EQUALS:
rangeKeyCondition.eq(value);
break;
case GREATER_THAN_OR_EQUALS:
rangeKeyCondition.ge(value);
break;
case LESS_THAN_OR_EQUALS:
rangeKeyCondition.le(value);
break;
default:
throw new InvalidConditionOperatorException(String
.format("Operation %s not valid for range key condition.", comparisonOperator.toString()));
}
return rangeKeyCondition;
}
示例4: shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndEqualComparisonOperator
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Test
public void shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndEqualComparisonOperator() {
// Given
final String attributeName = randomString();
final String conditionValue = randomString();
final Operators operator = Operators.EQUALS;
// When
final RangeKeyCondition rangeKeyCondition = RangeKeyConditionBuilder.build(attributeName, conditionValue,
operator);
// Then
assertEquals(attributeName, rangeKeyCondition.getAttrName());
assertTrue(rangeKeyCondition.getValues().length == 1);
assertEquals(conditionValue, rangeKeyCondition.getValues()[0]);
assertEquals(KeyConditions.EQ, rangeKeyCondition.getKeyCondition());
}
示例5: shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndLessThanOrEqualToComparisonOperator
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Test
public void shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndLessThanOrEqualToComparisonOperator() {
// Given
final String attributeName = randomString();
final String conditionValue = randomString();
final Operators operator = Operators.LESS_THAN_OR_EQUALS;
// When
final RangeKeyCondition rangeKeyCondition = RangeKeyConditionBuilder.build(attributeName, conditionValue,
operator);
// Then
assertEquals(attributeName, rangeKeyCondition.getAttrName());
assertTrue(rangeKeyCondition.getValues().length == 1);
assertEquals(conditionValue, rangeKeyCondition.getValues()[0]);
assertEquals(KeyConditions.LE, rangeKeyCondition.getKeyCondition());
}
示例6: shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndGreaterThanOrEqualToComparisonOperator
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Test
public void shouldBuildRangeKeyCondition_withAttributeNameConditionValueAndGreaterThanOrEqualToComparisonOperator() {
// Given
final String attributeName = randomString();
final String conditionValue = randomString();
final Operators operator = Operators.GREATER_THAN_OR_EQUALS;
// When
final RangeKeyCondition rangeKeyCondition = RangeKeyConditionBuilder.build(attributeName, conditionValue,
operator);
// Then
assertEquals(attributeName, rangeKeyCondition.getAttrName());
assertTrue(rangeKeyCondition.getValues().length == 1);
assertEquals(conditionValue, rangeKeyCondition.getValues()[0]);
assertEquals(KeyConditions.GE, rangeKeyCondition.getKeyCondition());
}
示例7: lt
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Override
public <V> QueryItemsBuilder<T> lt(V value) {
if ( "".equals(value) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
_spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
.lt(value));
return this;
}
示例8: le
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Override
public <V> QueryItemsBuilder<T> le(V value) {
if ( "".equals(value) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
_spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
.le(value));
return this;
}
示例9: gt
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Override
public <V> QueryItemsBuilder<T> gt(V value) {
if ( "".equals(value) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
_spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
.gt(value));
return this;
}
示例10: ge
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Override
public <V> QueryItemsBuilder<T> ge(V value) {
if ( "".equals(value) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
_spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
.ge(value));
return this;
}
示例11: between
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Override
public <V> QueryItemsBuilder<T> between(V value1, V value2) {
if ( "".equals(value1) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
if ( "".equals(value2) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
_spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
.between(value1, value2));
return this;
}
示例12: beginsWith
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Override
public QueryItemsBuilder<T> beginsWith(String value) {
if ( "".equals(value) ) throw new UnsupportedOperationException("Attempt to compare with empty string");
_spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
.beginsWith(value));
return this;
}
示例13: shouldBuild_withCompoundAttributeQuery
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Test
public void shouldBuild_withCompoundAttributeQuery() {
// Given
final String attributeName = randomString(10);
final String supportingAttributeName = randomString(10);
final Condition condition = randomCondition(1);
final Condition supportingCondition = randomCondition(1);
final CompoundAttributeQuery compoundAttributeQuery = mock(CompoundAttributeQuery.class);
final RangeKeyCondition mockRangeKeyCondition = mock(RangeKeyCondition.class);
final String expectedValue = condition.getValues().iterator().next();
final String expectedSupportingValue = supportingCondition.getValues().iterator().next();
final Operators expectedSupportingComparisonOperator = supportingCondition.getComparisonOperator();
when(compoundAttributeQuery.getAttributeName()).thenReturn(attributeName);
when(compoundAttributeQuery.getCondition()).thenReturn(condition);
when(compoundAttributeQuery.getSupportingCondition()).thenReturn(supportingCondition);
Mockito.<Class<?>> when(compoundAttributeQuery.getSupportingAttributeType(any())).thenReturn(String.class);
when(compoundAttributeQuery.getSupportingAttributeName()).thenReturn(supportingAttributeName);
when(RangeKeyConditionBuilder.build(supportingAttributeName, expectedSupportingValue,
expectedSupportingComparisonOperator)).thenReturn(mockRangeKeyCondition);
// When
final QuerySpec querySpec = QuerySpecBuilder.build(compoundAttributeQuery,
StubWithGlobalSecondaryIndexItem.class);
// Then
assertEquals(attributeName, querySpec.getHashKey().getName());
assertEquals(expectedValue, querySpec.getHashKey().getValue());
assertEquals(mockRangeKeyCondition, querySpec.getRangeKeyCondition());
}
示例14: eq
import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition; //导入依赖的package包/类
@Override
public <V> QueryItemsBuilder<T> eq(V value) {
_spec.withRangeKeyCondition(new RangeKeyCondition(_rkName)
.eq(toDDBEmptyString(value)));
return this;
}