From 8e67ec8647a7402dc189a95d9bc86c9972b31603 Mon Sep 17 00:00:00 2001 From: Ignacio Vera Date: Wed, 30 Sep 2020 09:14:56 +0200 Subject: [PATCH] Add equals and hashcode implementation to KnownCardinalityUpperBound (#62930) (#63045) --- .../aggregations/CardinalityUpperBound.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/CardinalityUpperBound.java b/server/src/main/java/org/elasticsearch/search/aggregations/CardinalityUpperBound.java index 9adba8dc90b..94e80b54588 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/CardinalityUpperBound.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/CardinalityUpperBound.java @@ -33,7 +33,7 @@ public abstract class CardinalityUpperBound { /** * {@link Aggregator}s with this cardinality won't collect any data at * all. For the most part this happens when an aggregation is inside of a - * {@link BucketsAggregator} that is pointing to an unmapped field. + * {@link BucketsAggregator} that is pointing to an unmapped field. */ public static final CardinalityUpperBound NONE = new CardinalityUpperBound() { @Override @@ -129,5 +129,18 @@ public abstract class CardinalityUpperBound { public R map(IntFunction mapper) { return mapper.apply(estimate); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + KnownCardinalityUpperBound that = (KnownCardinalityUpperBound) o; + return estimate == that.estimate; + } + + @Override + public int hashCode() { + return Integer.hashCode(estimate); + } } }