Search in sources :

Example 1 with QueryRequest

use of com.amazonaws.services.dynamodbv2.model.QueryRequest in project camel by apache.

the class QueryCommand method execute.

@Override
public void execute() {
    QueryResult result = ddbClient.query(new QueryRequest().withTableName(determineTableName()).withAttributesToGet(determineAttributeNames()).withConsistentRead(determineConsistentRead()).withExclusiveStartKey(determineStartKey()).withKeyConditions(determineKeyConditions()).withExclusiveStartKey(determineStartKey()).withLimit(determineLimit()).withScanIndexForward(determineScanIndexForward()));
    Map tmp = new HashMap<>();
    tmp.put(DdbConstants.ITEMS, result.getItems());
    tmp.put(DdbConstants.LAST_EVALUATED_KEY, result.getLastEvaluatedKey());
    tmp.put(DdbConstants.CONSUMED_CAPACITY, result.getConsumedCapacity());
    tmp.put(DdbConstants.COUNT, result.getCount());
    addToResults(tmp);
}
Also used : QueryResult(com.amazonaws.services.dynamodbv2.model.QueryResult) QueryRequest(com.amazonaws.services.dynamodbv2.model.QueryRequest) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with QueryRequest

use of com.amazonaws.services.dynamodbv2.model.QueryRequest in project camel by apache.

the class AmazonDDBClientMock method query.

@SuppressWarnings("unchecked")
@Override
public QueryResult query(QueryRequest queryRequest) {
    this.queryRequest = queryRequest;
    ConsumedCapacity consumed = new ConsumedCapacity();
    consumed.setCapacityUnits(1.0);
    Map<String, AttributeValue> lastEvaluatedKey = new HashMap<String, AttributeValue>();
    lastEvaluatedKey.put("1", new AttributeValue("LAST_KEY"));
    return new QueryResult().withConsumedCapacity(consumed).withCount(1).withItems(getAttributes()).withLastEvaluatedKey(lastEvaluatedKey);
}
Also used : AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) QueryResult(com.amazonaws.services.dynamodbv2.model.QueryResult) HashMap(java.util.HashMap) ConsumedCapacity(com.amazonaws.services.dynamodbv2.model.ConsumedCapacity)

Aggregations

QueryResult (com.amazonaws.services.dynamodbv2.model.QueryResult)2 HashMap (java.util.HashMap)2 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)1 ConsumedCapacity (com.amazonaws.services.dynamodbv2.model.ConsumedCapacity)1 QueryRequest (com.amazonaws.services.dynamodbv2.model.QueryRequest)1 Map (java.util.Map)1