use of software.amazon.awssdk.services.dynamodb.paginators.ListTablesIterable in project aws-doc-sdk-examples by awsdocs.
the class SyncPagination method autoPaginationWithResume.
public static void autoPaginationWithResume(DynamoDbClient client) {
System.out.println("running AutoPagination with resume in case of errors...\n");
ListTablesRequest listTablesRequest = ListTablesRequest.builder().limit(3).build();
ListTablesIterable responses = client.listTablesPaginator(listTablesRequest);
ListTablesResponse lastSuccessfulPage = null;
try {
for (ListTablesResponse response : responses) {
response.tableNames().forEach(System.out::println);
lastSuccessfulPage = response;
}
} catch (DynamoDbException exception) {
if (lastSuccessfulPage != null) {
System.out.println(exception.getMessage());
}
}
}
use of software.amazon.awssdk.services.dynamodb.paginators.ListTablesIterable in project aws-doc-sdk-examples by awsdocs.
the class SyncPagination method autoPagination.
public static void autoPagination(DynamoDbClient client) {
System.out.println("running AutoPagination...\n");
ListTablesRequest listTablesRequest = ListTablesRequest.builder().limit(3).build();
ListTablesIterable responses = client.listTablesPaginator(listTablesRequest);
System.out.println("AutoPagination: using for loop");
for (final ListTablesResponse response : responses) {
System.out.println(response.tableNames());
}
// Print the table names using the responses stream
System.out.println("AutoPagination: using stream");
responses.stream().forEach(response -> System.out.println(response.tableNames()));
// Convert the stream of responses to stream of table names, then print the table names
System.out.println("AutoPagination: using flatmap to get stream of table names");
responses.stream().flatMap(response -> response.tableNames().stream()).forEach(System.out::println);
System.out.println("AutoPagination: iterating directly on the table names");
Iterable<String> tableNames = responses.tableNames();
tableNames.forEach(System.out::println);
}
Aggregations