-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[ES|QL] Support some stats on aggregate_metric_double #120343
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
Merged
limotova
merged 25 commits into
elastic:main
from
limotova:add-aggregate-double-metric-aggregates
Jan 29, 2025
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
ae16694
[ES|QL] Support some stats on aggregate_double_metric
limotova a5be73b
addressed most comments minus tests
limotova 80b317a
Merge branch 'main' into add-aggregate-double-metric-aggregates
limotova a2a6092
FromAggregateDoubleMetricTests
limotova 9094f62
Merge branch 'main' into add-aggregate-double-metric-aggregates
limotova b3b27aa
bring back unsupported exceptions
limotova 5acb5a8
Merge branch 'main' into add-aggregate-double-metric-aggregates
limotova 71a05b2
change valueCount to Integer and revert other getValueCount()
limotova 648e0af
and revert getFirstValueIndex()
limotova 83612ec
test all metrics in aggregate double metric test
limotova 38659b9
refactor things touched in this PR to all be aggregate metric double …
limotova bfe84c1
[CI] Auto commit changes from spotless
022eebe
renaming stragglers
limotova 769e924
Update docs/changelog/120343.yaml
limotova 6dd6e36
fix changelog
limotova 5dd5ad9
Merge branch 'main' into add-aggregate-double-metric-aggregates
limotova af0e242
Add downsampled yaml test
limotova 1838a82
address some comments
limotova 335fe3b
change Double etc to double
limotova 5608bce
Merge branch 'main' into add-aggregate-double-metric-aggregates
limotova c417b3c
add instanceof check
limotova b5837f3
Merge branch 'main' into add-aggregate-double-metric-aggregates
limotova fba979f
Merge branch 'main' into add-aggregate-double-metric-aggregates
limotova 827eaf3
change AggMetDoubLit to record
limotova fbdb24d
move function to make checkstyle work
limotova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...mpute/src/main/java/org/elasticsearch/compute/data/AggregateDoubleMetricBlockBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.compute.data; | ||
|
|
||
| import org.elasticsearch.index.mapper.BlockLoader; | ||
|
|
||
| public class AggregateDoubleMetricBlockBuilder extends AbstractBlockBuilder implements BlockLoader.AggregateDoubleMetricBuilder { | ||
|
|
||
| private final DoubleBlockBuilder minBuilder; | ||
| private final DoubleBlockBuilder maxBuilder; | ||
| private final DoubleBlockBuilder sumBuilder; | ||
| private final IntBlockBuilder countBuilder; | ||
|
|
||
| public AggregateDoubleMetricBlockBuilder(int estimatedSize, BlockFactory blockFactory) { | ||
| super(blockFactory); | ||
| minBuilder = new DoubleBlockBuilder(estimatedSize, blockFactory); | ||
limotova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| maxBuilder = new DoubleBlockBuilder(estimatedSize, blockFactory); | ||
| sumBuilder = new DoubleBlockBuilder(estimatedSize, blockFactory); | ||
| countBuilder = new IntBlockBuilder(estimatedSize, blockFactory); | ||
| } | ||
|
|
||
| @Override | ||
| protected int valuesLength() { | ||
| return minBuilder.valuesLength(); | ||
limotova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Override | ||
| protected void growValuesArray(int newSize) { | ||
| minBuilder.growValuesArray(newSize); | ||
limotova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| maxBuilder.growValuesArray(newSize); | ||
| sumBuilder.growValuesArray(newSize); | ||
| countBuilder.growValuesArray(newSize); | ||
| } | ||
|
|
||
| @Override | ||
| protected int elementSize() { | ||
| return minBuilder.elementSize() + maxBuilder.elementSize() + sumBuilder.elementSize() + countBuilder.elementSize(); | ||
limotova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Override | ||
| public Block.Builder copyFrom(Block block, int beginInclusive, int endExclusive) { | ||
| CompositeBlock composite = (CompositeBlock) block; | ||
| minBuilder.copyFrom(composite.getBlock(Metric.MIN.ordinal()), beginInclusive, endExclusive); | ||
| maxBuilder.copyFrom(composite.getBlock(Metric.MAX.ordinal()), beginInclusive, endExclusive); | ||
| sumBuilder.copyFrom(composite.getBlock(Metric.SUM.ordinal()), beginInclusive, endExclusive); | ||
| countBuilder.copyFrom(composite.getBlock(Metric.COUNT.ordinal()), beginInclusive, endExclusive); | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Block.Builder mvOrdering(Block.MvOrdering mvOrdering) { | ||
| minBuilder.mvOrdering(mvOrdering); | ||
| maxBuilder.mvOrdering(mvOrdering); | ||
| sumBuilder.mvOrdering(mvOrdering); | ||
| countBuilder.mvOrdering(mvOrdering); | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Block build() { | ||
| Block[] blocks = new Block[4]; | ||
| blocks[Metric.MIN.ordinal()] = minBuilder.build(); | ||
limotova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| blocks[Metric.MAX.ordinal()] = maxBuilder.build(); | ||
| blocks[Metric.SUM.ordinal()] = sumBuilder.build(); | ||
| blocks[Metric.COUNT.ordinal()] = countBuilder.build(); | ||
| return new CompositeBlock(blocks); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.AggregateDoubleMetricBuilder append(double min, double max, double sum, int valueCount) { | ||
| minBuilder.appendDouble(min); | ||
| maxBuilder.appendDouble(max); | ||
| sumBuilder.appendDouble(sum); | ||
| countBuilder.appendInt(valueCount); | ||
| return this; | ||
| } | ||
|
|
||
| public enum Metric { | ||
limotova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| MIN, | ||
| MAX, | ||
| SUM, | ||
| COUNT; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -765,9 +765,8 @@ public static Literal randomLiteral(DataType type) { | |
| throw new UncheckedIOException(e); | ||
| } | ||
| } | ||
| case UNSUPPORTED, OBJECT, DOC_DATA_TYPE, TSID_DATA_TYPE, PARTIAL_AGG -> throw new IllegalArgumentException( | ||
| "can't make random values for [" + type.typeName() + "]" | ||
| ); | ||
| case UNSUPPORTED, OBJECT, DOC_DATA_TYPE, TSID_DATA_TYPE, PARTIAL_AGG, AGGREGATE_METRIC_DOUBLE -> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At some point we'll have to be able to make random AggregateMetricDoubles. But later is fine. |
||
| throw new IllegalArgumentException("can't make random values for [" + type.typeName() + "]"); | ||
| }, type); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.