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

setMaxResults doesn't seem to work for Cloud Storage API #1511

Closed
johanhaleby opened this issue Jan 6, 2017 · 8 comments
Closed

setMaxResults doesn't seem to work for Cloud Storage API #1511

johanhaleby opened this issue Jan 6, 2017 · 8 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API.

Comments

@johanhaleby
Copy link

johanhaleby commented Jan 6, 2017

I'm using:

<dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>gcloud-java</artifactId>
            <version>0.2.8</version>
</dependency>

which transitively depends on com.google.apis:google-api-services-storage:v1-rev62-1.21.0 and I have the following code:

Storage storage = ...
storage.objects().list(bucket).setMaxResults((long) Integer.MAX_VALUE).execute().getItems();

However the number of items are still 1000 (which is the default value) regardless of the value I pass to setMaxResults:

System.out.println(storage.objects().list(bucket).setMaxResults((long) Integer.MAX_VALUE).execute().size());

This yields 1000 as result.

@garrettjonesgoogle
Copy link
Member

garrettjonesgoogle commented Jan 11, 2017

Could you try using a more recent version? The artifact is now named google-cloud-java and the latest version is 0.8.1.

@garrettjonesgoogle garrettjonesgoogle added the api: storage Issues related to the Cloud Storage API. label Jan 11, 2017
@johanhaleby
Copy link
Author

Oh I was unaware of the change of artifactId, thanks for the hint. I'll try to look into it in a few days if that's ok.

@johanhaleby
Copy link
Author

Is google-cloud-java in maven central? I can't seem to find it.

@garrettjonesgoogle
Copy link
Member

Oops sorry, the artifact is named google-cloud.

@garrettjonesgoogle
Copy link
Member

@johanhaleby , were you able to try out the new version?

@vam-google
Copy link
Contributor

vam-google commented Jan 31, 2017

Looks like it is by design. Though I agree, the API signature, naming and documentation are confusing.
Apparently Storage.setMaxResults() sets the maximum size for the results page, and the maximum allowed value for it is 1000 (not properly documented).

As a workaround the following code can be used (it will successfully read > 1000 objects, page by page):

public class MyStorageExample {

  public static void main(String[] args) throws GeneralSecurityException, IOException {
    Storage.Builder sb = new Builder(
        GoogleNetHttpTransport.newTrustedTransport(),
        new JacksonFactory(),
        null);
    Storage storage = sb.build();

    Objects objects;
    String pageToken = null;
    final long maxPageSize = 1000L; // 1000 is the maximum possible value
    final String bucketName = "<YOUR_BUCKET_NAME>";

    do {
      objects = storage
          .objects()
          .list(bucketName)
          .setMaxResults(maxPageSize)
          .setPageToken(pageToken)
          .execute();
      pageToken = objects.getNextPageToken();
      if(objects.getItems() != null) {
        System.out.println(objects.getItems().size());
      }
    } while (pageToken != null);
  }
}

@johanhaleby
Copy link
Author

johanhaleby commented Feb 2, 2017

@vam-google I'm using something similar to what you're describing. I think it would be nice to improve the docs a bit to make it clear that 1000 is the maximum value.

Thanks for the support everyone.

@vam-google
Copy link
Contributor

The documentation and default value was updated for the Storage API, and will be available in the never version, once it is released. Closing the issue.

