GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — paging vs infinite API's - Cloud Storage, but more broadly applicable... · Issue #1798 · googleapis/google-cloud-java

paging vs infinite API's - Cloud Storage, but more broadly applicable... #1798

New issue
Copy link
New issue
Copy link
Closed
Closed
paging vs infinite API's - Cloud Storage, but more broadly applicable...#1798
Copy link
Assignees
garrettjonesgoogle
Labels
api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.triaged for GAtype: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Description

@lesv
lesv
opened on Mar 23, 2017
Issue body actions

In looking at the cloud storage API's, they are really a mapping of our internal protobuf apis to a client surface rather than going with what we had hoped to be the more natural view.

For example we show the following for list:

 String bucketName = "my_unique_bucket";
 String directory = "my_directory/";
 Page<Blob> blobs = storage.list(bucketName, BlobListOption.currentDirectory(),
     BlobListOption.prefix(directory));
 Iterator<Blob> blobIterator = blobs.iterateAll();
 while (blobIterator.hasNext()) {
   Blob blob = blobIterator.next();
   // do something with the blob
 }

In actuality the usage is more like:

 String bucketName = "my_unique_bucket";
 String directory = "my_directory/";
 Page<Blob> blobs = storage.list(bucketName, BlobListOption.currentDirectory(),
     BlobListOption.prefix(directory));
 do {
    Iterator<Blob> blobIterator = blobs.iterateAll();
    while (blobIterator.hasNext()) {
      Blob blob = blobIterator.next();
      // do something with the blob
    }
    blobs = blobs.getNextPage();
  } while ( blobs != null);

In a sense there are cases where it makes sense to use paging, such as doing so in a web app, but there are also many cases where we should hide our complexity from our users and just provide a single blobs iterator.

I don't wish to block GA with this as I don't think it makes sense, but this is something we should fix in the autogenerated libraries. Developers should be able to choose between a paged api, for webapps and the like, and a continuous api (that we can optimize behind the scenes).

@anthmgoogle FYI
@waprin FYI
@jabubake FYI
@garrettjonesgoogle
@jgeewax FYI

Activity

  1. lesv
    added
    api: storageIssues related to the Cloud Storage API.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    triaged for beta
    triaged for GA
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Mar 23, 2017
  2. garrettjonesgoogle commented on Mar 23, 2017

    @garrettjonesgoogle
    garrettjonesgoogle
    on Mar 23, 2017
    Contributor
    More actions

    @michaelbausor is actually working on the paging interface right now (#1568). Mike, could you chime in here?

  3. michaelbausor commented on Mar 23, 2017

    @michaelbausor
    michaelbausor
    on Mar 23, 2017
    Contributor
    More actions

    @lesv I am not sure I fully understand. The iterateAll() method does handle paging behind the scenes and iterate over all elements. So in your second code block, the calls to getNextPage() are not required - blobs.iterateAll() will make those calls in the background and iterate over everything.

    This is the same in the autogenerated paging implementation, which provides an iterateAllElements() method in the response object. I am currently working to unify the autogenerated and manual paging implementations, but we will definitely keep the ability to iterate all results in a single call, with paging handled automatically.

    GCJ paging impl: https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/google-cloud-core/src/main/java/com/google/cloud/PageImpl.java#L91
    GAX paged response impl: https://github.com/googleapis/gax-java/blob/master/src/main/java/com/google/api/gax/grpc/PagedListResponseImpl.java#L62

  4. lesv commented on Mar 23, 2017

    @lesv
    lesv
    on Mar 23, 2017
    ContributorAuthor
    More actions

    Cool - it's not the first time that I've missed something, probably won't be the last. :(

    Since I have everyone's attention, should we change our example to be:

     String bucketName = "my_unique_bucket";
     String directory = "my_directory/";
     Page<Blob> blobs = storage.list(bucketName, BlobListOption.currentDirectory(),
         BlobListOption.prefix(directory));
     for (Blob blob : blobs.iterateAll()) {
    
       // do something with the blob
     }
  5. michaelbausor commented on Apr 12, 2017

    @michaelbausor
    michaelbausor
    on Apr 12, 2017
    Contributor
    More actions

    @lesv As part of the update to the paging interface (#1894 have updated our samples to use the iteration style you suggest above. For example here: 5f5a859#diff-d0f13847f2d8f6c8b2a3b1bd238814feR115

  6. lesv commented on Apr 12, 2017

    @lesv
    lesv
    on Apr 12, 2017
    ContributorAuthor
    More actions

    Thanks

  7. garrettjonesgoogle commented on Jul 18, 2017

    @garrettjonesgoogle
    garrettjonesgoogle
    on Jul 18, 2017
    Contributor
    More actions

    I think this issue has been addressed, closing it out.

  8. garrettjonesgoogle
    closed this as completedon Jul 18, 2017
  9. JustinBeckwith
    assigned
    garrettjonesgoogle
    on Feb 1, 2021
  10. meltsufin
    added a commit that references this issue on Dec 22, 2025

    chore(main): release 3.22.3-SNAPSHOT (#1798)

    b311c0b
  11. chingor13
    added 2 commits that reference this issue on Feb 24, 2026

    fix: indicate non-validated external credentials in generic methods (#…

    e7d4380

    chore: follow up of #1798 (#1800)

    2856b87
  12. suztomo
    added a commit that references this issue on Mar 11, 2026

    chore(main): release 3.22.3-SNAPSHOT (googleapis#1798)

    e949e56
  13. chingor13
    added 2 commits that reference this issue on Mar 12, 2026

    fix: indicate non-validated external credentials in generic methods (#…

    405f17f

    chore: follow up of #1798 (#1800)

    db4bf9f
  14. suztomo
    added 2 commits that reference this issue on Mar 23, 2026

    deps: update dependency org.testcontainers:testcontainers to v1.20.3 (g…

    fac650d

    chore(main): release 2.24.0 (googleapis#1794)

    4338f0d
  15. meltsufin
    added 3 commits that reference this issue on Apr 29, 2026

    chore(main): release 1.125.9 (#1798)

    0d9b5ec

    chore(main): release 1.125.9 (#1798)

    68e747f

    chore(main): release 3.25.1 (#1798)

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

Metadata

Metadata

Assignees

  • @garrettjonesgoogle
    garrettjonesgoogle

Labels

api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.triaged for GAtype: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.