From 4cbebd093136c98b325c9b7a309cf3c40bd1d37c Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Fri, 4 Nov 2016 13:31:47 -0700 Subject: [PATCH] SubstringDimExtractionFn, BoundDimFilter: Implement typical style toString. (#3658) --- .../extraction/SubstringDimExtractionFn.java | 6 ++++ .../io/druid/query/filter/BoundDimFilter.java | 36 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/processing/src/main/java/io/druid/query/extraction/SubstringDimExtractionFn.java b/processing/src/main/java/io/druid/query/extraction/SubstringDimExtractionFn.java index 4802c1cff8a..1fabf48406f 100644 --- a/processing/src/main/java/io/druid/query/extraction/SubstringDimExtractionFn.java +++ b/processing/src/main/java/io/druid/query/extraction/SubstringDimExtractionFn.java @@ -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()); + } } diff --git a/processing/src/main/java/io/druid/query/filter/BoundDimFilter.java b/processing/src/main/java/io/druid/query/filter/BoundDimFilter.java index 98db495d6e7..db86cc8853d 100644 --- a/processing/src/main/java/io/druid/query/filter/BoundDimFilter.java +++ b/processing/src/main/java/io/druid/query/filter/BoundDimFilter.java @@ -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 makeLongPredicateSupplier() { return new Supplier()