我想扫描我的 Dynamo db 表并对其应用分页。在我的请求中,我想从我想要开始分页的地方发送号码。说,例如,我发送的请求的 start = 3 和 limit = 10,其中 start 是我希望扫描从表中的第三个项目开始,而限制最多为 10 个项目。但是我可以使用 .withLimit() 方法来实现限制(我使用的是 java)。我遵循了这个aws 文档。以下是我想要实现的代码:
<Map<String, AttributeValue>> mapList = new ArrayList<>();
AmazonDynamoDB client =AmazonDynamoDBClientBuilder.standard().build();
Gson gson = new GsonBuilder().serializeNulls().create();
Map<String, AttributeValue> expressionAttributeValues = new
HashMap<String,AttributeValue>();
expressionAttributeValues.put(":name",
newAttributeValue().withS(name));
List<ResponseDomain> domainList = new ArrayList<>();
ResponseDomain responseDomain = null;
//lastKeyEvaluated = start
Map<String, AttributeValue> lastKeyEvaluated = null;
do {
ScanRequest scanRequest = new
ScanRequest().withTableName(STUDENT_TABLE)
.withProjectionExpression("studentId, studentName")
.withFilterExpression("begins_with(studentName, :name)")
.withExpressionAttributeValues(expressionAttributeValues).
withExclusiveStartKey(lastKeyEvaluated);
ScanResult result = client.scan(scanRequest);
for (Map<String, AttributeValue> …
Run Code Online (Sandbox Code Playgroud) database pagination json amazon-web-services amazon-dynamodb