com.amazonaws.services.dynamodbv2.model.QueryRequest.withScanIndexForward()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中com.amazonaws.services.dynamodbv2.model.QueryRequest.withScanIndexForward方法的一些代码示例,展示了QueryRequest.withScanIndexForward的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryRequest.withScanIndexForward方法的具体详情如下:
包路径:com.amazonaws.services.dynamodbv2.model.QueryRequest
类名称:QueryRequest
方法名:withScanIndexForward

QueryRequest.withScanIndexForward介绍

[英]Specifies the order for index traversal: If true (default), the traversal is performed in ascending order; if false, the traversal is performed in descending order.

Items with the same partition key value are stored in sorted order by sort key. If the sort key data type is Number, the results are stored in numeric order. For type String, the results are stored in order of UTF-8 bytes. For type Binary, DynamoDB treats each byte of the binary data as unsigned.

If ScanIndexForward is true, DynamoDB returns the results in the order in which they are stored (by sort key value). This is the default behavior. If ScanIndexForward is false, DynamoDB reads the results in reverse order by sort key value, and then returns the results to the client.

Returns a reference to this object so that method calls can be chained together.
[中]指定索引遍历的顺序:如果true(默认),则按升序执行遍历;如果false,则按降序执行遍历。
具有相同分区键值的项按排序键的顺序存储。如果排序键数据类型为数字,则结果将按数字顺序存储。对于类型字符串,结果以UTF-8字节的顺序存储。对于Binary类型,DynamoDB将二进制数据的每个字节视为无符号。
如果ScanIndexForwardtrue,DynamoDB将按存储顺序(按排序键值)返回结果。这是默认行为。如果ScanIndexForwardfalse,DynamoDB会按排序键值的相反顺序读取结果,然后将结果返回给客户端。
返回对此对象的引用,以便将方法调用链接在一起。

代码示例

代码示例来源:origin: aws/aws-sdk-java

public QuerySpec withScanIndexForward(boolean scanIndexForward) {
  getRequest().withScanIndexForward(scanIndexForward);
  return this;
}

代码示例来源:origin: aws/aws-sdk-java

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);
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-dynamodb

public QuerySpec withScanIndexForward(boolean scanIndexForward) {
  getRequest().withScanIndexForward(scanIndexForward);
  return this;
}

代码示例来源:origin: sndyuk/logback-more-appenders

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());
  }
}

代码示例来源:origin: com.amazonaws/aws-dynamodb-encryption-java

@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());
  }
}

代码示例来源:origin: aws-samples/aws-dynamodb-examples

.withConsistentRead(true).withScanIndexForward(true)
.withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL);

代码示例来源:origin: aws/aws-dynamodb-encryption-java

@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());
  }
}

代码示例来源:origin: aws-samples/aws-dynamodb-examples

.withTableName(tableName)
.withIndexName(indexName)
.withScanIndexForward(true);

代码示例来源:origin: com.jcabi/jcabi-dynamo

.withKeyConditions(conditions)
.withConsistentRead(this.consistent)
.withScanIndexForward(this.forward)
.withSelect(this.select)
.withLimit(this.limit);

代码示例来源:origin: jcabi/jcabi-dynamo

.withKeyConditions(conditions)
.withConsistentRead(this.consistent)
.withScanIndexForward(this.forward)
.withSelect(this.select)
.withLimit(this.limit);

代码示例来源:origin: amazon-archives/dynamodb-geo

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;
  }
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-dynamodb

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);
}

相关文章

微信公众号

最新文章

更多

QueryRequest类方法