From 988a4c454d697e35627d02bd7e5ca235d5932bc2 Mon Sep 17 00:00:00 2001 From: Ayush Walekar Date: Thu, 26 May 2022 12:33:34 +0530 Subject: [PATCH] docs(samples): update querypagination sample - Updated example to loop through all remaining pages --- .../java/com/example/bigquery/QueryPagination.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java b/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java index dc9a6a24f..86915bab7 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java +++ b/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java @@ -62,19 +62,11 @@ public static void queryPagination(String datasetName, String tableName, String .getValues() .forEach(row -> row.forEach(val -> System.out.printf("%s,\n", val.toString()))); - if (results.hasNextPage()) { - // Next Page - results - .getNextPage() - .getValues() - .forEach(row -> row.forEach(val -> System.out.printf("%s,\n", val.toString()))); - } - - if (results.hasNextPage()) { + while (results.hasNextPage()) { // Remaining Pages + results = results.getNextPage(); results - .getNextPage() - .iterateAll() + .getValues() .forEach(row -> row.forEach(val -> System.out.printf("%s,\n", val.toString()))); }