Skip to content

Commit 78400b8

Browse files
authored
InternalMultiBucketAggregation.InternalBucket does not implement writable anymore (#117310)
This allows to make some Bucket implementations leaner, in particular terms and multi-terms aggregations
1 parent 5d9ad67 commit 78400b8

File tree

24 files changed

+94
-111
lines changed

24 files changed

+94
-111
lines changed

modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/adjacency/InternalAdjacencyMatrix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public class InternalAdjacencyMatrix extends InternalMultiBucketAggregation<InternalAdjacencyMatrix, InternalAdjacencyMatrix.InternalBucket>
3434
implements
3535
AdjacencyMatrix {
36-
public static class InternalBucket extends InternalMultiBucketAggregation.InternalBucket implements AdjacencyMatrix.Bucket {
36+
public static class InternalBucket extends InternalMultiBucketAggregation.InternalBucketWritable implements AdjacencyMatrix.Bucket {
3737

3838
private final String key;
3939
private final long docCount;

modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/timeseries/InternalTimeSeries.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class InternalTimeSeries extends InternalMultiBucketAggregation<InternalT
3434
/**
3535
* A bucket associated with a specific time series (identified by its key)
3636
*/
37-
public static class InternalBucket extends InternalMultiBucketAggregation.InternalBucket {
37+
public static class InternalBucket extends InternalMultiBucketAggregation.InternalBucketWritable {
3838
protected long bucketOrd;
3939
protected final BytesRef key;
4040
// TODO: make computing docCount optional

server/src/main/java/org/elasticsearch/search/aggregations/InternalMultiBucketAggregation.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private List<B> reducePipelineBuckets(AggregationReduceContext reduceContext, Pi
220220
return reducedBuckets;
221221
}
222222

223-
public abstract static class InternalBucket implements Bucket, Writeable {
223+
public abstract static class InternalBucket implements Bucket {
224224

225225
public Object getProperty(String containingAggName, List<String> path) {
226226
if (path.isEmpty()) {
@@ -248,4 +248,8 @@ public Object getProperty(String containingAggName, List<String> path) {
248248
return aggregation.getProperty(path.subList(1, path.size()));
249249
}
250250
}
251+
252+
/** A {@link InternalBucket} that implements the {@link Writeable} interface. Most implementation might want
253+
* to use this one except when specific logic is need to write into the stream. */
254+
public abstract static class InternalBucketWritable extends InternalBucket implements Writeable {}
251255
}

server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/InternalComposite.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ public int hashCode() {
320320
return Objects.hash(super.hashCode(), size, buckets, afterKey, Arrays.hashCode(reverseMuls), Arrays.hashCode(missingOrders));
321321
}
322322

323-
public static class InternalBucket extends InternalMultiBucketAggregation.InternalBucket implements CompositeAggregation.Bucket {
323+
public static class InternalBucket extends InternalMultiBucketAggregation.InternalBucketWritable
324+
implements
325+
CompositeAggregation.Bucket {
324326

325327
private final CompositeKey key;
326328
private final long docCount;

server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/InternalFilters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import java.util.Objects;
3131

3232
public class InternalFilters extends InternalMultiBucketAggregation<InternalFilters, InternalFilters.InternalBucket> implements Filters {
33-
public static class InternalBucket extends InternalMultiBucketAggregation.InternalBucket implements Filters.Bucket {
33+
public static class InternalBucket extends InternalMultiBucketAggregation.InternalBucketWritable implements Filters.Bucket {
3434

3535
private final String key;
3636
private long docCount;

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
@@ -19,7 +19,7 @@
1919
import java.io.IOException;
2020
import java.util.Objects;
2121

22-
public abstract class InternalGeoGridBucket extends InternalMultiBucketAggregation.InternalBucket
22+
public abstract class InternalGeoGridBucket extends InternalMultiBucketAggregation.InternalBucketWritable
2323
implements
2424
GeoGrid.Bucket,
2525
Comparable<InternalGeoGridBucket> {

server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/AbstractHistogramBucket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* A bucket in the histogram where documents fall in
1818
*/
19-
public abstract class AbstractHistogramBucket extends InternalMultiBucketAggregation.InternalBucket {
19+
public abstract class AbstractHistogramBucket extends InternalMultiBucketAggregation.InternalBucketWritable {
2020

2121
protected final long docCount;
2222
protected final InternalAggregations aggregations;

server/src/main/java/org/elasticsearch/search/aggregations/bucket/prefix/InternalIpPrefix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
public class InternalIpPrefix extends InternalMultiBucketAggregation<InternalIpPrefix, InternalIpPrefix.Bucket> {
3535

36-
public static class Bucket extends InternalMultiBucketAggregation.InternalBucket
36+
public static class Bucket extends InternalMultiBucketAggregation.InternalBucketWritable
3737
implements
3838
IpPrefix.Bucket,
3939
KeyComparable<InternalIpPrefix.Bucket> {

server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalBinaryRange.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public final class InternalBinaryRange extends InternalMultiBucketAggregation<In
3636
implements
3737
Range {
3838

39-
public static class Bucket extends InternalMultiBucketAggregation.InternalBucket implements Range.Bucket {
39+
public static class Bucket extends InternalMultiBucketAggregation.InternalBucketWritable implements Range.Bucket {
4040

4141
private final transient DocValueFormat format;
4242
private final String key;

server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class InternalRange<B extends InternalRange.Bucket, R extends InternalRan
3636
@SuppressWarnings("rawtypes")
3737
static final Factory FACTORY = new Factory();
3838

39-
public static class Bucket extends InternalMultiBucketAggregation.InternalBucket implements Range.Bucket {
39+
public static class Bucket extends InternalMultiBucketAggregation.InternalBucketWritable implements Range.Bucket {
4040

4141
protected final transient DocValueFormat format;
4242
protected final double from;

0 commit comments

Comments
 (0)