خرید بک لینک

Vote count: 0

I am trying to understand the difference between two following code segments. One uses pages to get scan results, and the second one doesn't. I am wondering whether the second approach would work if the total number of items in the database is very large? AWS docs say that scan result is limited by 1 Mb. How does this affect version 2? Will it only get first 1 mb of results or would it still make database calls after each page?

Note that I am using table.scan API, which is different from DynamoDBClient.scan api. See http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/document/Table.html for API details.

Version 1 (using pages):

            ItemCollection<ScanOutcome> items = table.scan(spec);
            items.pages().forEach(page -> {
                for (Item item : page) {
                    response.add(item);
                }
            });

Version 2 (iterating over items without pages):

            ItemCollection<ScanOutcome> items = table.scan(spec);
            for (Item item : items) {
                    response.add(item);
            }

asked 23 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 23 شهريور 1395 ساعت: 10:41

صفحه بندی