SubstringDimExtractionFn, BoundDimFilter: Implement typical style toString. (#3658)

This commit is contained in:
Gian Merlino 2016-11-04 13:31:47 -07:00 committed by Jonathan Wei
parent 2bbbad9908
commit 4cbebd0931
2 changed files with 42 additions and 0 deletions

View File

@ -130,4 +130,10 @@ public class SubstringDimExtractionFn extends DimExtractionFn
result = 31 * result + end;
return result;
}
@Override
public String toString()
{
return String.format("substring(%s, %s)", index, getLength());
}
}

View File

@ -276,6 +276,42 @@ public class BoundDimFilter implements DimFilter
return result;
}
@Override
public String toString()
{
final StringBuilder builder = new StringBuilder();
if (lower != null) {
builder.append(lower);
if (lowerStrict) {
builder.append(" < ");
} else {
builder.append(" <= ");
}
}
if (extractionFn != null) {
builder.append(String.format("%s(%s)", extractionFn, dimension));
} else {
builder.append(dimension);
}
if (!ordering.equals(StringComparators.LEXICOGRAPHIC)) {
builder.append(String.format(" as %s", ordering.toString()));
}
if (upper != null) {
if (upperStrict) {
builder.append(" < ");
} else {
builder.append(" <= ");
}
builder.append(upper);
}
return builder.toString();
}
private Supplier<DruidLongPredicate> makeLongPredicateSupplier()
{
return new Supplier<DruidLongPredicate>()