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

[2/4] git commit: DRILL-810 : add isSafe() to Nullable value vector. Check nullable value vector has capacity for new value in run-time code.

DRILL-810 : add isSafe() to Nullable value vector. Check nullable value vector has capacity for new value in run-time code.


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

Branch: refs/heads/master
Commit: 27e22131e2e89aca34d3093ee227249e1d8e8a73
Parents: f7688be
Author: Jinfeng Ni <jn...@maprtech.com>
Authored: Wed May 21 22:11:42 2014 -0700
Committer: Jinfeng Ni <jn...@maprtech.com>
Committed: Thu May 22 14:45:18 2014 -0700

----------------------------------------------------------------------
 .../src/main/codegen/templates/NullableValueVectors.java         | 4 ++++
 .../main/java/org/apache/drill/exec/expr/EvaluationVisitor.java  | 3 +++
 2 files changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/27e22131/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java b/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
index 29cd7cc..fd15e79 100644
--- a/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
+++ b/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
@@ -462,6 +462,10 @@ public final class ${className} extends BaseValueVector implements <#if type.maj
       values.getMutator().set(index, holder);
       <#if type.major == "VarLen">lastSet = index;</#if>
     }
+    
+    public boolean isSafe(int outIndex) {
+      return outIndex < Nullable${minor.class}Vector.this.getValueCapacity();
+    }
 
     //public boolean setSafe(int index, <#if type.major == "VarLen" || minor.class == "TimeStampTZ" || minor.class == "Interval" || minor.class == "IntervalDay">Nullable${minor.class}Holder <#elseif (type.width < 4)>int<#else>${minor.javaType!type.javaType}</#if> value){
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/27e22131/exec/java-exec/src/main/java/org/apache/drill/exec/expr/EvaluationVisitor.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/EvaluationVisitor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/EvaluationVisitor.java
index b03882e..6a34b9c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/EvaluationVisitor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/EvaluationVisitor.java
@@ -294,6 +294,8 @@ public class EvaluationVisitor {
       }else{
         String setMethod = e.isSafe() ? "setSafe" : "set";
 
+        String isSafeMethod = "isSafe";
+
         JInvocation setMeth;
         if (Types.usesHolderForGet(inputContainer.getMajorType())) {
           setMeth = vv.invoke("getMutator").invoke(setMethod).arg(outIndex).arg(inputContainer.getHolder());
@@ -308,6 +310,7 @@ public class EvaluationVisitor {
 //            block._if(vv.invoke("getMutator").invoke(setMethod).arg(outIndex).not())._then().assign(outputContainer.getValue(), JExpr.lit(0));
             JConditional jc = block._if(inputContainer.getIsSet().eq(JExpr.lit(0)).not());
             block = jc._then();
+            jc._else()._if(vv.invoke("getMutator").invoke(isSafeMethod).arg(outIndex).not())._then().assign(outputContainer.getValue(), JExpr.lit(0));
           }
           block._if(setMeth.not())._then().assign(outputContainer.getValue(), JExpr.lit(0));
           return outputContainer;