I need to get all rows from my DynamoDB table. There are approximately 500k records and every time I call scan method from Java SDK DynamoDBMapper I get different number of rows. So I tried to use scanPage method and use lastEvaluationKey from ScanResultPage object for pagination (because I think query result set size limit is 1MB) thinking it will work. But I get same result. I did something like this:
List<String> ids = new ArrayList<>();
DynamoDBScanExpression dynamoDBScanExpression = new DynamoDBScanExpression();
do {
ScanResultPage<EntityObject> scanResultPage = dynamoDBMapper.scanPage(EntityObject.class,
dynamoDBScanExpression);
scanResultPage.getResults().forEach(result -> ids.add(result.getId()));
log.info("Last evaluated key: {}", scanResultPage.getLastEvaluatedKey());
dynamoDBScanExpression.setExclusiveStartKey(scanResultPage.getLastEvaluatedKey());
} while (dynamoDBScanExpression.getExclusiveStartKey() != null);
What can I do to actually get all rows?