Repository navigation
REST: Fetch list results lazily with PaginationList - #4483
Open
Anurag-S1ngh wants to merge 1 commit into
Open
Anurag-S1ngh wants to merge 1 commit into
Anurag-S1ngh wants to merge 1 commit into
Conversation
Return a PaginationList from list_namespaces, list_tables, and list_views. Later pages are fetched only when iteration or indexing moves past the loaded items. Operations that need the full result set, such as len, contains, slicing, and repr, fetch all pages first.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
RestCatalog.list_namespaces,list_tables, andlist_viewscurrently walk every page before returning. Callers that only need the first few results still pay for all the network calls.This adds a
PaginationListthat loads the first page eagerly and fetches later pages only when iteration or indexing moves past the loaded items. Operations that need the complete result set, such aslen(),in, slicing, negative indexes,repr(),sort(), andreverse(), fetch all remaining pages first. The return type stays alistsubclass, so existing callers keep their list semantics. Retries are applied to each lazily fetched page.Closes #3365.
Are these changes tested?
Yes. Added unit tests for
PaginationListcovering lazy iteration, early exit, indexing, slicing, and list operations, plus a REST test that asserts the second page is not requested until iteration passes the first page.pytest tests/ -m unit --ignore=tests/integration: 4893 passed, 6 skippedruff checkandruff format --checkpassty checkreports only the two pre-existingmodel_dumpdiagnostics intypedef.pyAre there any user-facing changes?
The three list methods now return a
PaginationListinstead of a plain list. It behaves like a list, includinglen()and equality, but may defer network calls until callers reach later items.