-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Change downsample's MetricFieldProducers #124701
Change downsample's MetricFieldProducers #124701
Conversation
…f FormattedDocValues, which saves unneeded number conversations and casts.
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
nonMetricProducers.toArray(new AbstractDownsampleFieldProducer[0]), | ||
formattedDocValues.toArray(new FormattedDocValues[0]), | ||
metricProducers.toArray(new MetricFieldProducer[0]), | ||
numericDocValues.toArray(new SortedNumericDoubleValues[0]) |
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.
Nit: just pass the lists, to avoid the conversion to arrays?
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.
The LeafDownsampleCollector#collect(...)
method is hot code. I prefer to keep using arrays there.
for (int i = 0; i < fieldProducers.length; i++) { | ||
AbstractDownsampleFieldProducer fieldProducer = fieldProducers[i]; | ||
for (int i = 0; i < nonMetricProducers.length; i++) { | ||
AbstractDownsampleFieldProducer fieldProducer = nonMetricProducers[i]; |
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.
Assert that the lengths are the same?
@@ -281,9 +287,7 @@ public void write(XContentBuilder builder) throws IOException { | |||
if (isEmpty() == false) { | |||
builder.startObject(name()); | |||
for (MetricFieldProducer.Metric metric : metrics()) { | |||
if (metric.get() != null) { |
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.
Check if it returns Double.MIN_VALUE?
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.
So I removed this, after I realize that a metric (min, max, sum, count) will always have a value.
What the default value is depends on the metric implementation, so we would need to delegate to Metric for this. Given that this isn't needed, let's keep it this way? Also Metric will be removed in a followup PR.
@@ -94,51 +100,51 @@ public String name() { | |||
* Metric implementation that computes the maximum of all values of a field | |||
*/ | |||
static final class Max extends Metric { | |||
private Double max; | |||
private double max = -Double.MAX_VALUE; |
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.
Let's make this a static constant, Max.INVALID_VALUE
. Same below.
@@ -39,9 +39,7 @@ public void write(XContentBuilder builder) throws IOException { | |||
if (fieldProducer.isEmpty() == false) { | |||
if (fieldProducer instanceof MetricFieldProducer metricFieldProducer) { | |||
for (MetricFieldProducer.Metric metric : metricFieldProducer.metrics()) { | |||
if (metric.get() != null) { |
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.
Check if the returned value is invalid?
…r_use_sorted_numeric_double_value
Refactor MetricFieldProducer to use SortedNumericDoubleValues instead of FormattedDocValues, which saves unneeded conversations / casts.
Refactor MetricFieldProducer to use SortedNumericDoubleValues instead of FormattedDocValues, which saves unneeded conversations / casts.
Refactor MetricFieldProducer to use SortedNumericDoubleValues instead of FormattedDocValues, which saves unneeded conversations / casts.
Backporting #124701 to 9.0 branch. Refactor MetricFieldProducer to use SortedNumericDoubleValues instead of FormattedDocValues, which saves unneeded conversations / casts.
Refactor MetricFieldProducer to use SortedNumericDoubleValues instead of FormattedDocValues, which saves unneeded conversations / casts.
Refactor MetricFieldProducer to use SortedNumericDoubleValues instead of FormattedDocValues, which saves unneeded conversations / casts.
Next step after this PR is to remove the
Metric
abstraction layer inMetricFieldProducer
(a8a5735). According to local experiments, this is what gives a 10% performance boost.