Repository navigation
Fix JavaReservoirSampleOperator returning the whole input when the dataset size is unknown - #885
Open
sasmith-14 wants to merge 1 commit into
Open
sasmith-14 wants to merge 1 commit into
sasmith-14 wants to merge 1 commit into
Conversation
…taset size is unknown apache#884 The reservoir operator short-circuited to "return all" whenever sampleSize >= datasetSize, but datasetSize defaults to UNKNOWN_DATASET_SIZE (0) when the size is not known, so the comparison was always true and the operator returned the entire input instead of a sample. Guard the shortcut with isDataSetSizeKnown(), matching JavaRandomSampleOperator; the streaming reservoir algorithm already handles inputs smaller than the sample size. Fixes apache#884
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #884
What changes were proposed in this pull request?
JavaReservoirSampleOperatorreturned the entire input instead of a sample whenever the dataset size was unknown. The "return all" shortcutis always taken when
datasetSizeisUNKNOWN_DATASET_SIZE(0, the default), sosampleSize >= 0always holds.This guards the shortcut with
isDataSetSizeKnown()— the same checkJavaRandomSampleOperatoralready uses:When the size is unknown the operator now runs the reservoir algorithm, which already handles inputs smaller than the sample size.
How was this patch tested?
Added
testExecutionWithUnknownDatasetSize(nosetDatasetSizecall): it fails onmain(expected: <5> but was: <10>) and passes with this change. Fullwayang-javasuite: 56 run, 0 failures, 0 errors, 5 skipped.