Skip to content

Conversation

@cbuescher
Copy link
Member

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.

Copy link
Member Author

@cbuescher cbuescher Apr 21, 2017

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?

Copy link
Member

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

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 opened #24291 for this and Colin agreed that we should remove getCountAsString() on master. I rebased this PR on that change.

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.

LGTM, I left some comments though

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

final?

Copy link
Member

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?

Copy link
Member Author

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?

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

Copy link
Member

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.

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

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 it's fine to keep this on the branch, but if you prefer to move it to master I am good with that too.

Copy link
Member

Choose a reason for hiding this comment

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

typo

Copy link
Member Author

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.

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 there's a type in core that can be fixed too :)

Copy link
Member

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

@cbuescher cbuescher force-pushed the addParsing-InternalStats branch from 30ce73c to 76e5df7 Compare April 24, 2017 16:51
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

@cbuescher cbuescher merged commit 768420d into elastic:feature/client_aggs_parsing Apr 25, 2017
javanna pushed a commit to javanna/elasticsearch that referenced this pull request May 23, 2017
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