Skip to content

Conversation

@cbuescher
Copy link
Member

First stab at adding parsing one of the single value aggregations from xContent.
This is WIP against our current feature branch.

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 changed this (and the way the class interacts with the internal field) because I wanted to get close to what InternalAggregation allows for metadata. I think it can be null there, in which case the method returns null and we don't write anything to xContent.

Copy link
Member

Choose a reason for hiding this comment

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

as I said above, that makes sense, I adjusted it on our branch that way.

Copy link
Member Author

Choose a reason for hiding this comment

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

okay, will rebase this then

Copy link
Member

Choose a reason for hiding this comment

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

I pushed a very similar change to our branch. There was a discrepancy between empty and null handling in this class compared to InternalAggregation, I aligned it to InternalAggregation. this should not be needed anymore here.

Copy link
Member Author

Choose a reason for hiding this comment

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

okay, will rebase this then

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

Copy link
Member

Choose a reason for hiding this comment

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

why protected? subclasses can use the getter to retrieve it? but it only gets set while parsing? was this change required?

Copy link
Member

Choose a reason for hiding this comment

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

I think you forgot to put back the randomization here

Copy link
Member

Choose a reason for hiding this comment

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

do we want to shuffle these fields?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe not always, but that would be nice indeed

Copy link
Member Author

Choose a reason for hiding this comment

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

will add this

Copy link
Member

Choose a reason for hiding this comment

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

what is Double.MIN_VALUE doing here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thats just the expected delta between expeted/actual value for double comparissons in assertEquals()

Copy link
Member

Choose a reason for hiding this comment

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

ok

Copy link
Member

Choose a reason for hiding this comment

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

This is weird as this value is not returned with the response. But we can hardcode the formatter because this agg doesn't support format? I am a bit confused. Ideally we wouldn't have to implement this at all.

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, InternalCardinality doesn't print "value_as_string", but you can get a formated value using the java API using valueAsString defined in InternalNumericMetricsAggregation. That one uses the default formater, which is DocValueFormat.RAW. I don't think this can be reset in InternalCardinality, thats why I use it here to get the same behaviour as InternalCardinality.

Copy link
Member

Choose a reason for hiding this comment

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

ok can you expand your comment on why we do this and why it's ok? I also wish one day we get rid of it. I thought about throwing UnsupportedOperationException for a sec, but let's keep it for now as-is.

Copy link
Member

@tlrx tlrx left a comment

Choose a reason for hiding this comment

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

I second @javanna in all his comments and I don't have much to add. I'd love to have a common test in InternalAggregationTestCase for all aggregations, but I'm sure we'll get there soon.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe not always, but that would be nice indeed

@cbuescher cbuescher removed the WIP label Apr 10, 2017
@cbuescher cbuescher changed the title WIP: Adding ParsedCardinality Adding ParsedCardinality Apr 10, 2017
@cbuescher cbuescher force-pushed the internalCardinality-parsing branch from 8363f74 to 0fe3f5a Compare April 10, 2017 16:13
@cbuescher cbuescher force-pushed the internalCardinality-parsing branch from 0fe3f5a to 9cd83b2 Compare April 10, 2017 16:14
@cbuescher
Copy link
Member Author

@javanna @tlrx thanks a lot, I updated the PR. Let me know if I'm missing anything or if I should merge to the feature branch.

}

protected void setName(String name) {
this.name = name;
Copy link
Member

Choose a reason for hiding this comment

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

I think that with this protected setter, you can now make the instance member private?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

return cardinalityValue;
}

private void setValue(long cardinalityValue) {
Copy link
Member

Choose a reason for hiding this comment

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

It is a bit pointless to have a private setter for a private field, but we need it for object parser I guess?

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, thats the idea

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.

LGTM thanks @cbuescher . I wonder if we want to remove ParsedAggregationTests at this point, not as part of this PR though.

@cbuescher cbuescher merged commit 3565328 into elastic:feature/client_aggs_parsing Apr 12, 2017
javanna pushed a commit to javanna/elasticsearch that referenced this pull request May 23, 2017
Adding parsing of InternalCardinality xContent output. Parsing method will return a new
implementation of the Cardinality interface, ParsedCardinality.
@cbuescher cbuescher deleted the internalCardinality-parsing branch November 27, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants