Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ public String getName() {

@Override
public ArrowBuf getEmpty() {
assertOpen();
return empty;
}

Expand Down Expand Up @@ -236,8 +235,6 @@ public ArrowBuf buffer(final int initialRequestSize) {
}

private ArrowBuf createEmpty() {
assertOpen();
Copy link
Member Author

@BryanCutler BryanCutler Aug 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this did not seem necessary either, because an allocator will always hold an instance of an empty buffer. Does this seem ok?


return new ArrowBuf(new AtomicInteger(), null, AllocationManager.EMPTY, null, null, 0, 0, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public static List<ArrowBuf> unload(List<BufferBacked> vectors) {
return result;
}

// TODO: Nullable vectors extend BaseDataValueVector but do not use the data field
// We should fix the inheritance tree
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siddharthteotia I believe you resolved this comment in #892. Does this PR look ok to you?

protected ArrowBuf data;

public BaseDataValueVector(String name, BufferAllocator allocator) {
Expand All @@ -70,23 +68,11 @@ public BaseDataValueVector(String name, BufferAllocator allocator) {

@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,16 @@ public void testFillEmptiesUsage() {
}
}

@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);

Expand Down