网站开发word文档,安卓app整站织梦网站源码,建设工程有限公司企业网站,外贸营销邮件主题一般怎么写dynamodb容器使用之前#xff0c;我们介绍了如何使用DynamoDBMapper或底层Java api查询DynamoDB数据库。 除了发出查询之外#xff0c;DynamoDB还提供扫描功能。 扫描的目的是获取您在DynamoDB表上可能拥有的所有项目。 因此#xff0c;扫描不需要任何基于我们的分区键或… dynamodb容器使用 之前我们介绍了如何使用DynamoDBMapper或底层Java api查询DynamoDB数据库。 除了发出查询之外DynamoDB还提供扫描功能。 扫描的目的是获取您在DynamoDB表上可能拥有的所有项目。 因此扫描不需要任何基于我们的分区键或您的全局/本地二级索引的规则。 扫描提供的功能是基于已获取的项目进行过滤并从已获取的项目中返回特定属性。 下面的代码段通过过滤具有较低日期的项目来对“登录名”表进行扫描。 public ListLogin scanLogins(Long date) {MapString, String attributeNames new HashMapString, String();attributeNames.put(#timestamp, timestamp);MapString, AttributeValue attributeValues new HashMapString, AttributeValue();attributeValues.put(:from, new AttributeValue().withN(date.toString()));DynamoDBScanExpression dynamoDBScanExpression new DynamoDBScanExpression().withFilterExpression(#timestamp :from).withExpressionAttributeNames(attributeNames).withExpressionAttributeValues(attributeValues);ListLogin logins dynamoDBMapper.scan(Login.class, dynamoDBScanExpression);return logins;} DynamoDBMapper的另一个重要功能是并行扫描。 并行扫描将扫描任务划分为多个工作程序每个逻辑段一个。 工作人员并行处理数据并返回结果。 通常扫描请求的性能在很大程度上取决于DynamoDB表中存储的项目数。 因此并行扫描可能会解除扫描请求的某些性能问题因为您必须处理大量数据。 public ListLogin scanLogins(Long date,Integer workers) {MapString, String attributeNames new HashMapString, String();attributeNames.put(#timestamp, timestamp);MapString, AttributeValue attributeValues new HashMapString, AttributeValue();attributeValues.put(:from, new AttributeValue().withN(date.toString()));DynamoDBScanExpression dynamoDBScanExpression new DynamoDBScanExpression().withFilterExpression(#timestamp :from).withExpressionAttributeNames(attributeNames).withExpressionAttributeValues(attributeValues);ListLogin logins dynamoDBMapper.parallelScan(Login.class, dynamoDBScanExpression,workers);return logins;} 在对我们的应用程序使用扫描之前我们必须考虑到扫描会获取所有表项。 因此它在费用和性能上都有很高的成本。 此外它可能会消耗您的配置容量。 通常最好坚持查询并避免扫描。 您可以在github上找到带有单元测试的完整源代码。 翻译自: https://www.javacodegeeks.com/2016/10/scan-dynamodb-items-dynamodbmapper.htmldynamodb容器使用