mirror of https://github.com/apache/druid.git
Add, fix equals, hashCode, toString on various classes. (#3723)
* TimeFormatExtractionFn: Add toString. * InDimFilter: Add toString, allow accepting any Collection of values. * DimensionTopNMetricSpec: Fix toString. * InvertedTopNMetricSpec: Add toString. * HyperUniqueFinalizingPostAggregator: Add equals, hashCode, toString.
This commit is contained in:
parent
477e0cab7c
commit
68735829ca
|
@ -89,4 +89,39 @@ public class HyperUniqueFinalizingPostAggregator implements PostAggregator
|
|||
{
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HyperUniqueFinalizingPostAggregator that = (HyperUniqueFinalizingPostAggregator) o;
|
||||
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) {
|
||||
return false;
|
||||
}
|
||||
return fieldName != null ? fieldName.equals(that.fieldName) : that.fieldName == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = name != null ? name.hashCode() : 0;
|
||||
result = 31 * result + (fieldName != null ? fieldName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "HyperUniqueFinalizingPostAggregator{" +
|
||||
"name='" + name + '\'' +
|
||||
", fieldName='" + fieldName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ import java.util.Locale;
|
|||
|
||||
public class TimeFormatExtractionFn implements ExtractionFn
|
||||
{
|
||||
private final DateTimeZone tz;
|
||||
private final String format;
|
||||
private final DateTimeZone tz;
|
||||
private final Locale locale;
|
||||
private final QueryGranularity granularity;
|
||||
private final DateTimeFormatter formatter;
|
||||
|
@ -161,4 +161,10 @@ public class TimeFormatExtractionFn implements ExtractionFn
|
|||
result = 31 * result + granularity.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("timeFormat(\"%s\", %s, %s, %s)", format, tz, locale, granularity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package io.druid.query.filter;
|
|||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Supplier;
|
||||
|
@ -40,6 +41,7 @@ import io.druid.segment.filter.InFilter;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -59,7 +61,7 @@ public class InDimFilter implements DimFilter
|
|||
@JsonCreator
|
||||
public InDimFilter(
|
||||
@JsonProperty("dimension") String dimension,
|
||||
@JsonProperty("values") List<String> values,
|
||||
@JsonProperty("values") Collection<String> values,
|
||||
@JsonProperty("extractionFn") ExtractionFn extractionFn
|
||||
)
|
||||
{
|
||||
|
@ -227,6 +229,26 @@ public class InDimFilter implements DimFilter
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
if (extractionFn != null) {
|
||||
builder.append(extractionFn).append("(");
|
||||
}
|
||||
|
||||
builder.append(dimension);
|
||||
|
||||
if (extractionFn != null) {
|
||||
builder.append(")");
|
||||
}
|
||||
|
||||
builder.append(" IN (").append(Joiner.on(", ").join(values)).append(")");
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
// As the set of filtered values can be large, parsing them as longs should be done only if needed, and only once.
|
||||
// Pass in a common long predicate supplier to all filters created by .toFilter(), so that
|
||||
// we only compute the long hashset/array once per query.
|
||||
|
|
|
@ -146,7 +146,7 @@ public class DimensionTopNMetricSpec implements TopNMetricSpec
|
|||
{
|
||||
return "DimensionTopNMetricSpec{" +
|
||||
"previousStop='" + previousStop + '\'' +
|
||||
"ordering='" + ordering + '\'' +
|
||||
", ordering=" + ordering +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
|
|
@ -165,4 +165,12 @@ public class InvertedTopNMetricSpec implements TopNMetricSpec
|
|||
{
|
||||
return delegate != null ? delegate.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "InvertedTopNMetricSpec{" +
|
||||
"delegate=" + delegate +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue