From e4a6cd54683b468f2eef407c100cfcd4a22413b4 Mon Sep 17 00:00:00 2001 From: iverase Date: Mon, 13 Dec 2021 11:16:31 +0100 Subject: [PATCH 1/3] Change visibility of GeoGrid base class and method for package private to protected --- .../aggregations/bucket/geogrid/CellValues.java | 4 ++-- .../bucket/geogrid/GeoGridAggregator.java | 6 +++--- .../bucket/geogrid/GeoHashCellIdSource.java | 4 ++-- .../bucket/geogrid/GeoHashGridAggregator.java | 4 ++-- .../bucket/geogrid/GeoTileCellIdSource.java | 4 ++-- .../bucket/geogrid/GeoTileGridAggregator.java | 4 ++-- .../bucket/geogrid/InternalGeoGrid.java | 8 ++++---- .../bucket/geogrid/InternalGeoGridBucket.java | 2 +- .../bucket/geogrid/InternalGeoHashGrid.java | 14 +++++++------- .../bucket/geogrid/InternalGeoTileGrid.java | 14 +++++++------- .../bucket/geogrid/GeoGridAggregatorTestCase.java | 0 .../bucket/geogrid/GeoGridTestCase.java | 0 12 files changed, 32 insertions(+), 32 deletions(-) rename {server/src/test => test/framework/src/main}/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java (100%) rename {server/src/test => test/framework/src/main}/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridTestCase.java (100%) diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/CellValues.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/CellValues.java index 424fbc9c2dfda..06e177e7e5ecb 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/CellValues.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/CellValues.java @@ -17,7 +17,7 @@ * the geo-doc-values. Class must encode the values and then * sort them in order to account for the cells correctly. */ -abstract class CellValues extends AbstractSortingNumericDocValues { +public abstract class CellValues extends AbstractSortingNumericDocValues { private MultiGeoPointValues geoValues; protected int precision; @@ -51,5 +51,5 @@ public boolean advanceExact(int docId) throws IOException { * @param valuesIdx the index into values to set * @return valuesIdx + 1 if value was set, valuesIdx otherwise. */ - abstract int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx); + protected abstract int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregator.java index bddef4f45635e..ea247b1eda440 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregator.java @@ -38,7 +38,7 @@ public abstract class GeoGridAggregator> extends Bu protected final ValuesSource.Numeric valuesSource; protected final LongKeyedBucketOrds bucketOrds; - GeoGridAggregator( + protected GeoGridAggregator( String name, AggregatorFactories factories, ValuesSource.Numeric valuesSource, @@ -92,14 +92,14 @@ public void collect(int doc, long owningBucketOrd) throws IOException { }; } - abstract T buildAggregation(String name, int requiredSize, List buckets, Map metadata); + protected abstract T buildAggregation(String name, int requiredSize, List buckets, Map metadata); /** * This method is used to return a re-usable instance of the bucket when building * the aggregation. * @return a new {@link InternalGeoGridBucket} implementation with empty parameters */ - abstract InternalGeoGridBucket newEmptyBucket(); + protected abstract InternalGeoGridBucket newEmptyBucket(); @Override public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashCellIdSource.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashCellIdSource.java index 29a4e3b9a115d..8eaaa949cd92c 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashCellIdSource.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashCellIdSource.java @@ -65,7 +65,7 @@ private static class UnboundedCellValues extends CellValues { } @Override - int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) { + protected int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) { values[valuesIdx] = Geohash.longEncode(target.getLon(), target.getLat(), precision); return valuesIdx + 1; } @@ -83,7 +83,7 @@ private static class BoundedCellValues extends CellValues { } @Override - int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) { + protected int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) { final String hash = Geohash.stringEncode(target.getLon(), target.getLat(), precision); if (validHash(hash)) { values[valuesIdx] = Geohash.longEncode(hash); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java index c07030a2069f5..b6cd51cfc39e6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java @@ -38,7 +38,7 @@ public GeoHashGridAggregator( } @Override - InternalGeoHashGrid buildAggregation(String name, int requiredSize, List buckets, Map metadata) { + protected InternalGeoHashGrid buildAggregation(String name, int requiredSize, List buckets, Map metadata) { return new InternalGeoHashGrid(name, requiredSize, buckets, metadata); } @@ -47,7 +47,7 @@ public InternalGeoHashGrid buildEmptyAggregation() { return new InternalGeoHashGrid(name, requiredSize, Collections.emptyList(), metadata()); } - InternalGeoGridBucket newEmptyBucket() { + protected InternalGeoGridBucket newEmptyBucket() { return new InternalGeoHashGridBucket(0, 0, null); } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileCellIdSource.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileCellIdSource.java index 20dda5d15f033..49c747156dce3 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileCellIdSource.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileCellIdSource.java @@ -64,7 +64,7 @@ private static class UnboundedCellValues extends CellValues { } @Override - int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) { + protected int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) { values[valuesIdx] = GeoTileUtils.longEncode(target.getLon(), target.getLat(), precision); return valuesIdx + 1; } @@ -97,7 +97,7 @@ protected BoundedCellValues(MultiGeoPointValues geoValues, int precision, GeoBou } @Override - int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) { + protected int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) { final int x = GeoTileUtils.getXTile(target.getLon(), this.tiles); final int y = GeoTileUtils.getYTile(target.getLat(), this.tiles); if (validTile(x, y)) { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileGridAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileGridAggregator.java index 4547cc2e99d4a..b26472199ba15 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileGridAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileGridAggregator.java @@ -39,7 +39,7 @@ public GeoTileGridAggregator( } @Override - InternalGeoTileGrid buildAggregation(String name, int requiredSize, List buckets, Map metadata) { + protected InternalGeoTileGrid buildAggregation(String name, int requiredSize, List buckets, Map metadata) { return new InternalGeoTileGrid(name, requiredSize, buckets, metadata); } @@ -48,7 +48,7 @@ public InternalGeoTileGrid buildEmptyAggregation() { return new InternalGeoTileGrid(name, requiredSize, Collections.emptyList(), metadata()); } - InternalGeoGridBucket newEmptyBucket() { + protected InternalGeoGridBucket newEmptyBucket() { return new InternalGeoTileGridBucket(0, 0, null); } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java index 3a226f83ec11e..12a2e244ed2b9 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java @@ -38,13 +38,13 @@ public abstract class InternalGeoGrid extends I protected final int requiredSize; protected final List buckets; - InternalGeoGrid(String name, int requiredSize, List buckets, Map metadata) { + protected InternalGeoGrid(String name, int requiredSize, List buckets, Map metadata) { super(name, metadata); this.requiredSize = requiredSize; this.buckets = buckets; } - abstract Writeable.Reader getBucketReader(); + protected abstract Writeable.Reader getBucketReader(); /** * Read from a stream. @@ -62,7 +62,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { out.writeList(buckets); } - abstract InternalGeoGrid create(String name, int requiredSize, List buckets, Map metadata); + protected abstract InternalGeoGrid create(String name, int requiredSize, List buckets, Map metadata); @Override public List getBuckets() { @@ -117,7 +117,7 @@ protected InternalGeoGridBucket reduceBucket(List buckets return createBucket(buckets.get(0).hashAsLong, docCount, aggs); } - abstract B createBucket(long hashAsLong, long docCount, InternalAggregations aggregations); + protected abstract B createBucket(long hashAsLong, long docCount, InternalAggregations aggregations); @Override public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGridBucket.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGridBucket.java index 7662fc8a172e1..9c8ac145fca47 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGridBucket.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGridBucket.java @@ -51,7 +51,7 @@ public void writeTo(StreamOutput out) throws IOException { aggregations.writeTo(out); } - long hashAsLong() { + protected long hashAsLong() { return hashAsLong; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java index 0a1fa2009f53b..a4a274b7b92a5 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java @@ -40,22 +40,22 @@ public InternalGeoGridBucket createBucket(InternalAggregations aggregations, Int } @Override - InternalGeoGrid create( - String name, - int requiredSize, - List buckets, - Map metadata + protected InternalGeoGrid create( + String name, + int requiredSize, + List buckets, + Map metadata ) { return new InternalGeoHashGrid(name, requiredSize, buckets, metadata); } @Override - InternalGeoHashGridBucket createBucket(long hashAsLong, long docCount, InternalAggregations aggregations) { + protected InternalGeoHashGridBucket createBucket(long hashAsLong, long docCount, InternalAggregations aggregations) { return new InternalGeoHashGridBucket(hashAsLong, docCount, aggregations); } @Override - Reader getBucketReader() { + protected Reader getBucketReader() { return InternalGeoHashGridBucket::new; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoTileGrid.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoTileGrid.java index a036e772b1501..84b1e81376504 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoTileGrid.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoTileGrid.java @@ -40,22 +40,22 @@ public InternalGeoGridBucket createBucket(InternalAggregations aggregations, Int } @Override - InternalGeoGrid create( - String name, - int requiredSize, - List buckets, - Map metadata + protected InternalGeoGrid create( + String name, + int requiredSize, + List buckets, + Map metadata ) { return new InternalGeoTileGrid(name, requiredSize, buckets, metadata); } @Override - InternalGeoTileGridBucket createBucket(long hashAsLong, long docCount, InternalAggregations aggregations) { + protected InternalGeoTileGridBucket createBucket(long hashAsLong, long docCount, InternalAggregations aggregations) { return new InternalGeoTileGridBucket(hashAsLong, docCount, aggregations); } @Override - Reader getBucketReader() { + protected Reader getBucketReader() { return InternalGeoTileGridBucket::new; } diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java b/test/framework/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java similarity index 100% rename from server/src/test/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java rename to test/framework/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridTestCase.java b/test/framework/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridTestCase.java similarity index 100% rename from server/src/test/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridTestCase.java rename to test/framework/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridTestCase.java From f9ae08fc7fe8653c7d26a49bf463624216c3366b Mon Sep 17 00:00:00 2001 From: iverase Date: Mon, 13 Dec 2021 11:41:43 +0100 Subject: [PATCH 2/3] precommit --- .../aggregations/bucket/geogrid/GeoHashGridAggregator.java | 7 ++++++- .../aggregations/bucket/geogrid/GeoTileGridAggregator.java | 7 ++++++- .../aggregations/bucket/geogrid/InternalGeoGrid.java | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java index b6cd51cfc39e6..2de98c3d569b2 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java @@ -38,7 +38,12 @@ public GeoHashGridAggregator( } @Override - protected InternalGeoHashGrid buildAggregation(String name, int requiredSize, List buckets, Map metadata) { + protected InternalGeoHashGrid buildAggregation( + String name, + int requiredSize, + List buckets, + Map metadata + ) { return new InternalGeoHashGrid(name, requiredSize, buckets, metadata); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileGridAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileGridAggregator.java index b26472199ba15..73975302fa4c8 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileGridAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileGridAggregator.java @@ -39,7 +39,12 @@ public GeoTileGridAggregator( } @Override - protected InternalGeoTileGrid buildAggregation(String name, int requiredSize, List buckets, Map metadata) { + protected InternalGeoTileGrid buildAggregation( + String name, + int requiredSize, + List buckets, + Map metadata + ) { return new InternalGeoTileGrid(name, requiredSize, buckets, metadata); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java index 12a2e244ed2b9..2135841ac7800 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java @@ -62,7 +62,12 @@ protected void doWriteTo(StreamOutput out) throws IOException { out.writeList(buckets); } - protected abstract InternalGeoGrid create(String name, int requiredSize, List buckets, Map metadata); + protected abstract InternalGeoGrid create( + String name, + int requiredSize, + List buckets, + Map metadata + ); @Override public List getBuckets() { From c8523797cd54477ac4d7e7ca61cf50b17d7eacdd Mon Sep 17 00:00:00 2001 From: iverase Date: Mon, 13 Dec 2021 11:59:03 +0100 Subject: [PATCH 3/3] spotless --- .../aggregations/bucket/geogrid/InternalGeoHashGrid.java | 8 ++++---- .../aggregations/bucket/geogrid/InternalGeoTileGrid.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java index a4a274b7b92a5..393c1ed9bfb20 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java @@ -41,10 +41,10 @@ public InternalGeoGridBucket createBucket(InternalAggregations aggregations, Int @Override protected InternalGeoGrid create( - String name, - int requiredSize, - List buckets, - Map metadata + String name, + int requiredSize, + List buckets, + Map metadata ) { return new InternalGeoHashGrid(name, requiredSize, buckets, metadata); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoTileGrid.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoTileGrid.java index 84b1e81376504..c5215957505de 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoTileGrid.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoTileGrid.java @@ -41,10 +41,10 @@ public InternalGeoGridBucket createBucket(InternalAggregations aggregations, Int @Override protected InternalGeoGrid create( - String name, - int requiredSize, - List buckets, - Map metadata + String name, + int requiredSize, + List buckets, + Map metadata ) { return new InternalGeoTileGrid(name, requiredSize, buckets, metadata); }