-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add parsing for InternalStats #24239
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
Add parsing for InternalStats #24239
Conversation
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.
This is one caveat I found in the current InternalStats implementation. We dont have a COUNT_AS_STRING field in the xContent output, but the java API provides formatted String values of the "long" count via getCountAsString(). Possible solutions I can think of for now:
- add COUNT_AS_STRING to xContent (breaking ?)
- change getCountAsString() in InternalStats to return Long.toString(count) (breaking Java?)
- remove getCountAsString() from the Stats interface (after all we don't render a formatted version)
- ignore this as a rare edge case and exclude it from testing like I've done it now
Wdyt?
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.
It looks like it has been forgotten, I think we can add it in master/v6 and ignore it/not add it in 5.x
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 opened #24291 for this and Colin agreed that we should remove getCountAsString() on master. I rebased this PR on that change.
tlrx
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.
LGTM, I left some comments though
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.
We could rename it to parseDouble() and add some Javadoc.
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.
final?
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 find this more readable:
if (count != 0) {
builder.field(Fields.MIN, min);
builder.field(Fields.MAX, max);
builder.field(Fields.AVG, avg);
builder.field(Fields.SUM, sum);
if (valueAsString.get(Fields.MIN_AS_STRING) != null) {
builder.field(Fields.MIN_AS_STRING, getMinAsString());
builder.field(Fields.MAX_AS_STRING, getMaxAsString());
builder.field(Fields.AVG_AS_STRING, getAvgAsString());
builder.field(Fields.SUM_AS_STRING, getSumAsString());
}
} else {
builder.nullField(Fields.MIN);
builder.nullField(Fields.MAX);
builder.nullField(Fields.AVG);
builder.nullField(Fields.SUM);
}
or maybe store count != 0 in a 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.
Good point, should I also change this in InternalStats then to make it more readable there?
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 changed this here in ParsedStats and left the other version in InternalStats. I don't know really which one I like better, probably the "old" one? Lets see if @javanna has an opinion when comparing both.
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 like it, we could align also InternalStats.
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.
Okay, I also changed InternalStats#doXContentBody(), do you think I should do this on master as well do have a smaller diff with the feature branch when we merge or is it enough to just do it on the branch? It shouldn't change any behavior...
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 think it's fine to keep this on the branch, but if you prefer to move it to master I am good with that too.
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.
typo
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.
Good catch, that is in there in InternalStats too. Will also change that.
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 think there's a type in core that can be fixed too :)
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.
It looks like it has been forgotten, I think we can add it in master/v6 and ignore it/not add it in 5.x
30ce73c to
76e5df7
Compare
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.
LGTM
Similar to #24085 this adds parsing for InternalStats. This will be needed for the high level rest client.
PR is against the current feature branch for aggregation parsing.