Skip to content

[draft] based on PR 43484, put PagingOptions to retriever lambda#43720

Merged
weidongxu-microsoft merged 4 commits into
Azure:clientcore-pagedfrom
weidongxu-microsoft:clientcore-paged_paging-context
Jan 9, 2025
Merged

[draft] based on PR 43484, put PagingOptions to retriever lambda#43720
weidongxu-microsoft merged 4 commits into
Azure:clientcore-pagedfrom
weidongxu-microsoft:clientcore-paged_paging-context

Conversation

@weidongxu-microsoft

@weidongxu-microsoft weidongxu-microsoft commented Jan 7, 2025

Copy link
Copy Markdown
Member

For #43484

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@weidongxu-microsoft weidongxu-microsoft changed the title put PagingOptions to retriever lambda [draft] based on PR 43484, put PagingOptions to retriever lambda Jan 7, 2025
private PagedResponse<TodoItem> listNextSinglePage(String nextLink) {
Response<TodoPage> res = listNextSync(nextLink);
private PagedResponse<TodoItem> listNextSinglePage(PagingOptions pagingOptions, String nextLink) {
Response<TodoPage> res = (nextLink == null) ? listSync(pagingOptions) : listNextSync(nextLink);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, the code would fork in nextLink. If nextLink exists, it would just request that URL; if nextLink not exist, it would call the same API, but with pagingOptions updated (e.g. continuationToken updated from the prior page).

Comment on lines +231 to +234
nextLink = page.getNextLink();
continuationToken = page.getContinuationToken();
this.done = (nextLink == null || nextLink.isEmpty())
&& (continuationToken == null || continuationToken.isEmpty());

@weidongxu-microsoft weidongxu-microsoft Jan 7, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code here and above only handle the server-driven pageable (i.e. nextLink or continuationToken).

It does not handle client-side pageable (i.e. via incremental on pageIndex or index).

Handling of client-side pageable would require we get the PagingOptions of the prior request (in additional to this PagedResponse), and update it for next page.

private Response<TodoPage> listSync() {
private Response<TodoPage> listSync(PagingOptions pagingOptions) {
// mock request on first page
return new HttpResponse<>(null, 200, null, new TodoPage(List.of(new TodoItem(), new TodoItem()), "nextLink1"));

@weidongxu-microsoft weidongxu-microsoft Jan 7, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code here should set the value of pagingOptions.continuationToken into the proxy API.
(it also means emitter/codegen need to do special handling for continuationToken param, as it should appear on proxy API, but not on client method API)

@weidongxu-microsoft weidongxu-microsoft force-pushed the clientcore-paged_paging-context branch from 1cffdc6 to 1695f0c Compare January 8, 2025 03:17
@weidongxu-microsoft weidongxu-microsoft marked this pull request as ready for review January 9, 2025 02:57
@weidongxu-microsoft weidongxu-microsoft merged commit 74c95f9 into Azure:clientcore-paged Jan 9, 2025
@weidongxu-microsoft weidongxu-microsoft deleted the clientcore-paged_paging-context branch January 9, 2025 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant