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-875: Avoid setting an extra empty in fillEmpties()
Date Sat, 22 Apr 2017 19:07:05 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 39a37f76f -> a0a925b42


ARROW-875: Avoid setting an extra empty in fillEmpties()

Author: Steven Phillips <steven@dremio.com>

Closes #579 from StevenMPhillips/fillEmpties and squashes the following commits:

e454876 [Steven Phillips] ARROW-875: Avoid setting an extra empty in fillEmpties()


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

Branch: refs/heads/master
Commit: a0a925b42541d1ed2711c547c9eccaaa91820711
Parents: 39a37f7
Author: Steven Phillips <steven@dremio.com>
Authored: Sat Apr 22 15:07:00 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Sat Apr 22 15:07:00 2017 -0400

----------------------------------------------------------------------
 .../main/codegen/templates/NullableValueVectors.java    |  4 ++--
 .../java/org/apache/arrow/vector/TestValueVector.java   | 12 ++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/a0a925b4/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 acee6cb..178d5bd 100644
--- a/java/vector/src/main/codegen/templates/NullableValueVectors.java
+++ b/java/vector/src/main/codegen/templates/NullableValueVectors.java
@@ -526,8 +526,8 @@ public final class ${className} extends BaseDataValueVector implements
<#if type
 
     private void fillEmpties(int index){
       final ${valuesName}.Mutator valuesMutator = values.getMutator();
-      for (int i = lastSet; i < index; i++) {
-        valuesMutator.setSafe(i + 1, emptyByteArray);
+      for (int i = lastSet + 1; i < index; i++) {
+        valuesMutator.setSafe(i, emptyByteArray);
       }
       while(index > bits.getValueCapacity()) {
         bits.reAlloc();

http://git-wip-us.apache.org/repos/asf/arrow/blob/a0a925b4/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 78ca14d..e6e49ab 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
@@ -466,4 +466,16 @@ public class TestValueVector {
     }
   }
 
+  @Test
+  public void testFillEmptiesNotOverfill() {
+    try (final NullableVarCharVector vector = newVector(NullableVarCharVector.class, EMPTY_SCHEMA_PATH,
MinorType.VARCHAR, allocator)) {
+      vector.allocateNew();
+
+      vector.getMutator().setSafe(4094, "hello".getBytes(), 0, 5);
+      vector.getMutator().setValueCount(4095);
+      assertEquals(4096 * 4, vector.getFieldBuffers().get(1).capacity());
+    }
+  }
+
+
 }


Mime
View raw message