arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-1249: [JAVA] expose fillEmpties from Nullable variable length vectors
Date Tue, 25 Jul 2017 01:39:10 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 6042c4895 -> ecdc86ba4


ARROW-1249: [JAVA] expose fillEmpties from Nullable variable length vectors

This will allow us to do some cleanup in Dremio where we have written wrapper routines using
Reflection to access the fillEmpties method of mutator.

Unit tests have been added.

Author: siddharth <siddharth@dremio.com>

Closes #880 from siddharthteotia/ARROW-1249 and squashes the following commits:

e0532c5c [siddharth] Merge branch 'ARROW-1249' of https://github.com/siddharthteotia/arrow
into ARROW-1249
dc052061 [siddharth] ARROW-1249: Expose fillEmpties() from Nullable Variable Length Vectors
f24d8f11 [siddharth] ARROW-1249: expose fillEmpties from Nullable variable length vectors


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

Branch: refs/heads/master
Commit: ecdc86ba45c9dc1739587ec664080e9f2a9b479f
Parents: 6042c48
Author: siddharth <siddharth@dremio.com>
Authored: Mon Jul 24 21:39:02 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Mon Jul 24 21:39:02 2017 -0400

----------------------------------------------------------------------
 .../codegen/templates/NullableValueVectors.java |  2 +-
 .../apache/arrow/vector/TestValueVector.java    | 97 ++++++++++++++++++++
 2 files changed, 98 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/ecdc86ba/java/vector/src/main/codegen/templates/NullableValueVectors.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/codegen/templates/NullableValueVectors.java b/java/vector/src/main/codegen/templates/NullableValueVectors.java
index 1decd0b..5b99367 100644
--- a/java/vector/src/main/codegen/templates/NullableValueVectors.java
+++ b/java/vector/src/main/codegen/templates/NullableValueVectors.java
@@ -540,7 +540,7 @@ public final class ${className} extends BaseDataValueVector implements
<#if type
 
     <#if type.major == "VarLen">
 
-    private void fillEmpties(int index){
+    public void fillEmpties(int index){
       final ${valuesName}.Mutator valuesMutator = values.getMutator();
       for (int i = lastSet + 1; i < index; i++) {
         valuesMutator.setSafe(i, emptyByteArray);

http://git-wip-us.apache.org/repos/asf/arrow/blob/ecdc86ba/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java
----------------------------------------------------------------------
diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java
index f5508aa..0f41c2d 100644
--- a/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java
+++ b/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java
@@ -639,6 +639,103 @@ public class TestValueVector {
     }
   }
 
+  @Test
+  public void testFillEmptiesUsage() {
+    try (final NullableVarCharVector vector = new NullableVarCharVector("myvector", allocator))
{
+
+      final NullableVarCharVector.Mutator mutator = vector.getMutator();
+
+      vector.allocateNew(1024 * 10, 1024);
+
+      setBytes(0, STR1, vector);
+      setBytes(1, STR2, vector);
+      setBytes(2, STR3, vector);
+      setBytes(3, STR4, vector);
+      setBytes(4, STR5, vector);
+      setBytes(5, STR6, vector);
+
+      /* Check current lastSet */
+      assertEquals(Integer.toString(-1), Integer.toString(mutator.getLastSet()));
+
+      /* Check the vector output */
+      final NullableVarCharVector.Accessor accessor = vector.getAccessor();
+      assertArrayEquals(STR1, accessor.get(0));
+      assertArrayEquals(STR2, accessor.get(1));
+      assertArrayEquals(STR3, accessor.get(2));
+      assertArrayEquals(STR4, accessor.get(3));
+      assertArrayEquals(STR5, accessor.get(4));
+      assertArrayEquals(STR6, accessor.get(5));
+
+      mutator.setLastSet(5);
+      /* fill empty byte arrays from index [6, 9] */
+      mutator.fillEmpties(10);
+
+      /* Check current lastSet */
+      assertEquals(Integer.toString(9), Integer.toString(mutator.getLastSet()));
+
+      /* Check the vector output */
+      assertArrayEquals(STR1, accessor.get(0));
+      assertArrayEquals(STR2, accessor.get(1));
+      assertArrayEquals(STR3, accessor.get(2));
+      assertArrayEquals(STR4, accessor.get(3));
+      assertArrayEquals(STR5, accessor.get(4));
+      assertArrayEquals(STR6, accessor.get(5));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(6)));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(7)));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(8)));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(9)));
+
+      setBytes(10, STR1, vector);
+      setBytes(11, STR2, vector);
+
+      mutator.setLastSet(11);
+      /* fill empty byte arrays from index [12, 14] */
+      mutator.setValueCount(15);
+
+      /* Check current lastSet */
+      assertEquals(Integer.toString(14), Integer.toString(mutator.getLastSet()));
+
+      /* Check the vector output */
+      assertArrayEquals(STR1, accessor.get(0));
+      assertArrayEquals(STR2, accessor.get(1));
+      assertArrayEquals(STR3, accessor.get(2));
+      assertArrayEquals(STR4, accessor.get(3));
+      assertArrayEquals(STR5, accessor.get(4));
+      assertArrayEquals(STR6, accessor.get(5));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(6)));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(7)));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(8)));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(9)));
+      assertArrayEquals(STR1, accessor.get(10));
+      assertArrayEquals(STR2, accessor.get(11));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(12)));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(13)));
+      assertEquals(Integer.toString(0), Integer.toString(accessor.getValueLength(14)));
+
+      /* Check offsets */
+      final UInt4Vector.Accessor offsetAccessor = vector.values.offsetVector.getAccessor();
+      assertEquals(Integer.toString(0), Integer.toString(offsetAccessor.get(0)));
+      assertEquals(Integer.toString(6), Integer.toString(offsetAccessor.get(1)));
+      assertEquals(Integer.toString(16), Integer.toString(offsetAccessor.get(2)));
+      assertEquals(Integer.toString(21), Integer.toString(offsetAccessor.get(3)));
+      assertEquals(Integer.toString(30), Integer.toString(offsetAccessor.get(4)));
+      assertEquals(Integer.toString(34), Integer.toString(offsetAccessor.get(5)));
+
+      assertEquals(Integer.toString(40), Integer.toString(offsetAccessor.get(6)));
+      assertEquals(Integer.toString(40), Integer.toString(offsetAccessor.get(7)));
+      assertEquals(Integer.toString(40), Integer.toString(offsetAccessor.get(8)));
+      assertEquals(Integer.toString(40), Integer.toString(offsetAccessor.get(9)));
+      assertEquals(Integer.toString(40), Integer.toString(offsetAccessor.get(10)));
+
+      assertEquals(Integer.toString(46), Integer.toString(offsetAccessor.get(11)));
+      assertEquals(Integer.toString(56), Integer.toString(offsetAccessor.get(12)));
+
+      assertEquals(Integer.toString(56), Integer.toString(offsetAccessor.get(13)));
+      assertEquals(Integer.toString(56), Integer.toString(offsetAccessor.get(14)));
+      assertEquals(Integer.toString(56), Integer.toString(offsetAccessor.get(15)));
+    }
+  }
+
   public static void setBytes(int index, byte[] bytes, NullableVarCharVector vector) {
     final int currentOffset = vector.values.offsetVector.getAccessor().get(index);
 


Mime
View raw message