Skip to content

Conversation

@cbuescher
Copy link
Member

Similar to #24085 this adds parsing for InternalSimpleValue and InternalDerivative. This will be needed for
the high level rest client. PR is against the current feature branch for aggregation parsing.

Copy link
Member Author

Choose a reason for hiding this comment

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

This flag might seem a bit weird but I think we need it (or something similar) to distinguish cases where the original InternalDerivative.normalizationFactor was 0. Its an edge case, but in this case no xContent output is rendered at all. I couldn't think of another way to cover this edge case without somehow tracking whether this parser encountered any "normalized_value" or "normalized_value_as_string" fields in the parsed xContent.

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 this is the way to go. Maybe we could document the purpose of this flag and maybe rename it to hasNormalizationFactor or hasValue or isValuePresent? Ok, you know I'm bad at naming things :)

Copy link
Member

Choose a reason for hiding this comment

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

++ on hasNormalizationFactor . I would probably associate the flag to the parsing of normalized_value only. the other field is only optionally printed out.

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 but they are minor. I really like how it becomes straightforward to add new types of aggregations to parse!

Copy link
Member

Choose a reason for hiding this comment

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

min can be named simple or aggregation

Copy link
Member

Choose a reason for hiding this comment

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

can you place everything on the same line?

Copy link
Member

Choose a reason for hiding this comment

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

Can we rename min to something else?

Copy link
Member

Choose a reason for hiding this comment

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

In which case value can be infinite?

Copy link
Member

Choose a reason for hiding this comment

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

Also, we could put this check in a protected static method and reuse it in ParsedDerivative

Copy link
Member Author

Choose a reason for hiding this comment

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

In which case value can be infinite?

Good question, this is just the same condition as in InternalSimpleValue, which I just assumed makes sense. I guess any pipeline agg that reduces to InternalSimpleValue could potentially set it to some infinite value.
Maybe we should share things like this across InternalSimpleValue/ParsedSimpleValue via the SimpleValue interface? Any opinions?

Copy link
Member

Choose a reason for hiding this comment

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

but I thought we never set the parsed value to infinite?

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, both infinite and NaN values are printed as null and parsed back as NaN so you are right, this shouldn't be possible in ParsedSimpleValue. I just copied the condition from the internal implementation to be on the safe side I guess. I can remove this here, or move to a shared condition in the interface like suggested above (and then have one "unnecessary check" in there...). Wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

I am slightly more in favour of having precise checks where needed rather than sharing code with unnecessary checks.

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 changed the condition and will merge this PR then. We can always change this later if we think its necessary.

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 this is the way to go. Maybe we could document the purpose of this flag and maybe rename it to hasNormalizationFactor or hasValue or isValuePresent? Ok, you know I'm bad at naming things :)

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 similar to the internal implementation, nice

Copy link
Member

Choose a reason for hiding this comment

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

I added a randomNumericDocValueFormat() method in core which seems appropriate for this.

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 Luca asked this question already but I didn't find the response... why Double.MIN_VALUE?

Copy link
Member

Choose a reason for hiding this comment

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

it's a delta, mandatory argument in comparisons between double values.

Copy link
Member Author

Choose a reason for hiding this comment

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

The version without a delta is deprecated, so I think better to add one. @tlrx yes, I can use 0 here, but I usually prefer to leave a very small value to allow minimal rounding errors. But I will change the delta to 0 here, hope to remember that when I see it in other place, please remind me if I don't ;-)

Copy link
Member

Choose a reason for hiding this comment

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

Use randomNumericDocValueFormat()

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

s/Singe/Single

Copy link
Member

Choose a reason for hiding this comment

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

++ on hasNormalizationFactor . I would probably associate the flag to the parsing of normalized_value only. the other field is only optionally printed out.

Copy link
Member

Choose a reason for hiding this comment

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

is infinite possible here?

Copy link
Member

Choose a reason for hiding this comment

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

it's a delta, mandatory argument in comparisons between double values.

@cbuescher cbuescher force-pushed the addParsing-SimpleValue-Derivative branch from 7ea2c6e to 1edc368 Compare April 19, 2017 10:27
@cbuescher cbuescher force-pushed the addParsing-SimpleValue-Derivative branch from 1edc368 to 0e3db29 Compare April 19, 2017 10:43
@cbuescher cbuescher merged commit 4562c8a into elastic:feature/client_aggs_parsing Apr 19, 2017
@cbuescher
Copy link
Member Author

@tlrx @javanna thanks for the review

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