-
Notifications
You must be signed in to change notification settings - Fork 25.6k
AbstractParsedPercentiles should use Percentile class #24160
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
AbstractParsedPercentiles should use Percentile class #24160
Conversation
Now the Percentile interface has been merged with the InternalPercentile class in core (elastic#24154) the AbstractParsedPercentiles should use it. This commit also changes InternalPercentilesRanksTestCase so that it now tests the iterator obtained from parsed percentiles ranks aggregations. Adding this new test raised an issue in the iterators where key and value are "swapped" in internal implementations when building the iterators (see InternalTDigestPercentileRanks.Iter constructor that accepts the `keys` as the first parameter named `values`, each key being mapped to the `value` field of Percentile class). This is because percentiles ranks aggs inverts percentiles/values compared to the percentiles aggs.
| public final void testFromXContent() throws IOException { | ||
| final NamedXContentRegistry xContentRegistry = xContentRegistry(); | ||
| final T aggregation = createTestInstance(); | ||
| assumeTrue("This test does not support the aggregation type yet", |
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.
leave the //norelease ? we will have to get rid of it at some point.
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.
Sure
| final NamedXContentRegistry xContentRegistry = xContentRegistry(); | ||
| final T aggregation = createTestInstance(); | ||
| assumeTrue("This test does not support the aggregation type yet", | ||
| getNamedXContents().stream().filter(entry -> entry.name.match(aggregation.getType())).count() == 1); |
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.
count > 0? just being paranoid :)
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.
Ok
| final boolean keyed = randomBoolean(); | ||
| final DocValueFormat format = randomFrom(DocValueFormat.RAW, new DocValueFormat.Decimal("###.##")); | ||
| List<Double> randomCdfValues = randomSubsetOf(randomIntBetween(1, 5), 0.01d, 0.05d, 0.25d, 0.50d, 0.75d, 0.95d, 0.99d); | ||
| List<Double> randomCdfValues = Collections.singletonList(0.75d);//randomSubsetOf(randomIntBetween(1, 5), 0.01d, 0.05d, 0.25d, 0.50d, 0.75d, 0.95d, 0.99d); |
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.
leftover?
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.
Yes
javanna
left a comment
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.
left a few comments, LGTM otherwise. Thanks a lot @tlrx !
|
Thanks @javanna I merged with your suggestions. I also had to move the test of iterators in a dedicated |
| assertTrue(parsedClass.isInstance(parsedAggregation)); | ||
| } | ||
|
|
||
| public void testPercentilesRanksIterators() throws IOException { |
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.
maybe some code could be shared, or maybe shuffling could be disabled optionally?
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 addressed this in #24183 where I added a parse() method that accepts a shuffled boolean.
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 saw it, thanks!
Now the Percentile interface has been merged with the InternalPercentile class in core (elastic#24154) the AbstractParsedPercentiles should use it. This commit also changes InternalPercentilesRanksTestCase so that it now tests the iterator obtained from parsed percentiles ranks aggregations. Adding this new test raised an issue in the iterators where key and value are "swapped" in internal implementations when building the iterators (see InternalTDigestPercentileRanks.Iter constructor that accepts the `keys` as the first parameter named `values`, each key being mapped to the `value` field of Percentile class). This is because percentiles ranks aggs inverts percentiles/values compared to the percentiles aggs. * Add assume in InternalAggregationTestCase * Update after Luca review
Note: pull request against feature branch
Now the Percentile interface has been merged with the InternalPercentile class in core (#24154) the AbstractParsedPercentiles should use it.
This commit also changes InternalPercentilesRanksTestCase so that it now tests the iterator obtained from parsed percentiles ranks aggregations.
Adding this new test raised an issue in the iterators where key and value are "swapped" in internal implementations when building the iterators (see InternalTDigestPercentileRanks.Iter constructor that accepts the
keysas the first parameter namedvalues, each key being mapped to thevaluefield of Percentile class). This is because percentiles ranks aggs inverts percentiles/values compared to the percentiles aggs.