From 599aacce0fc911f2b1d4712063d1ab37465f2eb2 Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Mon, 28 Sep 2020 22:13:10 -0700 Subject: [PATCH] Remove Expr.visit. (#10437) * Remove Expr.visit. It isn't used and doesn't have tests. * Remove Visitor too. --- .../druid/math/expr/BinaryOperatorExpr.java | 8 ------ .../apache/druid/math/expr/ConstantExpr.java | 6 ----- .../java/org/apache/druid/math/expr/Expr.java | 20 ++------------ .../druid/math/expr/ExprMacroTable.java | 16 ------------ .../druid/math/expr/FunctionalExpr.java | 26 ------------------- .../druid/math/expr/IdentifierExpr.java | 6 ----- .../druid/math/expr/UnaryOperatorExpr.java | 7 ----- .../druid/query/expression/TrimExprMacro.java | 8 ------ 8 files changed, 2 insertions(+), 95 deletions(-) diff --git a/core/src/main/java/org/apache/druid/math/expr/BinaryOperatorExpr.java b/core/src/main/java/org/apache/druid/math/expr/BinaryOperatorExpr.java index 9db527bf5b4..128a7808c10 100644 --- a/core/src/main/java/org/apache/druid/math/expr/BinaryOperatorExpr.java +++ b/core/src/main/java/org/apache/druid/math/expr/BinaryOperatorExpr.java @@ -46,14 +46,6 @@ abstract class BinaryOpExprBase implements Expr this.right = right; } - @Override - public void visit(Visitor visitor) - { - left.visit(visitor); - right.visit(visitor); - visitor.visit(this); - } - @Override public Expr visit(Shuttle shuttle) { diff --git a/core/src/main/java/org/apache/druid/math/expr/ConstantExpr.java b/core/src/main/java/org/apache/druid/math/expr/ConstantExpr.java index d9075f8c62e..279600da994 100644 --- a/core/src/main/java/org/apache/druid/math/expr/ConstantExpr.java +++ b/core/src/main/java/org/apache/druid/math/expr/ConstantExpr.java @@ -57,12 +57,6 @@ abstract class ConstantExpr implements Expr return true; } - @Override - public void visit(Visitor visitor) - { - visitor.visit(this); - } - @Override public Expr visit(Shuttle shuttle) { diff --git a/core/src/main/java/org/apache/druid/math/expr/Expr.java b/core/src/main/java/org/apache/druid/math/expr/Expr.java index b8fa44f6a24..be0a32e1da3 100644 --- a/core/src/main/java/org/apache/druid/math/expr/Expr.java +++ b/core/src/main/java/org/apache/druid/math/expr/Expr.java @@ -112,12 +112,6 @@ public interface Expr */ String stringify(); - /** - * Programmatically inspect the {@link Expr} tree with a {@link Visitor}. Each {@link Expr} is responsible for - * ensuring the {@link Visitor} can visit all of its {@link Expr} children before visiting itself - */ - void visit(Visitor visitor); - /** * Programatically rewrite the {@link Expr} tree with a {@link Shuttle}. Each {@link Expr} is responsible for * ensuring the {@link Shuttle} can visit all of its {@link Expr} children, as well as updating its children @@ -252,25 +246,15 @@ public interface Expr T[] getObjectVector(String name); long[] getLongVector(String name); + double[] getDoubleVector(String name); + @Nullable boolean[] getNullVector(String name); int getCurrentVectorSize(); } - /** - * Mechanism to inspect an {@link Expr}, implementing a {@link Visitor} allows visiting all children of an - * {@link Expr} - */ - interface Visitor - { - /** - * Provide the {@link Visitor} with an {@link Expr} to inspect - */ - void visit(Expr expr); - } - /** * Mechanism to rewrite an {@link Expr}, implementing a {@link Shuttle} allows visiting all children of an * {@link Expr}, and replacing them as desired. diff --git a/core/src/main/java/org/apache/druid/math/expr/ExprMacroTable.java b/core/src/main/java/org/apache/druid/math/expr/ExprMacroTable.java index 616297a57c3..8ff0d3d0108 100644 --- a/core/src/main/java/org/apache/druid/math/expr/ExprMacroTable.java +++ b/core/src/main/java/org/apache/druid/math/expr/ExprMacroTable.java @@ -111,13 +111,6 @@ public class ExprMacroTable analyzeInputsSupplier = Suppliers.memoize(this::supplyAnalyzeInputs); } - @Override - public void visit(final Visitor visitor) - { - arg.visit(visitor); - visitor.visit(this); - } - @Override public BindingAnalysis analyzeInputs() { @@ -184,15 +177,6 @@ public class ExprMacroTable ); } - @Override - public void visit(final Visitor visitor) - { - for (Expr arg : args) { - arg.visit(visitor); - } - visitor.visit(this); - } - @Override public BindingAnalysis analyzeInputs() { diff --git a/core/src/main/java/org/apache/druid/math/expr/FunctionalExpr.java b/core/src/main/java/org/apache/druid/math/expr/FunctionalExpr.java index 80bc1e7ab2e..df4de19fa03 100644 --- a/core/src/main/java/org/apache/druid/math/expr/FunctionalExpr.java +++ b/core/src/main/java/org/apache/druid/math/expr/FunctionalExpr.java @@ -101,13 +101,6 @@ class LambdaExpr implements Expr return StringUtils.format("(%s) -> %s", ARG_JOINER.join(getIdentifiers()), expr.stringify()); } - @Override - public void visit(Visitor visitor) - { - expr.visit(visitor); - visitor.visit(this); - } - @Override public Expr visit(Shuttle shuttle) { @@ -201,15 +194,6 @@ class FunctionExpr implements Expr return StringUtils.format("%s(%s)", name, ARG_JOINER.join(args.stream().map(Expr::stringify).iterator())); } - @Override - public void visit(Visitor visitor) - { - for (Expr child : args) { - child.visit(visitor); - } - visitor.visit(this); - } - @Override public Expr visit(Shuttle shuttle) { @@ -338,16 +322,6 @@ class ApplyFunctionExpr implements Expr ); } - @Override - public void visit(Visitor visitor) - { - lambdaExpr.visit(visitor); - for (Expr arg : argsExpr) { - arg.visit(visitor); - } - visitor.visit(this); - } - @Override public Expr visit(Shuttle shuttle) { diff --git a/core/src/main/java/org/apache/druid/math/expr/IdentifierExpr.java b/core/src/main/java/org/apache/druid/math/expr/IdentifierExpr.java index fd8d7aed175..da009326bb0 100644 --- a/core/src/main/java/org/apache/druid/math/expr/IdentifierExpr.java +++ b/core/src/main/java/org/apache/druid/math/expr/IdentifierExpr.java @@ -131,12 +131,6 @@ class IdentifierExpr implements Expr return StringUtils.format("\"%s\"", StringEscapeUtils.escapeJava(binding)); } - @Override - public void visit(Visitor visitor) - { - visitor.visit(this); - } - @Override public Expr visit(Shuttle shuttle) { diff --git a/core/src/main/java/org/apache/druid/math/expr/UnaryOperatorExpr.java b/core/src/main/java/org/apache/druid/math/expr/UnaryOperatorExpr.java index c741a5a808e..97a033e484e 100644 --- a/core/src/main/java/org/apache/druid/math/expr/UnaryOperatorExpr.java +++ b/core/src/main/java/org/apache/druid/math/expr/UnaryOperatorExpr.java @@ -45,13 +45,6 @@ abstract class UnaryExpr implements Expr abstract UnaryExpr copy(Expr expr); - @Override - public void visit(Visitor visitor) - { - expr.visit(visitor); - visitor.visit(this); - } - @Override public Expr visit(Shuttle shuttle) { diff --git a/processing/src/main/java/org/apache/druid/query/expression/TrimExprMacro.java b/processing/src/main/java/org/apache/druid/query/expression/TrimExprMacro.java index f019edc93e4..48a007c7556 100644 --- a/processing/src/main/java/org/apache/druid/query/expression/TrimExprMacro.java +++ b/processing/src/main/java/org/apache/druid/query/expression/TrimExprMacro.java @@ -282,14 +282,6 @@ public abstract class TrimExprMacro implements ExprMacroTable.ExprMacro return StringUtils.format("%s(%s, %s)", mode.getFnName(), stringExpr.stringify(), charsExpr.stringify()); } - @Override - public void visit(final Visitor visitor) - { - stringExpr.visit(visitor); - charsExpr.visit(visitor); - visitor.visit(this); - } - @Override public Expr visit(Shuttle shuttle) {