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.
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
Implement ordered list state for FnApi. #30317
Implement ordered list state for FnApi. #30317
Changes from 1 commit
b978ca7
68abe65
d06e0a5
ffd9627
f74fc60
f9e48a3
a76b523
8a3b719
5d7cd5e
33e748d
91b770e
4b512ea
09db01c
44b6679
868e493
ea7ca70
83bac80
90b7f7d
8900646
f881b62
361deb0
7225a89
10eddad
a76034f
b481880
65aef1a
c158b32
f4c3440
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super-clear on how Iterables work in Java. Does this actually copy the elements, or is it just wrapping the values in
pendingAdds
in an Iterable? I'm curious about the statements in the comments saying "the values are kept" so that we can make modifications to the ordered list and not mess up existing Iterables.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iterables in java work like iterables in other languages. Basically, we use it to traverse an existing collection of elements without making a copy of them.
The
PrefetchableIterable
interface in Beam is specifically for iterables that support prefetching. The functionPrefetchableIterables.limit()
is applied on an iterable, resulting in a new iterable, which can be used to traverse its backend collection until the number of elements reaches a preset limit.Here is the tricky part.
pendingAddsInRange
is a list of iterables. For each of these iterables, when an iteration is performed at any time after its creation, the result will be truncated to the last element we see at the time we initialize the iterable withPrefetchableIterables.limit()
. In other words, appending a new element to the end of an existing key ofpendingAdds
would not affect the outcome above, because the iterable inpendingAddsInRange
is designed to be truncated to the size when it is created.pendingAdds
, it won't change the outcome of traversing an pre-existingpendingAddsInRange
either, because the iterable of the new key is not included inpendingAddsInRange
.pendingAdds
, we remove the key-value mapping, but not touch its value (i.e. the collection of elements). Therefore, the iterables in pre-existingpendingAddsInRange
will still work as the backend collection is accessible. Only when no iterables reference these collections will they be garbage collected.