github-actions bot pushed a commit that referenced this issue Aug 9, 2022
…) (#859)

Fixes #1502
Source-Link: googleapis/synthtool@26ea255
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7a9a7eb50ca2af5bfffab3abd2f38d408735c990a74bacf9b7fde2af0a086a0b
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
…) (#796)

Fixes #1502
Source-Link: googleapis/synthtool@26ea255
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7a9a7eb50ca2af5bfffab3abd2f38d408735c990a74bacf9b7fde2af0a086a0b
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
…) (#901)

Fixes #1502
Source-Link: googleapis/synthtool@26ea255
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7a9a7eb50ca2af5bfffab3abd2f38d408735c990a74bacf9b7fde2af0a086a0b
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
…) (#973)

Fixes #1502
Source-Link: googleapis/synthtool@26ea255
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7a9a7eb50ca2af5bfffab3abd2f38d408735c990a74bacf9b7fde2af0a086a0b
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
…) (#294)

Fixes #1502
Source-Link: googleapis/synthtool@26ea255
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7a9a7eb50ca2af5bfffab3abd2f38d408735c990a74bacf9b7fde2af0a086a0b
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
…) (#729)

Fixes #1502
Source-Link: googleapis/synthtool@26ea255
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7a9a7eb50ca2af5bfffab3abd2f38d408735c990a74bacf9b7fde2af0a086a0b
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
…) (#945)

Fixes #1502
Source-Link: googleapis/synthtool@26ea255
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7a9a7eb50ca2af5bfffab3abd2f38d408735c990a74bacf9b7fde2af0a086a0b
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
…) (#77)

Fixes #1502
Source-Link: googleapis/synthtool@26ea255
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7a9a7eb50ca2af5bfffab3abd2f38d408735c990a74bacf9b7fde2af0a086a0b
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
…) (#768)

Fixes #1502
Source-Link: googleapis/synthtool@26ea255
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7a9a7eb50ca2af5bfffab3abd2f38d408735c990a74bacf9b7fde2af0a086a0b
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
🤖 I have created a release *beep* *boop*
---


## [2.3.3](googleapis/java-scheduler@v2.3.2...v2.3.3) (2022-08-05)


### Documentation

* **owlbot-java:** explaining why not using formatter in pom.xml ([#1511](https://github.com/googleapis/java-scheduler/issues/1511)) ([#796](googleapis/java-scheduler#796)) ([0b6e26f](googleapis/java-scheduler@0b6e26f)), closes [#1502](https://github.com/googleapis/java-scheduler/issues/1502)


### Dependencies

* update dependency com.google.cloud:google-cloud-pubsub-bom to v1.120.10 ([#795](googleapis/java-scheduler#795)) ([39cd11f](googleapis/java-scheduler@39cd11f))
* update dependency com.google.cloud:google-cloud-shared-dependencies to v3 ([#792](googleapis/java-scheduler#792)) ([62a3aee](googleapis/java-scheduler@62a3aee))

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


## [3.4.0](googleapis/java-monitoring@v3.3.6...v3.4.0) (2022-08-06)


### Features

* Added support for evaluating missing data in AlertPolicy ([#906](googleapis/java-monitoring#906)) ([e51e43c](googleapis/java-monitoring@e51e43c))


### Documentation

* **owlbot-java:** explaining why not using formatter in pom.xml ([#1511](https://github.com/googleapis/java-monitoring/issues/1511)) ([#901](googleapis/java-monitoring#901)) ([bb07735](googleapis/java-monitoring@bb07735)), closes [#1502](https://github.com/googleapis/java-monitoring/issues/1502)

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


## [2.3.6](googleapis/java-tasks@v2.3.5...v2.3.6) (2022-08-05)


### Documentation

* **owlbot-java:** explaining why not using formatter in pom.xml ([#1511](https://github.com/googleapis/java-tasks/issues/1511)) ([#729](googleapis/java-tasks#729)) ([ad9bcd2](googleapis/java-tasks@ad9bcd2)), closes [#1502](https://github.com/googleapis/java-tasks/issues/1502)

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


## [3.6.7](googleapis/java-dlp@v3.6.6...v3.6.7) (2022-08-05)


### Documentation

* **owlbot-java:** explaining why not using formatter in pom.xml ([#1511](https://github.com/googleapis/java-dlp/issues/1511)) ([#945](googleapis/java-dlp#945)) ([f29bd22](googleapis/java-dlp@f29bd22)), closes [#1502](https://github.com/googleapis/java-dlp/issues/1502)

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


## [1.1.7](googleapis/java-optimization@v1.1.6...v1.1.7) (2022-08-06)


### Documentation

* **owlbot-java:** explaining why not using formatter in pom.xml ([#1511](https://github.com/googleapis/java-optimization/issues/1511)) ([#77](googleapis/java-optimization#77)) ([7177414](googleapis/java-optimization@7177414)), closes [#1502](https://github.com/googleapis/java-optimization/issues/1502)

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


## [4.8.0](googleapis/java-dialogflow@v4.7.5...v4.8.0) (2022-08-05)


### Features

* deprecated the filter field and add resource_definition ([d58232f](googleapis/java-dialogflow@d58232f))
* provide new parameter cx_current_page, the unique identifier of the CX page to override the `current_page` in the session. Add filter field to ListAnswerRecordsRequest. And add AudioInput to analysis requests ([d58232f](googleapis/java-dialogflow@d58232f))


### Dependencies

* update dependency com.google.cloud:google-cloud-core to v2.8.8 ([#979](googleapis/java-dialogflow#979)) ([aee2eab](googleapis/java-dialogflow@aee2eab))


### Documentation

* add more meaningful comments ([d58232f](googleapis/java-dialogflow@d58232f))
* add more meaningful comments ([d58232f](googleapis/java-dialogflow@d58232f))
* added an explicit note that DetectIntentRequest's text input is limited by 256 characters ([d58232f](googleapis/java-dialogflow@d58232f))
* **owlbot-java:** explaining why not using formatter in pom.xml ([#1511](https://github.com/googleapis/java-dialogflow/issues/1511)) ([#973](googleapis/java-dialogflow#973)) ([3202efe](googleapis/java-dialogflow@3202efe)), closes [#1502](https://github.com/googleapis/java-dialogflow/issues/1502)
* updated some method comments and added an explicit note that DetectIntentRequest's text input is limited by 256 characters ([#954](googleapis/java-dialogflow#954)) ([d58232f](googleapis/java-dialogflow@d58232f))

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


## [2.5.2](googleapis/java-container@v2.5.1...v2.5.2) (2022-09-16)


### Bug Fixes

* Change vpc network ([#783](googleapis/java-container#783)) ([dcc91b6](googleapis/java-container@dcc91b6))


### Documentation

* **owlbot-java:** Explaining why not using formatter in pom.xml ([#1511](https://github.com/googleapis/java-container/issues/1511)) ([#768](googleapis/java-container#768)) ([a6c7635](googleapis/java-container@a6c7635)), closes [#1502](https://github.com/googleapis/java-container/issues/1502)


### Dependencies

* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 ([#781](googleapis/java-container#781)) ([a1e886e](googleapis/java-container@a1e886e))

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


## [2.3.15](https://togithub.com/googleapis/java-bigquerydatatransfer/compare/v2.3.14...v2.3.15) (2022-10-03)


### Dependencies

* Update dependency cachetools to v5 ([#1511](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1511)) ([b95ccc8](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/b95ccc8d07c7fc5b6f50917560304bf7d1db8b02))
* Update dependency certifi to v2022.9.24 ([#1497](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1497)) ([8280ad9](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/8280ad9d94f44c41dbc57aef7007359fa43a65ec))
* Update dependency charset-normalizer to v2.1.1 ([#1501](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1501)) ([7f61538](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/7f6153862f189554d10b82b755dcccb9f24c3044))
* Update dependency click to v8.1.3 ([#1502](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1502)) ([d315f8e](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/d315f8e433a64f1a1e4673688991b807285f5435))
* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.4 ([#1523](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1523)) ([5eb622d](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/5eb622d8bcf05a9852c342a73d119e4d703a0c27))
* Update dependency com.google.protobuf:protobuf-java-util to v3.21.7 ([#1521](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1521)) ([7bb94b7](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/7bb94b735d7822337f5f6b671b425081f4822813))
* Update dependency gcp-releasetool to v1.8.8 ([#1498](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1498)) ([9801601](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/9801601eacc79432efa9ce243af8bda87bdeadb2))
* Update dependency google-cloud-core to v2.3.2 ([#1499](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1499)) ([1e73bff](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/1e73bfffe09f8ae7f5216e8e4cd3e7d4aa520893))
* Update dependency googleapis-common-protos to v1.56.4 ([#1500](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1500)) ([3b4b24c](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/3b4b24ccff9a199f78c8e48ea73e7c04f4e2bb5e))
* Update dependency jinja2 to v3.1.2 ([#1503](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1503)) ([4864061](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/48640616122833134b28e42bc689109849a77279))
* Update dependency keyring to v23.9.3 ([#1504](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1504)) ([cc523de](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/cc523de50fefe993dbfbedbebbbd5a9754071342))
* Update dependency markupsafe to v2.1.1 ([#1505](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1505)) ([1e0ba5e](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/1e0ba5e094f98858affb53f77ceb61eff677b7cd))
* Update dependency protobuf to v3.20.2 ([#1506](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1506)) ([7a1e267](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/7a1e267ce2a02b9c506769de09bfefc76d103cb8))
* Update dependency protobuf to v4 ([#1512](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1512)) ([12c0c67](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/12c0c67819a05f4bafab1c280fd3a8b15ee0193b))
* Update dependency pyjwt to v2.5.0 ([#1507](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1507)) ([98f2d58](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/98f2d580e1a78aeeebbbc5db8d2b99461255b86f))
* Update dependency requests to v2.28.1 ([#1508](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1508)) ([9906ca8](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/9906ca8c8a67390106b524d561f1e973126aecfa))
* Update dependency typing-extensions to v4.3.0 ([#1509](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1509)) ([2d7eb9f](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/2d7eb9f93181fbf183ae2d633fdc63748c82110e))
* Update dependency zipp to v3.8.1 ([#1510](https://togithub.com/googleapis/java-bigquerydatatransfer/issues/1510)) ([dd98eef](https://togithub.com/googleapis/java-bigquerydatatransfer/commit/dd98eef23cdbac8b9c365504c2456776bed786a9))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.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: storage Issues related to the Cloud Storage API.
Projects
None yet
Development

No branches or pull requests

3 participants