Add equals and hashcode implementation to KnownCardinalityUpperBound (#62930) (#63045)

This commit is contained in:
Ignacio Vera 2020-09-30 09:14:56 +02:00 committed by GitHub
parent df93f46888
commit 8e67ec8647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -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> R map(IntFunction<R> 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);
}
}
}