Abacn opened a new pull request, #41867:
URL: https://github.com/apache/beam/pull/41867

   FnApiStateAccessor.bindBag().read() previously returned BagUserState.get() 
directly, which does not implement ElementByteSizeObservableIterable. When a 
DoFn such as GroupIntoBatches emits a BagState iterable, 
PCollectionConsumerRegistry.SampleByteSizeDistribution calls 
IterableLikeCoder.registerByteSizeObserver(), triggering a full eager fetch and 
decode of the entire bag state before the downstream DoFn iterates it a second 
time.
   
   Reuse StateBackedIterable.WrappedObservingIterator via a package-private 
StateBackedIterable.observeIterable() helper in 
FnApiStateAccessor.bindBag().read() so byte-size observation occurs lazily 
during the single downstream pass, and short-circuit 
WrappedObservingIterator.next() when no observers are attached.
   
   <!--
   
   Thank you for your contribution! Follow this checklist to help us 
incorporate your contribution quickly and easily:
   
    - [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
    - [ ] Replace these instructions with a description of your change and why 
you have made it.
    - [ ] Mention the appropriate issue in your description (for example: 
`addresses #123` or `fixes #456`).
    - [ ] Update `CHANGES.md` with noteworthy changes.
   
   See [CONTRIBUTING.md]() for more details.
   
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to