Skip to content

Commit b011c17

Browse files
authored
Change visibility of GeoGrid base class and methods from package private to protected (#81643)
This change should help implemening new GeoGrid aggregations over geo_points in a different module.
1 parent 1751ced commit b011c17

File tree

12 files changed

+39
-24
lines changed

12 files changed

+39
-24
lines changed

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/CellValues.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* the geo-doc-values. Class must encode the values and then
1818
* sort them in order to account for the cells correctly.
1919
*/
20-
abstract class CellValues extends AbstractSortingNumericDocValues {
20+
public abstract class CellValues extends AbstractSortingNumericDocValues {
2121
private MultiGeoPointValues geoValues;
2222
protected int precision;
2323

@@ -51,5 +51,5 @@ public boolean advanceExact(int docId) throws IOException {
5151
* @param valuesIdx the index into <code>values</code> to set
5252
* @return valuesIdx + 1 if value was set, valuesIdx otherwise.
5353
*/
54-
abstract int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx);
54+
protected abstract int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx);
5555
}

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public abstract class GeoGridAggregator<T extends InternalGeoGrid<?>> extends Bu
3838
protected final ValuesSource.Numeric valuesSource;
3939
protected final LongKeyedBucketOrds bucketOrds;
4040

41-
GeoGridAggregator(
41+
protected GeoGridAggregator(
4242
String name,
4343
AggregatorFactories factories,
4444
ValuesSource.Numeric valuesSource,
@@ -92,14 +92,14 @@ public void collect(int doc, long owningBucketOrd) throws IOException {
9292
};
9393
}
9494

95-
abstract T buildAggregation(String name, int requiredSize, List<InternalGeoGridBucket> buckets, Map<String, Object> metadata);
95+
protected abstract T buildAggregation(String name, int requiredSize, List<InternalGeoGridBucket> buckets, Map<String, Object> metadata);
9696

9797
/**
9898
* This method is used to return a re-usable instance of the bucket when building
9999
* the aggregation.
100100
* @return a new {@link InternalGeoGridBucket} implementation with empty parameters
101101
*/
102-
abstract InternalGeoGridBucket newEmptyBucket();
102+
protected abstract InternalGeoGridBucket newEmptyBucket();
103103

104104
@Override
105105
public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws IOException {

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashCellIdSource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private static class UnboundedCellValues extends CellValues {
6565
}
6666

6767
@Override
68-
int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) {
68+
protected int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) {
6969
values[valuesIdx] = Geohash.longEncode(target.getLon(), target.getLat(), precision);
7070
return valuesIdx + 1;
7171
}
@@ -83,7 +83,7 @@ private static class BoundedCellValues extends CellValues {
8383
}
8484

8585
@Override
86-
int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) {
86+
protected int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) {
8787
final String hash = Geohash.stringEncode(target.getLon(), target.getLat(), precision);
8888
if (validHash(hash)) {
8989
values[valuesIdx] = Geohash.longEncode(hash);

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ public GeoHashGridAggregator(
3838
}
3939

4040
@Override
41-
InternalGeoHashGrid buildAggregation(String name, int requiredSize, List<InternalGeoGridBucket> buckets, Map<String, Object> metadata) {
41+
protected InternalGeoHashGrid buildAggregation(
42+
String name,
43+
int requiredSize,
44+
List<InternalGeoGridBucket> buckets,
45+
Map<String, Object> metadata
46+
) {
4247
return new InternalGeoHashGrid(name, requiredSize, buckets, metadata);
4348
}
4449

@@ -47,7 +52,7 @@ public InternalGeoHashGrid buildEmptyAggregation() {
4752
return new InternalGeoHashGrid(name, requiredSize, Collections.emptyList(), metadata());
4853
}
4954

50-
InternalGeoGridBucket newEmptyBucket() {
55+
protected InternalGeoGridBucket newEmptyBucket() {
5156
return new InternalGeoHashGridBucket(0, 0, null);
5257
}
5358
}

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileCellIdSource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private static class UnboundedCellValues extends CellValues {
6464
}
6565

6666
@Override
67-
int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) {
67+
protected int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) {
6868
values[valuesIdx] = GeoTileUtils.longEncode(target.getLon(), target.getLat(), precision);
6969
return valuesIdx + 1;
7070
}
@@ -97,7 +97,7 @@ protected BoundedCellValues(MultiGeoPointValues geoValues, int precision, GeoBou
9797
}
9898

9999
@Override
100-
int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) {
100+
protected int advanceValue(org.elasticsearch.common.geo.GeoPoint target, int valuesIdx) {
101101
final int x = GeoTileUtils.getXTile(target.getLon(), this.tiles);
102102
final int y = GeoTileUtils.getYTile(target.getLat(), this.tiles);
103103
if (validTile(x, y)) {

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoTileGridAggregator.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ public GeoTileGridAggregator(
3939
}
4040

4141
@Override
42-
InternalGeoTileGrid buildAggregation(String name, int requiredSize, List<InternalGeoGridBucket> buckets, Map<String, Object> metadata) {
42+
protected InternalGeoTileGrid buildAggregation(
43+
String name,
44+
int requiredSize,
45+
List<InternalGeoGridBucket> buckets,
46+
Map<String, Object> metadata
47+
) {
4348
return new InternalGeoTileGrid(name, requiredSize, buckets, metadata);
4449
}
4550

@@ -48,7 +53,7 @@ public InternalGeoTileGrid buildEmptyAggregation() {
4853
return new InternalGeoTileGrid(name, requiredSize, Collections.emptyList(), metadata());
4954
}
5055

51-
InternalGeoGridBucket newEmptyBucket() {
56+
protected InternalGeoGridBucket newEmptyBucket() {
5257
return new InternalGeoTileGridBucket(0, 0, null);
5358
}
5459
}

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ public abstract class InternalGeoGrid<B extends InternalGeoGridBucket> extends I
3838
protected final int requiredSize;
3939
protected final List<InternalGeoGridBucket> buckets;
4040

41-
InternalGeoGrid(String name, int requiredSize, List<InternalGeoGridBucket> buckets, Map<String, Object> metadata) {
41+
protected InternalGeoGrid(String name, int requiredSize, List<InternalGeoGridBucket> buckets, Map<String, Object> metadata) {
4242
super(name, metadata);
4343
this.requiredSize = requiredSize;
4444
this.buckets = buckets;
4545
}
4646

47-
abstract Writeable.Reader<B> getBucketReader();
47+
protected abstract Writeable.Reader<B> getBucketReader();
4848

4949
/**
5050
* Read from a stream.
@@ -62,7 +62,12 @@ protected void doWriteTo(StreamOutput out) throws IOException {
6262
out.writeList(buckets);
6363
}
6464

65-
abstract InternalGeoGrid<B> create(String name, int requiredSize, List<InternalGeoGridBucket> buckets, Map<String, Object> metadata);
65+
protected abstract InternalGeoGrid<B> create(
66+
String name,
67+
int requiredSize,
68+
List<InternalGeoGridBucket> buckets,
69+
Map<String, Object> metadata
70+
);
6671

6772
@Override
6873
public List<InternalGeoGridBucket> getBuckets() {
@@ -117,7 +122,7 @@ protected InternalGeoGridBucket reduceBucket(List<InternalGeoGridBucket> buckets
117122
return createBucket(buckets.get(0).hashAsLong, docCount, aggs);
118123
}
119124

120-
abstract B createBucket(long hashAsLong, long docCount, InternalAggregations aggregations);
125+
protected abstract B createBucket(long hashAsLong, long docCount, InternalAggregations aggregations);
121126

122127
@Override
123128
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGridBucket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void writeTo(StreamOutput out) throws IOException {
5151
aggregations.writeTo(out);
5252
}
5353

54-
long hashAsLong() {
54+
protected long hashAsLong() {
5555
return hashAsLong;
5656
}
5757

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public InternalGeoGridBucket createBucket(InternalAggregations aggregations, Int
4040
}
4141

4242
@Override
43-
InternalGeoGrid<InternalGeoHashGridBucket> create(
43+
protected InternalGeoGrid<InternalGeoHashGridBucket> create(
4444
String name,
4545
int requiredSize,
4646
List<InternalGeoGridBucket> buckets,
@@ -50,12 +50,12 @@ InternalGeoGrid<InternalGeoHashGridBucket> create(
5050
}
5151

5252
@Override
53-
InternalGeoHashGridBucket createBucket(long hashAsLong, long docCount, InternalAggregations aggregations) {
53+
protected InternalGeoHashGridBucket createBucket(long hashAsLong, long docCount, InternalAggregations aggregations) {
5454
return new InternalGeoHashGridBucket(hashAsLong, docCount, aggregations);
5555
}
5656

5757
@Override
58-
Reader<InternalGeoHashGridBucket> getBucketReader() {
58+
protected Reader<InternalGeoHashGridBucket> getBucketReader() {
5959
return InternalGeoHashGridBucket::new;
6060
}
6161

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoTileGrid.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public InternalGeoGridBucket createBucket(InternalAggregations aggregations, Int
4040
}
4141

4242
@Override
43-
InternalGeoGrid<InternalGeoTileGridBucket> create(
43+
protected InternalGeoGrid<InternalGeoTileGridBucket> create(
4444
String name,
4545
int requiredSize,
4646
List<InternalGeoGridBucket> buckets,
@@ -50,12 +50,12 @@ InternalGeoGrid<InternalGeoTileGridBucket> create(
5050
}
5151

5252
@Override
53-
InternalGeoTileGridBucket createBucket(long hashAsLong, long docCount, InternalAggregations aggregations) {
53+
protected InternalGeoTileGridBucket createBucket(long hashAsLong, long docCount, InternalAggregations aggregations) {
5454
return new InternalGeoTileGridBucket(hashAsLong, docCount, aggregations);
5555
}
5656

5757
@Override
58-
Reader<InternalGeoTileGridBucket> getBucketReader() {
58+
protected Reader<InternalGeoTileGridBucket> getBucketReader() {
5959
return InternalGeoTileGridBucket::new;
6060
}
6161

0 commit comments

Comments
 (0)