You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2014/05/10 02:14:23 UTC

[6/6] git commit: DRILL-633: Fix toString() for DrillFuncHolder and few other types.

DRILL-633: Fix toString() for DrillFuncHolder and few other types.

 - Added o.a.d.common.types.Types.toString(MajorType) method to convert a MajorType to string without the line breaks.
 - Log a trace message with all registered Drill functions.


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/f2ebfc6f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/f2ebfc6f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/f2ebfc6f

Branch: refs/heads/master
Commit: f2ebfc6fa94b85ea1caaa35b2c3637b2d36c3265
Parents: acc45fe
Author: Aditya Kishore <ad...@maprtech.com>
Authored: Sat May 3 16:38:11 2014 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Fri May 9 16:52:17 2014 -0700

----------------------------------------------------------------------
 .../common/logical/data/NamedExpression.java     |  7 ++++++-
 .../org/apache/drill/common/types/Types.java     |  6 ++++++
 .../drill/exec/expr/fn/DrillFuncHolder.java      | 19 +++++++++++--------
 .../fn/DrillFunctionImplementationRegistry.java  |  8 +++++++-
 .../exec/expr/fn/DrillSimpleFuncHolder.java      | 11 +----------
 5 files changed, 31 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f2ebfc6f/common/src/main/java/org/apache/drill/common/logical/data/NamedExpression.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/NamedExpression.java b/common/src/main/java/org/apache/drill/common/logical/data/NamedExpression.java
index 6d36618..4c006c6 100644
--- a/common/src/main/java/org/apache/drill/common/logical/data/NamedExpression.java
+++ b/common/src/main/java/org/apache/drill/common/logical/data/NamedExpression.java
@@ -43,5 +43,10 @@ public class NamedExpression {
   public FieldReference getRef() {
     return ref;
   }
-  
+
+  @Override
+  public String toString() {
+    return "NamedExpression [expr=" + expr + ", ref=" + ref + "]";
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f2ebfc6f/common/src/main/java/org/apache/drill/common/types/Types.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/types/Types.java b/common/src/main/java/org/apache/drill/common/types/Types.java
index c51177d..325e20a 100644
--- a/common/src/main/java/org/apache/drill/common/types/Types.java
+++ b/common/src/main/java/org/apache/drill/common/types/Types.java
@@ -21,6 +21,8 @@ import org.apache.drill.common.types.TypeProtos.DataMode;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 
+import com.google.protobuf.TextFormat;
+
 import static org.apache.drill.common.types.TypeProtos.DataMode.REPEATED;
 
 public class Types {
@@ -333,4 +335,8 @@ public class Types {
     }
   }
 
+  public static String toString(MajorType type) {
+    return type != null ? "MajorType[" + TextFormat.shortDebugString(type) + "]" : "null";
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f2ebfc6f/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java
index e93a768..ea4e9f6 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java
@@ -21,29 +21,22 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.drill.common.expression.FunctionCall;
 import org.apache.drill.common.expression.LogicalExpression;
 import org.apache.drill.common.types.TypeProtos;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.Types;
-import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.expr.ClassGenerator;
 import org.apache.drill.exec.expr.ClassGenerator.BlockType;
 import org.apache.drill.exec.expr.ClassGenerator.HoldingContainer;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.FunctionScope;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
-import org.apache.drill.exec.record.NullExpression;
-import org.apache.drill.exec.resolver.ResolverTypePrecedence;
-import org.apache.drill.exec.resolver.TypeCastRules;
 
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.sun.codemodel.JBlock;
-import com.sun.codemodel.JExpr;
-import com.sun.codemodel.JMod;
 import com.sun.codemodel.JVar;
 
 public abstract class DrillFuncHolder {
@@ -213,6 +206,16 @@ public abstract class DrillFuncHolder {
     return registeredNames;
   }
 
+  @Override
+  public String toString() {
+    final int maxLen = 10;
+    return this.getClass().getSimpleName()
+        + " [functionNames=" + Arrays.toString(registeredNames)
+        + ", returnType=" + Types.toString(returnValue.type)
+        + ", nullHandling=" + nullHandling
+        + ", parameters=" + (parameters != null ? Arrays.asList(parameters).subList(0, Math.min(parameters.length, maxLen)) : null) + "]";
+  }
+
   public static class ValueReference {
     MajorType type;
     String name;
@@ -233,7 +236,7 @@ public abstract class DrillFuncHolder {
 
     @Override
     public String toString() {
-      return "ValueReference [type=" + type + ", name=" + name + "]";
+      return "ValueReference [type=" + Types.toString(type) + ", name=" + name + "]";
     }
 
   }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f2ebfc6f/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFunctionImplementationRegistry.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFunctionImplementationRegistry.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFunctionImplementationRegistry.java
index 64ceef5..fb2f443 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFunctionImplementationRegistry.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFunctionImplementationRegistry.java
@@ -20,7 +20,6 @@ package org.apache.drill.exec.expr.fn;
 import java.util.Set;
 
 import org.apache.drill.common.config.DrillConfig;
-import org.apache.drill.common.expression.FunctionCall;
 import org.apache.drill.common.util.PathScanner;
 import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.expr.DrillFunc;
@@ -45,6 +44,13 @@ public class DrillFunctionImplementationRegistry {
         logger.warn("Unable to initialize function for class {}", clazz.getName());
       }
     }
+    if (logger.isTraceEnabled()) {
+      StringBuilder allFunctions = new StringBuilder();
+      for (DrillFuncHolder method: methods.values()) {
+        allFunctions.append(method.toString()).append("\n");
+      }
+      logger.trace("Registered functions: [\n{}]", allFunctions);
+    }
   }
 
   public ArrayListMultimap<String, DrillFuncHolder> getMethods() {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f2ebfc6f/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillSimpleFuncHolder.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillSimpleFuncHolder.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillSimpleFuncHolder.java
index 33265de..0460ec4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillSimpleFuncHolder.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillSimpleFuncHolder.java
@@ -29,10 +29,8 @@ import org.apache.drill.exec.expr.ClassGenerator.BlockType;
 import org.apache.drill.exec.expr.ClassGenerator.HoldingContainer;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.FunctionScope;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
-import org.apache.drill.exec.expr.fn.DrillFuncHolder.ValueReference;
 
 import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
 import com.sun.codemodel.JBlock;
 import com.sun.codemodel.JConditional;
 import com.sun.codemodel.JExpr;
@@ -80,7 +78,7 @@ class DrillSimpleFuncHolder extends DrillFuncHolder{
     return c;
   }
  
- protected HoldingContainer generateEvalBody(ClassGenerator<?> g, HoldingContainer[] inputVariables, String body, JVar[] workspaceJVars){
+  protected HoldingContainer generateEvalBody(ClassGenerator<?> g, HoldingContainer[] inputVariables, String body, JVar[] workspaceJVars) {
     
     //g.getBlock().directStatement(String.format("//---- start of eval portion of %s function. ----//", functionName));
     
@@ -127,11 +125,4 @@ class DrillSimpleFuncHolder extends DrillFuncHolder{
     return out;
   }
 
-@Override
-public String toString() {
-  final int maxLen = 10;
-  return "DrillSimpleFuncHolder [, functionName=" + Arrays.toString(registeredNames) + ", nullHandling=" + nullHandling + "parameters="
-      + (parameters != null ? Arrays.asList(parameters).subList(0, Math.min(parameters.length, maxLen)) : null) + "]";
-}
-  
 }