public QuerySpec withScanIndexForward(boolean scanIndexForward) { getRequest().withScanIndexForward(scanIndexForward); return this; }
protected <T> QueryRequest createQueryRequestFromExpression(Class<T> clazz, DynamoDBQueryExpression<T> xpress, DynamoDBMapperConfig config) { final DynamoDBMapperTableModel<T> model = getTableModel(clazz, config); QueryRequest req = new QueryRequest(); req.setConsistentRead(xpress.isConsistentRead()); req.setTableName(getTableName(clazz, xpress.getHashKeyValues(), config)); req.setIndexName(xpress.getIndexName()); req.setKeyConditionExpression(xpress.getKeyConditionExpression()); processKeyConditions(req, xpress, model); req.withScanIndexForward(xpress.isScanIndexForward()) .withLimit(xpress.getLimit()) .withExclusiveStartKey(xpress.getExclusiveStartKey()) .withQueryFilter(xpress.getQueryFilter()) .withConditionalOperator(xpress.getConditionalOperator()) .withSelect(xpress.getSelect()) .withProjectionExpression(xpress.getProjectionExpression()) .withFilterExpression(xpress.getFilterExpression()) .withExpressionAttributeNames(xpress.getExpressionAttributeNames()) .withExpressionAttributeValues(xpress.getExpressionAttributeValues()) .withReturnConsumedCapacity(xpress.getReturnConsumedCapacity()) .withRequestMetricCollector(config.getRequestMetricCollector()) ; return applyUserAgent(req); }
public QuerySpec withScanIndexForward(boolean scanIndexForward) { getRequest().withScanIndexForward(scanIndexForward); return this; }
private static long getLastId(String tableName, String instanceName, AmazonDynamoDB dynamoClient) { QueryRequest queryRequest = new QueryRequest().withTableName(tableName) .withKeyConditionExpression("instance = :pk") .addExpressionAttributeValuesEntry(":pk", new AttributeValue().withS(instanceName)) .withScanIndexForward(false).withLimit(1); QueryResult result = dynamoClient.query(queryRequest); List<Map<String, AttributeValue>> items = result.getItems(); if (items == null || items.size() == 0) { return 0L; } else { return Long.valueOf(items.get(0).get("id").getN()); } }
@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()); } }
.withConsistentRead(true).withScanIndexForward(true) .withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL);
@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()); } }
.withTableName(tableName) .withIndexName(indexName) .withScanIndexForward(true);
.withKeyConditions(conditions) .withConsistentRead(this.consistent) .withScanIndexForward(this.forward) .withSelect(this.select) .withLimit(this.limit);
.withKeyConditions(conditions) .withConsistentRead(this.consistent) .withScanIndexForward(this.forward) .withSelect(this.select) .withLimit(this.limit);
public static QueryRequest copyQueryRequest(QueryRequest queryRequest) { QueryRequest copiedQueryRequest = new QueryRequest().withAttributesToGet(queryRequest.getAttributesToGet()) .withConsistentRead(queryRequest.getConsistentRead()) .withExclusiveStartKey(queryRequest.getExclusiveStartKey()).withIndexName(queryRequest.getIndexName()) .withKeyConditions(queryRequest.getKeyConditions()).withLimit(queryRequest.getLimit()) .withReturnConsumedCapacity(queryRequest.getReturnConsumedCapacity()) .withScanIndexForward(queryRequest.getScanIndexForward()).withSelect(queryRequest.getSelect()) .withTableName(queryRequest.getTableName()); return copiedQueryRequest; } }
protected <T> QueryRequest createQueryRequestFromExpression(Class<T> clazz, DynamoDBQueryExpression<T> xpress, DynamoDBMapperConfig config) { final DynamoDBMapperTableModel<T> model = getTableModel(clazz, config); QueryRequest req = new QueryRequest(); req.setConsistentRead(xpress.isConsistentRead()); req.setTableName(getTableName(clazz, xpress.getHashKeyValues(), config)); req.setIndexName(xpress.getIndexName()); req.setKeyConditionExpression(xpress.getKeyConditionExpression()); processKeyConditions(req, xpress, model); req.withScanIndexForward(xpress.isScanIndexForward()) .withLimit(xpress.getLimit()) .withExclusiveStartKey(xpress.getExclusiveStartKey()) .withQueryFilter(xpress.getQueryFilter()) .withConditionalOperator(xpress.getConditionalOperator()) .withSelect(xpress.getSelect()) .withProjectionExpression(xpress.getProjectionExpression()) .withFilterExpression(xpress.getFilterExpression()) .withExpressionAttributeNames(xpress.getExpressionAttributeNames()) .withExpressionAttributeValues(xpress.getExpressionAttributeValues()) .withReturnConsumedCapacity(xpress.getReturnConsumedCapacity()) .withRequestMetricCollector(config.getRequestMetricCollector()) ; return applyUserAgent(req); }