drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meh...@apache.org
Subject [1/2] drill git commit: DRILL-1988: Create child vectors while initializing complex vectors using Materialized Field
Date Thu, 05 Feb 2015 20:19:20 GMT
Repository: drill
Updated Branches:
  refs/heads/master a0d10063c -> 90a2835f6


DRILL-1988: Create child vectors while initializing complex vectors using Materialized Field


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

Branch: refs/heads/master
Commit: 90a2835f693c1eecf2a11e93a3d6324ba98cf1a6
Parents: 9d088f5
Author: Mehant Baid <mehantr@gmail.com>
Authored: Mon Feb 2 18:33:59 2015 -0800
Committer: Mehant Baid <mehantr@gmail.com>
Committed: Thu Feb 5 10:34:37 2015 -0800

----------------------------------------------------------------------
 .../org/apache/drill/exec/ExecConstants.java    |  3 +-
 .../exec/vector/complex/AbstractMapVector.java  | 18 +++++++++--
 .../exec/vector/complex/RepeatedListVector.java | 13 +++++++-
 .../drill/exec/physical/impl/sort/TestSort.java | 32 +++++++++++++++++++-
 4 files changed, 61 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/90a2835f/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
index 190c13f..f48b06d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
@@ -102,7 +102,8 @@ public interface ExecConstants {
   public static OptionValidator MONGO_READER_ALL_TEXT_MODE_VALIDATOR = new BooleanValidator(MONGO_ALL_TEXT_MODE,
false);
 
   public static final String SLICE_TARGET = "planner.slice_target";
-  public static final OptionValidator SLICE_TARGET_OPTION = new PositiveLongValidator(SLICE_TARGET,
Long.MAX_VALUE, 100000);
+  public static final long SLICE_TARGET_DEFAULT = 100000l;
+  public static final OptionValidator SLICE_TARGET_OPTION = new PositiveLongValidator(SLICE_TARGET,
Long.MAX_VALUE, SLICE_TARGET_DEFAULT);
 
   public static final String CAST_TO_NULLABLE_NUMERIC = "drill.exec.functions.cast_empty_string_to_null";
   public static final OptionValidator CAST_TO_NULLABLE_NUMERIC_OPTION = new BooleanValidator(CAST_TO_NULLABLE_NUMERIC,
false);

http://git-wip-us.apache.org/repos/asf/drill/blob/90a2835f/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractMapVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractMapVector.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractMapVector.java
index dd1fff3..b0783af 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractMapVector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractMapVector.java
@@ -42,6 +42,12 @@ public abstract class AbstractMapVector extends AbstractContainerVector
{
 
   protected AbstractMapVector(MaterializedField field, BufferAllocator allocator, CallBack
callBack) {
     super(field, allocator, callBack);
+    // create the hierarchy of the child vectors based on the materialized field
+    for (MaterializedField child : field.getChildren()) {
+      String fieldName = child.getLastName();
+      ValueVector  v = TypeHelper.getNewVector(child, allocator, callBack);
+      putVector(fieldName, v);
+    }
   }
 
   @Override
@@ -139,6 +145,16 @@ public abstract class AbstractMapVector extends AbstractContainerVector
{
    * Note that this method does not enforce any vector type check nor throws a schema change
exception.
    */
   protected void putChild(String name, ValueVector vector) {
+    putVector(name, vector);
+    field.addChild(vector.getField());
+  }
+
+  /**
+   * Inserts the input vector into the map if it does not exist, replaces if it exists already
+   * @param name  field name
+   * @param vector  vector to be inserted
+   */
+  protected void putVector(String name, ValueVector vector) {
     ValueVector old = vectors.put(
         Preconditions.checkNotNull(name, "field name cannot be null").toLowerCase(),
         Preconditions.checkNotNull(vector, "vector cannot be null")
@@ -147,8 +163,6 @@ public abstract class AbstractMapVector extends AbstractContainerVector
{
       logger.debug("Field [%s] mutated from [%s] to [%s]", name, old.getClass().getSimpleName(),
           vector.getClass().getSimpleName());
     }
-
-    field.addChild(vector.getField());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/drill/blob/90a2835f/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
index 73daf93..3078f4e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
@@ -66,6 +66,16 @@ public class RepeatedListVector extends AbstractContainerVector implements
Repea
 
   public RepeatedListVector(MaterializedField field, BufferAllocator allocator, CallBack
callBack){
     super(field, allocator, callBack);
+    int childrenSize = field.getChildren().size();
+
+    // repeated list vector should not have more than one child
+    assert childrenSize <= 1;
+
+    if (childrenSize > 0) {
+      MaterializedField child = field.getChildren().iterator().next();
+      vector = TypeHelper.getNewVector(child, allocator, callBack);
+    }
+
     this.offsets = new UInt4Vector(null, allocator);
   }
 
@@ -235,7 +245,8 @@ public class RepeatedListVector extends AbstractContainerVector implements
Repea
 
     @Override
     public int getGroupCount() {
-      return offsets.getAccessor().getValueCount() - 1;
+      final int valueCount = offsets.getAccessor().getValueCount();
+      return valueCount == 0 ? 0 : valueCount - 1;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/90a2835f/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSort.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSort.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSort.java
index 5dc81b5..5066c83 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSort.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSort.java
@@ -18,6 +18,9 @@
 package org.apache.drill.exec.physical.impl.sort;
 
 import org.apache.drill.BaseTestQuery;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.util.JsonStringArrayList;
+import org.apache.drill.exec.util.JsonStringHashMap;
 import org.junit.Test;
 
 /**
@@ -26,8 +29,35 @@ import org.junit.Test;
  */
 public class TestSort extends BaseTestQuery {
 
+  private static final JsonStringHashMap x = new JsonStringHashMap();
+  private static final JsonStringArrayList<JsonStringHashMap> repeated_map = new JsonStringArrayList<>();
+
+  static {
+    x.put("c", 1l);
+    repeated_map.add(0, x);
+  }
+
   @Test
   public void testSortWithComplexInput() throws Exception {
-    test("select t.a from cp.`jsoninput/repeatedmap_sort_bug.json` t order by t.b");
+    testBuilder()
+        .sqlQuery("select (t.a) as col from cp.`jsoninput/repeatedmap_sort_bug.json` t order
by t.b")
+        .ordered()
+        .baselineColumns("col")
+        .baselineValues(repeated_map)
+        .go();
+  }
+
+  @Test
+  public void testSortWithRepeatedMapWithExchanges() throws Exception {
+    testBuilder()
+        .sqlQuery("select (t.a) as col from cp.`jsoninput/repeatedmap_sort_bug.json` t order
by t.b")
+        .optionSettingQueriesForTestQuery("alter session set `planner.slice_target` = 1")
+        .ordered()
+        .baselineColumns("col")
+        .baselineValues(repeated_map)
+        .go();
+
+    // reset the planner.slice_target
+    test("alter session set `planner.slice_target` = " + ExecConstants.SLICE_TARGET_DEFAULT);
   }
 }
\ No newline at end of file


Mime
View raw message