Skip to content
Open
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 @@ -601,8 +601,8 @@ public ValueVector visit(UnionVector deltaVector, Void value) {
UnionVector targetUnionVector = (UnionVector) targetVector;
int newValueCount = targetVector.getValueCount() + deltaVector.getValueCount();

// make sure there is enough capacity
while (targetUnionVector.getValueCapacity() < newValueCount) {
// Child vectors are created and expanded below; an empty union has zero value capacity.
while (targetUnionVector.getTypeBuffer().capacity() / UnionVector.TYPE_WIDTH < newValueCount) {
targetUnionVector.reAlloc();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,26 @@ public void testAppendEmptyStructVector() {
}
}

@Test
public void testAppendToEmptyUnionVector() {
try (BufferAllocator limitedAllocator = allocator.newChildAllocator("empty union", 0, 1048576);
UnionVector target = UnionVector.empty("target", limitedAllocator);
UnionVector delta = UnionVector.empty("delta", limitedAllocator)) {
delta.setType(0, Types.MinorType.FLOAT4);
delta.setType(1, Types.MinorType.FLOAT4);
Float4Vector values = delta.getFloat4Vector();
values.allocateNew();
ValueVectorDataPopulator.setVector(values, 1f, 2f);
delta.setValueCount(2);

delta.accept(new VectorAppender(target), null);

assertEquals(2, target.getValueCount());
assertEquals(1f, target.getObject(0));
assertEquals(2f, target.getObject(1));
}
}

@Test
public void testAppendUnionVector() {
final int length1 = 10;
Expand Down
Loading