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

Add iterateAll method to Page, update example and snippet #333

Merged
merged 2 commits into from
Nov 9, 2015

Conversation

mziccard
Copy link
Contributor

@mziccard mziccard commented Nov 6, 2015

This PR fixes #330.

  • Add an iterateAll method to Page interface and implements the iterator in PageImpl.
  • Add unit test
  • Update snippet and storage example

@mziccard mziccard added api: core api: storage Issues related to the Cloud Storage API. labels Nov 6, 2015
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 6, 2015
@mziccard mziccard force-pushed the all-pages-iterator branch 2 times, most recently from 7468113 to 22c655e Compare November 6, 2015 11:34
@@ -35,6 +37,50 @@
Page<T> nextPage();
}

static class PageIterator<T> implements java.util.Iterator<T> {

This comment was marked as spam.

@mziccard
Copy link
Contributor Author

mziccard commented Nov 6, 2015

Fixed in place.

Page<T> nextPage = currentPage.nextPage();
if (nextPage != null) {
currentPage = nextPage;
currentPageIterator = currentPage.values().iterator();

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@mziccard
Copy link
Contributor Author

mziccard commented Nov 7, 2015

Sorry to insist but I am just trying to understand.

At some point the service might give up before any row matched the criteria returning an empty result but with a cursor to allow continuing the listing from the point it stopped.

According to which criteria? Is this documented somewhere?
In the GCS docs I read that the pageToken points to the last item in the returned list (i.e. not the last seen before giving up):

The pageToken is an encoded field representing the name and generation of the last object in the returned list.

So in your example what does prevent the next page request to give up again at the same point returning an empty result list?

I am being picky because I don't want to add a loop if I am not sure according to which criteria it terminates.

@aozarov
Copy link
Contributor

aozarov commented Nov 7, 2015

No problem. The questions are great!

In the GCS docs I read that the pageToken points to the last item in the returned list (i.e. not the last seen before giving up):

Yes, you are right. I also verified that with @BrandonY a while back.
In the case of GCS it will always return at least one value or it will timeout.
I think that is a poor choice of the service and would rather have it behave like Datastore
which can make progress even without returning a result (due to time limit per request), and
let the timeout option be done by the client-side.

So in your example what does prevent the next page request to give up again at the same point
returning an empty result list?

Nothing stop also the next result to be empty, this is why it is in a loop.

I am being picky because I don't want to add a loop if I am not sure according to which criteria it terminates.

The only true indication that there are "no-more-results" is a null nextPageCursor.
which is exactly what the previous "example"/code-snippet that we provided did.

@mziccard
Copy link
Contributor Author

mziccard commented Nov 7, 2015

Yes, you are right. I also verified that with @BrandonY a while back.
In the case of GCS it will always return at least one value or it will timeout.

This confused me, indeed. Thanks for the clarifications!
I added the loop.

aozarov added a commit that referenced this pull request Nov 9, 2015
Add iterateAll method to Page, update example and snippet
@aozarov aozarov merged commit 0a04229 into googleapis:master Nov 9, 2015
github-actions bot pushed a commit that referenced this pull request Jul 1, 2022
…s to v2.1.0 (#333)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:google-cloud-workflows](https://togithub.com/googleapis/java-workflows) | `2.0.2` -> `2.1.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-workflows/2.1.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-workflows/2.1.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-workflows/2.1.0/compatibility-slim/2.0.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-workflows/2.1.0/confidence-slim/2.0.2)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/java-workflows</summary>

### [`v2.1.0`](https://togithub.com/googleapis/java-workflows/blob/master/CHANGELOG.md#&#8203;210-httpswwwgithubcomgoogleapisjava-workflowscomparev202v210-2021-09-01)

[Compare Source](https://togithub.com/googleapis/java-workflows/compare/v2.0.2...v2.1.0)

##### Features

-   Remove use of deprecated gradle command in java README ([#&#8203;1196](https://www.togithub.com/googleapis/java-workflows/issues/1196)) ([#&#8203;327](https://www.togithub.com/googleapis/java-workflows/issues/327)) ([5525ccd](https://www.github.com/googleapis/java-workflows/commit/5525ccd9eb08a07be773aaee773812a6c42ec483))

##### Dependencies

-   update dependency com.google.cloud:google-cloud-shared-dependencies to v2.2.0 ([#&#8203;329](https://www.togithub.com/googleapis/java-workflows/issues/329)) ([c8cf2d8](https://www.github.com/googleapis/java-workflows/commit/c8cf2d848689b49beb398d9be088d7da1d1c1107))

##### [2.0.2](https://www.github.com/googleapis/java-workflows/compare/v2.0.1...v2.0.2) (2021-08-23)

##### Dependencies

-   update dependency com.google.cloud:google-cloud-shared-dependencies to v2.1.0 ([#&#8203;321](https://www.togithub.com/googleapis/java-workflows/issues/321)) ([332dfd5](https://www.github.com/googleapis/java-workflows/commit/332dfd508eaac6f6ca2d2f5b463df3c80ae9e435))

##### [2.0.1](https://www.github.com/googleapis/java-workflows/compare/v2.0.0...v2.0.1) (2021-08-12)

##### Dependencies

-   update dependency com.google.cloud:google-cloud-shared-dependencies to v2.0.1 ([#&#8203;315](https://www.togithub.com/googleapis/java-workflows/issues/315)) ([a187352](https://www.github.com/googleapis/java-workflows/commit/a1873529849dd569be91758e5f70fa94233a9c21))

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-workflows).
github-actions bot pushed a commit that referenced this pull request Jul 18, 2022
…-info-reports-plugin to v3.4.0 (#333)

[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.apache.maven.plugins:maven-project-info-reports-plugin](https://maven.apache.org/plugins/) ([source](https://togithub.com/apache/maven-project-info-reports-plugin)) | `3.3.0` -> `3.4.0` | [![age](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-project-info-reports-plugin/3.4.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-project-info-reports-plugin/3.4.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-project-info-reports-plugin/3.4.0/compatibility-slim/3.3.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-project-info-reports-plugin/3.4.0/confidence-slim/3.3.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-workflow-executions).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMTcuNCIsInVwZGF0ZWRJblZlciI6IjMyLjExNy40In0=-->
github-actions bot pushed a commit that referenced this pull request Aug 9, 2022
…to v3.7.0 (#333)

[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:google-cloud-channel](https://togithub.com/googleapis/java-) | `3.6.1` -> `3.7.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-channel/3.7.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-channel/3.7.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-channel/3.7.0/compatibility-slim/3.6.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-channel/3.7.0/confidence-slim/3.6.1)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-channel).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMzUuMSIsInVwZGF0ZWRJblZlciI6IjMyLjEzNS4xIn0=-->
github-actions bot pushed a commit that referenced this pull request Aug 9, 2022
…center-insights to v2.3.6 (#333)

[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:google-cloud-contact-center-insights](https://togithub.com/googleapis/java-contact-center-insights) | `2.3.3` -> `2.3.6` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-contact-center-insights/2.3.6/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-contact-center-insights/2.3.6/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-contact-center-insights/2.3.6/compatibility-slim/2.3.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-contact-center-insights/2.3.6/confidence-slim/2.3.3)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/java-contact-center-insights</summary>

### [`v2.3.6`](https://togithub.com/googleapis/java-contact-center-insights/blob/HEAD/CHANGELOG.md#&#8203;236-httpsgithubcomgoogleapisjava-contact-center-insightscomparev235v236-2022-07-11)

[Compare Source](https://togithub.com/googleapis/java-contact-center-insights/compare/v2.3.5...v2.3.6)

##### Bug Fixes

-   update gapic-generator-java with mock service generation fixes ([#&#8203;306](https://togithub.com/googleapis/java-contact-center-insights/issues/306)) ([45c0a15](https://togithub.com/googleapis/java-contact-center-insights/commit/45c0a15b1b1657d67fdf7bb2e808e47d99f43b6f))

### [`v2.3.5`](https://togithub.com/googleapis/java-contact-center-insights/blob/HEAD/CHANGELOG.md#&#8203;235-httpsgithubcomgoogleapisjava-contact-center-insightscomparev234v235-2022-07-01)

[Compare Source](https://togithub.com/googleapis/java-contact-center-insights/compare/v2.3.4...v2.3.5)

##### Dependencies

-   update dependency com.google.cloud:google-cloud-bigquery to v2.13.8 ([#&#8203;311](https://togithub.com/googleapis/java-contact-center-insights/issues/311)) ([6912a2b](https://togithub.com/googleapis/java-contact-center-insights/commit/6912a2b135e249c12d66c2b6da9f5617d57d1a3d))
-   update dependency com.google.cloud:google-cloud-pubsub to v1.120.0 ([#&#8203;315](https://togithub.com/googleapis/java-contact-center-insights/issues/315)) ([853b7a7](https://togithub.com/googleapis/java-contact-center-insights/commit/853b7a7e5d83afea0682ae987d092c234a1d1201))

### [`v2.3.4`](https://togithub.com/googleapis/java-contact-center-insights/blob/HEAD/CHANGELOG.md#&#8203;234-httpsgithubcomgoogleapisjava-contact-center-insightscomparev233v234-2022-06-30)

[Compare Source](https://togithub.com/googleapis/java-contact-center-insights/compare/v2.3.3...v2.3.4)

##### Documentation

-   Updating comments ([13f7937](https://togithub.com/googleapis/java-contact-center-insights/commit/13f79379f3cf01e4525fcbe2f6834354751b57fa))

##### Dependencies

-   update dependency com.google.cloud:google-cloud-bigquery to v2.13.3 ([#&#8203;303](https://togithub.com/googleapis/java-contact-center-insights/issues/303)) ([192f667](https://togithub.com/googleapis/java-contact-center-insights/commit/192f667b695b64e457611eefc2005676c099e7d4))
-   update dependency com.google.cloud:google-cloud-bigquery to v2.13.4 ([#&#8203;304](https://togithub.com/googleapis/java-contact-center-insights/issues/304)) ([62a8663](https://togithub.com/googleapis/java-contact-center-insights/commit/62a86636da8f642054f88124604eff11b46c0ef7))
-   update dependency com.google.cloud:google-cloud-bigquery to v2.13.5 ([#&#8203;307](https://togithub.com/googleapis/java-contact-center-insights/issues/307)) ([3fad9d0](https://togithub.com/googleapis/java-contact-center-insights/commit/3fad9d0e780c32d55e348a8c2faa9f36289553b7))
-   update dependency com.google.cloud:google-cloud-bigquery to v2.13.6 ([#&#8203;308](https://togithub.com/googleapis/java-contact-center-insights/issues/308)) ([da0694b](https://togithub.com/googleapis/java-contact-center-insights/commit/da0694b7b948fafa3a09a563e20ec52f0c7d71ef))
-   update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#&#8203;305](https://togithub.com/googleapis/java-contact-center-insights/issues/305)) ([8e7c000](https://togithub.com/googleapis/java-contact-center-insights/commit/8e7c0008512a82ab26a6dce8ed795483a710a4cf))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-contact-center-insights).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMzUuMSIsInVwZGF0ZWRJblZlciI6IjMyLjEzNS4xIn0=-->
github-actions bot pushed a commit to renovate-bot/google-cloud-java that referenced this pull request Nov 19, 2022
…s#1687) (googleapis#333)

* chore(java): add a note in README for migrated split repos

Disable renovate bot and flaky bot for split repositories
that have moved to the Java monorepo.
The Java monorepo will pass the "monorepo=True" parameter
to java.common_templates method in its owlbot.py files so that
the migration note will not appear in the README in the monorepo.

Co-authored-by: Jeff Ching <chingor@google.com>
Source-Link: googleapis/synthtool@d4b2916
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:edae91ccdd2dded2f572ec341a768ad180305a3e8fbfd93064b28e237d35920a

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Jeff Ching <chingor@google.com>
suztomo pushed a commit that referenced this pull request Feb 1, 2023
🤖 I have created a release *beep* *boop*
---


### [1.3.2](googleapis/java-iam@v1.3.1...v1.3.2) (2022-04-15)


### Dependencies

* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.10.0 ([#332](googleapis/java-iam#332)) ([21e926c](googleapis/java-iam@21e926c))

---
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 api: storage Issues related to the Cloud Storage API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a convenient way to get all results from a com.google.gcloud.Page
3 participants