Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
aozarov opened this issue Nov 6, 2015 · 2 comments · Fixed by #333
Closed

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

aozarov opened this issue Nov 6, 2015 · 2 comments · Fixed by #333
Assignees
Labels
api: core 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@aozarov
Copy link
Contributor

aozarov commented Nov 6, 2015

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?

@aozarov aozarov changed the title Provide a convenient way to get *all* results from a com.google.gcloud.Page Provide a convenient way to get all results from a com.google.gcloud.Page Nov 6, 2015
@mziccard
Copy link
Contributor

mziccard commented Nov 6, 2015

I would prefer an instance method. I would also not use allValues as we alredy have a values method that returns Iterable instead. My preference is iterateAll or simply iterator provided that we document what the method does.

@aozarov
Copy link
Contributor Author

aozarov commented Nov 6, 2015

Sure, I like iterateAll better than iterator for being more explicit.

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
github-actions bot pushed a commit to suztomo/google-cloud-java that referenced this issue Jun 29, 2022
This PR was generated using Autosynth. 🌈


<details><summary>Log from Synthtool</summary>

```
2020-12-14 19:59:27,827 synthtool [DEBUG] > Executing /root/.cache/synthtool/java-resourcemanager/.github/readme/synth.py.
On branch autosynth-readme
nothing to commit, working tree clean
2020-12-14 19:59:28,685 synthtool [DEBUG] > Wrote metadata to .github/readme/synth.metadata/synth.metadata.

```
</details>

Full log will be available here:
https://source.cloud.google.com/results/invocations/ce177fa3-8170-4c5a-b80c-ffee762181b6/targets

- [ ] To automatically regenerate this PR, check this box.
github-actions bot pushed a commit that referenced this issue Jul 1, 2022
…s to v2.0.2 (#330)

* chore(deps): update dependency com.google.cloud:google-cloud-workflows to v2.0.2

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
github-actions bot pushed a commit that referenced this issue Jul 14, 2022
github-actions bot pushed a commit that referenced this issue Jul 27, 2022
- [ ] Regenerate this pull request now.

chore(bazel): update gax-java to 2.18.4

PiperOrigin-RevId: 463115700

Source-Link: googleapis/googleapis@52130a9

Source-Link: https://github.com/googleapis/googleapis-gen/commit/6a4d9d9bb3afb20b0f5fa4f5d9f6740b1d0eb19a
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmE0ZDlkOWJiM2FmYjIwYjBmNWZhNGY1ZDlmNjc0MGIxZDBlYjE5YSJ9
github-actions bot pushed a commit that referenced this issue Aug 1, 2022
- [ ] Regenerate this pull request now.

chore:remove LRO to API list

PiperOrigin-RevId: 463893258

Source-Link: googleapis/googleapis@e47c0cd

Source-Link: https://github.com/googleapis/googleapis-gen/commit/8df6a6a605ff4032486c8e9a30366a99b4874666
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOGRmNmE2YTYwNWZmNDAzMjQ4NmM4ZTlhMzAzNjZhOTliNDg3NDY2NiJ9
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
🤖 I have created a release *beep* *boop*
---


## [2.3.8](googleapis/java-contact-center-insights@v2.3.7...v2.3.8) (2022-08-09)


### Documentation

* Updating comments ([#330](googleapis/java-contact-center-insights#330)) ([f39e2a4](googleapis/java-contact-center-insights@f39e2a4))


### Dependencies

* update dependency com.google.cloud:google-cloud-bigquery to v2.14.0 ([#328](googleapis/java-contact-center-insights#328)) ([f6c0048](googleapis/java-contact-center-insights@f6c0048))
* update dependency com.google.cloud:google-cloud-bigquery to v2.14.1 ([#329](googleapis/java-contact-center-insights#329)) ([d91008c](googleapis/java-contact-center-insights@d91008c))
* update dependency com.google.cloud:google-cloud-bigquery to v2.14.2 ([#337](googleapis/java-contact-center-insights#337)) ([8fc9eec](googleapis/java-contact-center-insights@8fc9eec))
* update dependency com.google.cloud:google-cloud-bigquery to v2.14.3 ([#338](googleapis/java-contact-center-insights#338)) ([63a6788](googleapis/java-contact-center-insights@63a6788))
* update dependency com.google.cloud:google-cloud-pubsub to v1.120.10 ([#336](googleapis/java-contact-center-insights#336)) ([5189bf6](googleapis/java-contact-center-insights@5189bf6))
* update dependency com.google.cloud:google-cloud-pubsub to v1.120.8 ([#334](googleapis/java-contact-center-insights#334)) ([eb9519d](googleapis/java-contact-center-insights@eb9519d))
* update dependency com.google.cloud:google-cloud-pubsub to v1.120.9 ([#335](googleapis/java-contact-center-insights#335)) ([66cde14](googleapis/java-contact-center-insights@66cde14))
* update dependency com.google.cloud:google-cloud-shared-dependencies to v3 ([#331](googleapis/java-contact-center-insights#331)) ([11af982](googleapis/java-contact-center-insights@11af982))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
suztomo pushed a commit that referenced this issue Feb 1, 2023
🤖 I have created a release *beep* *boop*
---


### [1.3.1](googleapis/java-iam@v1.3.0...v1.3.1) (2022-04-11)


### Dependencies

* revert dependency com.google.protobuf:protobuf-java to v3.19.4 ([#329](googleapis/java-iam#329)) ([dee765a](googleapis/java-iam@dee765a))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: core 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants