Skip to content

Commit

Permalink
reorder to avoid scaling cheap coders
Browse files Browse the repository at this point in the history
  • Loading branch information
stankiewicz committed Feb 3, 2025
1 parent 0896bf5 commit ec36635
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ public boolean hasNext() {
public T next() {
T value = wrappedIterator.next();
try {
if (sampleElement() || elementCoder.isRegisterByteSizeObserverCheap(value)) {
boolean cheap = elementCoder.isRegisterByteSizeObserverCheap(value);
if (cheap || sampleElement()) {
observerProxy.setScalingFactor(
Math.max(samplingToken, SAMPLING_CUTOFF) / (double) SAMPLING_CUTOFF);
cheap ? 1.0 : Math.max(samplingToken, SAMPLING_CUTOFF) / (double) SAMPLING_CUTOFF);
elementCoder.registerByteSizeObserver(value, observerProxy);
if (observerProxy.getIsLazy()) {
// The observer will only be notified of bytes as the result
Expand Down

0 comments on commit ec36635

Please sign in to comment.