Skip to content

Provide a convenient way to get all results from a com.google.gcloud.Page #330

Description

@aozarov

In cases when paging between different requests is not necessary (all results are consumed in the same request/thread) a common usage-pattern would be as such:

Page<V> page = .... get first page
while (page != null) {
  for (V v : page.values()) {
    ...do something...
  }
   page = page.nextPage();
}

or

Page<V> page = .... get first page
do {
  for (V v : page.values()) {
    ...do something...
  }
  page = page.nextPage();
} while (page != null);

To avoid this boilerplate code It would be nice to add to the Page class a method to return
an Iterator for all the results (and let that Iterator do the paging).

Some options:

(1) add a static method such as Page.iterateAll(page)
(2) an instance method such as page.allValues() or page.iterateAll() or page.fetchAll()

Any preference or other suggestions?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚨 criticalP0 critical issue. Requires immediate fixapi: coretriage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions