Skip to content

Conversation

@tlrx
Copy link
Member

@tlrx tlrx commented Apr 18, 2017

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 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.

tlrx added 2 commits April 18, 2017 15:47
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.
@tlrx tlrx added :Java High Level REST Client >test Issues or PRs that are addressing/adding tests v6.0.0-alpha1 labels Apr 18, 2017
@tlrx tlrx requested a review from javanna April 18, 2017 14:13
public final void testFromXContent() throws IOException {
final NamedXContentRegistry xContentRegistry = xContentRegistry();
final T aggregation = createTestInstance();
assumeTrue("This test does not support the aggregation type yet",
Copy link
Member

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.

Copy link
Member Author

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);
Copy link
Member

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 :)

Copy link
Member Author

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member

@javanna javanna left a 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 !

@tlrx
Copy link
Member Author

tlrx commented Apr 18, 2017

Thanks @javanna

I merged with your suggestions. I also had to move the test of iterators in a dedicated testPercentilesRanksIterators method because it relies on the field ordering and the testFromXContent suffled the fields by default, losing the ordering in the parsed implementation.

@tlrx tlrx merged commit c1ba699 into elastic:feature/client_aggs_parsing Apr 18, 2017
@tlrx tlrx deleted the fix-percentiles-ranks branch April 18, 2017 14:55
assertTrue(parsedClass.isInstance(parsedAggregation));
}

public void testPercentilesRanksIterators() throws IOException {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw it, thanks!

javanna pushed a commit to javanna/elasticsearch that referenced this pull request May 23, 2017
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>test Issues or PRs that are addressing/adding tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants