AggregatorFactory equals() and hashCode() methods.

This commit is contained in:
Gian Merlino 2014-08-29 15:02:04 -07:00
parent 08b6a2677d
commit 879e615314
3 changed files with 126 additions and 1 deletions

View File

@ -238,6 +238,52 @@ public class ApproximateHistogramAggregatorFactory implements AggregatorFactory
return new ApproximateHistogram(resolution); return new ApproximateHistogram(resolution);
} }
@Override
public boolean equals(Object o)
{
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ApproximateHistogramAggregatorFactory that = (ApproximateHistogramAggregatorFactory) o;
if (Float.compare(that.lowerLimit, lowerLimit) != 0) {
return false;
}
if (numBuckets != that.numBuckets) {
return false;
}
if (resolution != that.resolution) {
return false;
}
if (Float.compare(that.upperLimit, upperLimit) != 0) {
return false;
}
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) {
return false;
}
if (name != null ? !name.equals(that.name) : that.name != null) {
return false;
}
return true;
}
@Override
public int hashCode()
{
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (fieldName != null ? fieldName.hashCode() : 0);
result = 31 * result + resolution;
result = 31 * result + numBuckets;
result = 31 * result + (lowerLimit != +0.0f ? Float.floatToIntBits(lowerLimit) : 0);
result = 31 * result + (upperLimit != +0.0f ? Float.floatToIntBits(upperLimit) : 0);
return result;
}
@Override @Override
public String toString() public String toString()
{ {

View File

@ -148,6 +148,52 @@ public class ApproximateHistogramFoldingAggregatorFactory extends ApproximateHis
.array(); .array();
} }
@Override
public boolean equals(Object o)
{
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ApproximateHistogramAggregatorFactory that = (ApproximateHistogramAggregatorFactory) o;
if (Float.compare(that.lowerLimit, lowerLimit) != 0) {
return false;
}
if (numBuckets != that.numBuckets) {
return false;
}
if (resolution != that.resolution) {
return false;
}
if (Float.compare(that.upperLimit, upperLimit) != 0) {
return false;
}
if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) {
return false;
}
if (name != null ? !name.equals(that.name) : that.name != null) {
return false;
}
return true;
}
@Override
public int hashCode()
{
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (fieldName != null ? fieldName.hashCode() : 0);
result = 31 * result + resolution;
result = 31 * result + numBuckets;
result = 31 * result + (lowerLimit != +0.0f ? Float.floatToIntBits(lowerLimit) : 0);
result = 31 * result + (upperLimit != +0.0f ? Float.floatToIntBits(upperLimit) : 0);
return result;
}
@Override @Override
public String toString() public String toString()
{ {

View File

@ -39,7 +39,6 @@ import org.apache.commons.codec.binary.Base64;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -233,6 +232,40 @@ public class CardinalityAggregatorFactory implements AggregatorFactory
return HyperLogLogCollector.makeLatestCollector(); return HyperLogLogCollector.makeLatestCollector();
} }
@Override
public boolean equals(Object o)
{
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CardinalityAggregatorFactory that = (CardinalityAggregatorFactory) o;
if (byRow != that.byRow) {
return false;
}
if (fieldNames != null ? !fieldNames.equals(that.fieldNames) : that.fieldNames != null) {
return false;
}
if (name != null ? !name.equals(that.name) : that.name != null) {
return false;
}
return true;
}
@Override
public int hashCode()
{
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (fieldNames != null ? fieldNames.hashCode() : 0);
result = 31 * result + (byRow ? 1 : 0);
return result;
}
@Override @Override
public String toString() public String toString()
{ {