Skip to content

Conversation

@apollonin
Copy link
Contributor

Adding more convenience to users when they want to get a predefined number of results from the paginated collection.

old way:

data_rows = dataset.data_rows()
data_row = next(data_rows)

new way:

data_row = dataset.data_rows().get_one()

old way:

data_rows = dataset.data_rows()
first_ten = []
for data_row in data_rows:
    first_ten.append(data_row)
    if len(first_ten) >= 10:
        break

new way:

data_rows = dataset.data_rows().get_many(10)

important note. These methods are idempotent. That means:

  1. They can be called as many times as wanted and the result will be the same. E.x. get_one will always return first one result. It is not equivalent to calling next().
  2. get_many will not call API in case it already has needed amount of data. This way to safe resources and time.

@apollonin apollonin requested review from a team, kkim-labelbox and msokoloff1 December 2, 2022 22:03
Dmitriy Apollonin added 2 commits December 2, 2022 15:07
@apollonin apollonin requested a review from msokoloff1 December 2, 2022 22:14
@apollonin apollonin merged commit adb133d into develop Dec 2, 2022
@apollonin apollonin deleted the AL-4334-add-get-one-method-to-sdk-paginator branch December 2, 2022 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants