-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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 value ranges for GeoTile aggregation metrics metrics in the meta layer #71611
Merged
iverase
merged 7 commits into
elastic:feature/vector-tiles
from
iverase:rangesMetaLayer
Apr 22, 2021
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
605c8fd
Add value ranges for bucket metrics in meta layer
iverase 020d6c9
fix rounding
iverase 199bcf8
Merge branch 'feature/vector-tiles' into rangesMetaLayer
iverase 5977e6e
add aggregation in a more generic way
iverase 201575f
iter
iverase 1b33938
Merge branch 'feature/vector-tiles' into rangesMetaLayer
iverase 47a58fb
iter
iverase 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 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 |
---|---|---|
|
@@ -28,14 +28,22 @@ | |
import org.elasticsearch.rest.RestResponse; | ||
import org.elasticsearch.rest.RestStatus; | ||
import org.elasticsearch.rest.action.RestResponseListener; | ||
import org.elasticsearch.search.aggregations.AggregationBuilder; | ||
import org.elasticsearch.search.aggregations.AggregatorFactories; | ||
import org.elasticsearch.search.aggregations.PipelineAggregationBuilder; | ||
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoTileUtils; | ||
import org.elasticsearch.search.aggregations.metrics.AvgAggregationBuilder; | ||
import org.elasticsearch.search.aggregations.metrics.CardinalityAggregationBuilder; | ||
import org.elasticsearch.search.aggregations.metrics.MaxAggregationBuilder; | ||
import org.elasticsearch.search.aggregations.metrics.MinAggregationBuilder; | ||
import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder; | ||
import org.elasticsearch.search.builder.SearchSourceBuilder; | ||
import org.elasticsearch.search.fetch.subphase.FieldAndFormat; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
@@ -226,9 +234,31 @@ public AggregatorFactories.Builder getAggBuilder() { | |
} | ||
|
||
public void setAggBuilder(AggregatorFactories.Builder aggBuilder) { | ||
// TODO: validation | ||
for (AggregationBuilder aggregation : aggBuilder.getAggregatorFactories()) { | ||
final String type = aggregation.getType(); | ||
switch (type) { | ||
case MinAggregationBuilder.NAME: | ||
case MaxAggregationBuilder.NAME: | ||
case AvgAggregationBuilder.NAME: | ||
case SumAggregationBuilder.NAME: | ||
case CardinalityAggregationBuilder.NAME: | ||
break; | ||
default: | ||
// top term and percentile should be supported | ||
throw new IllegalArgumentException("Unsupported aggregation of type [" + type + "]"); | ||
} | ||
} | ||
for (PipelineAggregationBuilder aggregation : aggBuilder.getPipelineAggregatorFactories()) { | ||
// should not have pipeline aggregations | ||
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. Why? |
||
final String type = aggregation.getType(); | ||
throw new IllegalArgumentException("Unsupported pipeline aggregation of type [" + type + "]"); | ||
} | ||
this.aggBuilder = aggBuilder; | ||
} | ||
|
||
public Collection<AggregationBuilder> getAggregations() { | ||
return aggBuilder == null ? emptyList() : aggBuilder.getAggregatorFactories(); | ||
} | ||
} | ||
|
||
protected AbstractVectorTileSearchAction(Supplier<R> emptyRequestProvider) { | ||
|
This file contains 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 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 |
---|---|---|
|
@@ -57,10 +57,10 @@ public void box(VectorTile.Tile.Feature.Builder featureBuilder, double minLon, d | |
} | ||
|
||
private int lat(double lat) { | ||
return (int) (pointYScale * (VectorTileUtils.latToSphericalMercator(lat) - rectangle.getMinY())) + extent; | ||
return (int) Math.round(pointYScale * (VectorTileUtils.latToSphericalMercator(lat) - rectangle.getMinY())) + extent; | ||
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. We should still probably get this in. |
||
} | ||
|
||
private int lon(double lon) { | ||
return (int) (pointXScale * (VectorTileUtils.lonToSphericalMercator(lon) - rectangle.getMinX())); | ||
return (int) Math.round(pointXScale * (VectorTileUtils.lonToSphericalMercator(lon) - rectangle.getMinX())); | ||
} | ||
} |
This file contains 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
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.
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 wait with this. I think I have some idea on how to make this more generic.
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 still wonder if 1) this should responsibility of the callers and 2) if we want to add these pipeline aggs, we need to throw an exception if we don't recognize the agg
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.
My hope is that a user of this API does not need to be an expert on Elasticsearch so we can provide this information from them. I am hoping to only support a subset of the aggregations, the ones that make sense.