本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.ComparisonOperator类的典型用法代码示例。如果您正苦于以下问题:Java ComparisonOperator类的具体用法?Java ComparisonOperator怎么用?Java ComparisonOperator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComparisonOperator类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了ComparisonOperator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expired
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的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.ComparisonOperator; //导入依赖的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.ComparisonOperator; //导入依赖的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.ComparisonOperator; //导入依赖的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.ComparisonOperator; //导入依赖的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: accountGetAccountByToken
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的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;
}
示例7: execute
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的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"));
}
示例8: addExpectedValueIfPresent
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的package包/类
private void addExpectedValueIfPresent(final StaticBuffer column, final Map<String, ExpectedAttributeValue> expectedValueMap) {
final String dynamoDbColumn = encodeKeyBuffer(column);
if (expectedValueMap.containsKey(dynamoDbColumn)) {
return;
}
if (transaction.contains(store, key, column)) {
final StaticBuffer expectedValue = transaction.get(store, key, column);
final ExpectedAttributeValue expectedAttributeValue;
if (expectedValue == null) {
expectedAttributeValue = new ExpectedAttributeValue().withExists(false);
} else {
final AttributeValue attributeValue = encodeValue(expectedValue);
expectedAttributeValue = new ExpectedAttributeValue().withValue(attributeValue)
.withComparisonOperator(ComparisonOperator.EQ);
}
expectedValueMap.put(dynamoDbColumn, expectedAttributeValue);
}
}
开发者ID:awslabs,项目名称:dynamodb-janusgraph-storage-backend,代码行数:21,代码来源:SingleExpectedAttributeValueBuilder.java
示例9: findRootFolder
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的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);
}
示例10: findEntityByParent
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的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;
}
示例11: findEntityByParentAndType
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的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;
}
示例12: getLandUnits
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的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;
}
示例13: queryValue
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的package包/类
/**
* Return the stored value for a label and date value at the configured time
* granularity
*
* @param label
* The Aggregated Label Value to get data for
* @param dateValue
* The Date Value to obtain data from
* @param h
* The Time Horizon to query
* @return
*/
public List<Map<String, AttributeValue>> queryValue(String label,
Date dateValue, ComparisonOperator comp) throws Exception {
if (!(this.dataStore instanceof DynamoDataStore)) {
throw new Exception(
"Unable to Query by Date unless Data Store is Dynamo DB");
}
if (comp != null && comp.equals(ComparisonOperator.BETWEEN)) {
throw new InvalidConfigurationException(
"Between Operator Not Supported");
}
return ((DynamoDataStore) this.dataStore).queryEngine().queryByKey(
label, dateValue, comp);
}
示例14: getMaxVersion
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的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: handle
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; //导入依赖的package包/类
@Override
public void handle(Event event) {
final EventData eventData = event.getEventData();
try {
final String bookId = new String(eventData.getData().get("bookId").toString());
final String userId = new String(eventData.getData().get("userId").toString());
final Book book = this.repository.get(Key.create(bookId));
if(Book.CHECKED_OUT_BY_NOBODY.equals(book.getCheckedOutBy())){
book.setCheckedOutBy(userId);
this.repository.saveIf(book,ComparisonOperator.EQ, "checkedOutBy", Book.CHECKED_OUT_BY_NOBODY);
LOGGER.info("=========================== SAVING BOOK CHECKOUT REQUEST ===========================");
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}