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-1296: [Java] Fix allocationSizeInBytes in FixedValueVectors.res…
Date Fri, 04 Aug 2017 21:34:51 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 717bed0d0 -> 3bc7d4604


ARROW-1296: [Java] Fix allocationSizeInBytes in FixedValueVectors.res…

Fix allocationSizeInBytes in FixedValueVectors.reset

Author: Li Jin <ice.xelloss@gmail.com>

Closes #915 from icexelloss/vector-reset-ARROW-1296 and squashes the following commits:

f9c8607f [Li Jin] Add VectorReset test; Add package private method getAllocationSize to FixedValueVectors
d0117a83 [Li Jin] ARROW-1296: [Java] Fix allocationSizeInBytes in FixedValueVectors.reset()


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

Branch: refs/heads/master
Commit: 3bc7d4604c68930cbaac0262e0c9281adf31f8c0
Parents: 717bed0
Author: Li Jin <ice.xelloss@gmail.com>
Authored: Fri Aug 4 17:34:46 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Fri Aug 4 17:34:46 2017 -0400

----------------------------------------------------------------------
 .../codegen/templates/FixedValueVectors.java    |  6 ++-
 .../apache/arrow/vector/TestVectorReset.java    | 55 ++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/3bc7d460/java/vector/src/main/codegen/templates/FixedValueVectors.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/codegen/templates/FixedValueVectors.java b/java/vector/src/main/codegen/templates/FixedValueVectors.java
index 5d92cd2..61164ab 100644
--- a/java/vector/src/main/codegen/templates/FixedValueVectors.java
+++ b/java/vector/src/main/codegen/templates/FixedValueVectors.java
@@ -111,6 +111,10 @@ public final class ${className} extends BaseDataValueVector implements
FixedWidt
     return mutator;
   }
 
+  int getAllocationSize() {
+    return allocationSizeInBytes;
+  }
+
   @Override
   public void setInitialCapacity(final int valueCount) {
     final long size = 1L * valueCount * ${type.width};
@@ -162,7 +166,7 @@ public final class ${className} extends BaseDataValueVector implements
FixedWidt
 
   @Override
   public void reset() {
-    allocationSizeInBytes = INITIAL_VALUE_ALLOCATION;
+    allocationSizeInBytes = INITIAL_VALUE_ALLOCATION * ${type.width};
     allocationMonitor = 0;
     zeroVector();
     super.reset();

http://git-wip-us.apache.org/repos/asf/arrow/blob/3bc7d460/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java
----------------------------------------------------------------------
diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java
new file mode 100644
index 0000000..d53f694
--- /dev/null
+++ b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.memory.RootAllocator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestVectorReset {
+
+  private BufferAllocator allocator;
+
+  @Before
+  public void init() {
+    allocator = new RootAllocator(Long.MAX_VALUE);
+  }
+
+  @After
+  public void terminate() throws Exception {
+    allocator.close();
+  }
+
+  @Test
+  public void testFixedTypeReset() {
+    try (final UInt4Vector vector = new UInt4Vector("", allocator)) {
+      final UInt4Vector.Mutator m = vector.getMutator();
+      vector.allocateNew();
+      final int sizeBefore = vector.getAllocationSize();
+      vector.reAlloc();
+      vector.reset();
+      final int sizeAfter = vector.getAllocationSize();
+      assertEquals(sizeBefore, sizeAfter);
+    }
+  }
+}


Mime
View raw message