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-1283: [JAVA] Allow VectorSchemaRoot to close more than once
Date Mon, 07 Aug 2017 19:04:34 GMT
Repository: arrow
Updated Branches:
  refs/heads/master c0acb8654 -> f9d983391


ARROW-1283: [JAVA] Allow VectorSchemaRoot to close more than once

This change allows the VectorSchemaRoot/FieldVectors to close more than once, even if the
allocator has already been closed.  Before, an empty ArrowBuf was created during closing which
required the allocator to not be closed, however this empty buffer is not needed once the
FieldVector has been closed.

Author: Bryan Cutler <cutlerb@gmail.com>

Closes #898 from BryanCutler/java-vectorSchemaRoot-close-twice-ARROW-1283 and squashes the
following commits:

2921d848 [Bryan Cutler] removed resolved comment
3b3718b8 [Bryan Cutler] Merge remote-tracking branch 'upstream/master' into java-vectorSchemaRoot-close-twice-ARROW-1283
e992fc79 [Bryan Cutler] BaseDataValueVector.close will now just clear, which releases previous
and assigns an empty buffer
8ecfce2a [Bryan Cutler] Merge remote-tracking branch 'upstream/master' into java-vectorSchemaRoot-close-twice-ARROW-1283
ca38d3d8 [Bryan Cutler] use clear to release data, ensure that an empty buffer is never allocated
again after closing
10ff7c36 [Bryan Cutler] Added regression test


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

Branch: refs/heads/master
Commit: f9d983391695a22ca400da9135ddfbeb041859ca
Parents: c0acb86
Author: Bryan Cutler <cutlerb@gmail.com>
Authored: Mon Aug 7 15:04:29 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Mon Aug 7 15:04:29 2017 -0400

----------------------------------------------------------------------
 .../java/org/apache/arrow/memory/BaseAllocator.java |  3 ---
 .../apache/arrow/vector/BaseDataValueVector.java    | 16 +---------------
 .../org/apache/arrow/vector/TestValueVector.java    | 10 ++++++++++
 3 files changed, 11 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/f9d98339/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java
----------------------------------------------------------------------
diff --git a/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java b/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java
index be0ba77..b38cf67 100644
--- a/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java
+++ b/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java
@@ -171,7 +171,6 @@ public abstract class BaseAllocator extends Accountant implements BufferAllocato
 
   @Override
   public ArrowBuf getEmpty() {
-    assertOpen();
     return empty;
   }
 
@@ -236,8 +235,6 @@ public abstract class BaseAllocator extends Accountant implements BufferAllocato
   }
 
   private ArrowBuf createEmpty() {
-    assertOpen();
-
     return new ArrowBuf(new AtomicInteger(), null, AllocationManager.EMPTY, null, null, 0,
0, true);
   }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/f9d98339/java/vector/src/main/java/org/apache/arrow/vector/BaseDataValueVector.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/BaseDataValueVector.java b/java/vector/src/main/java/org/apache/arrow/vector/BaseDataValueVector.java
index 0fea719..88e0249 100644
--- a/java/vector/src/main/java/org/apache/arrow/vector/BaseDataValueVector.java
+++ b/java/vector/src/main/java/org/apache/arrow/vector/BaseDataValueVector.java
@@ -59,8 +59,6 @@ public abstract class BaseDataValueVector extends BaseValueVector implements
Buf
     return result;
   }
 
-  // TODO: Nullable vectors extend BaseDataValueVector but do not use the data field
-  // We should fix the inheritance tree
   protected ArrowBuf data;
 
   public BaseDataValueVector(String name, BufferAllocator allocator) {
@@ -70,24 +68,12 @@ public abstract class BaseDataValueVector extends BaseValueVector implements
Buf
 
   @Override
   public void clear() {
-    if (data != null) {
-      data.release();
-    }
+    data.release();
     data = allocator.getEmpty();
     super.clear();
   }
 
   @Override
-  public void close() {
-    clear();
-    if (data != null) {
-      data.release();
-      data = null;
-    }
-    super.close();
-  }
-
-  @Override
   public TransferPair getTransferPair(String ref, BufferAllocator allocator, CallBack callBack)
{
     return getTransferPair(ref, allocator);
   }

http://git-wip-us.apache.org/repos/asf/arrow/blob/f9d98339/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 0f41c2d..159d534 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
@@ -736,6 +736,16 @@ public class TestValueVector {
     }
   }
 
+  @Test
+  public void testMultipleClose() {
+    BufferAllocator vectorAllocator = allocator.newChildAllocator("vector_allocator", 0,
Long.MAX_VALUE);
+    NullableIntVector vector = newVector(NullableIntVector.class, EMPTY_SCHEMA_PATH, MinorType.INT,
vectorAllocator);
+    vector.close();
+    vectorAllocator.close();
+    vector.close();
+    vectorAllocator.close();
+  }
+
   public static void setBytes(int index, byte[] bytes, NullableVarCharVector vector) {
     final int currentOffset = vector.values.offsetVector.getAccessor().get(index);
 


Mime
View raw message