Skip to content

Commit

Permalink
ARROW-308: UnionListWriter.setPosition() should not call startList()
Browse files Browse the repository at this point in the history
  • Loading branch information
adeneche committed Sep 28, 2016
1 parent 768c7d0 commit bd195e3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public void close() throws Exception {
@Override
public void setPosition(int index) {
super.setPosition(index);
startList();
}

<#list vv.types as type><#list type.minor as minor><#assign name = minor.class?cap_first />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

public class TestComplexWriter {

static final BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE);
private static final BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE);

private static final int COUNT = 100;

Expand Down Expand Up @@ -115,6 +115,36 @@ public void nullableMap() {
parent.close();
}

@Test
public void listOfLists() {
MapVector parent = new MapVector("parent", allocator, null);
ComplexWriter writer = new ComplexWriterImpl("root", parent);
MapWriter rootWriter = writer.rootAsMap();

rootWriter.start();
rootWriter.bigInt("int").writeBigInt(0);
rootWriter.list("list").startList();
rootWriter.list("list").bigInt().writeBigInt(0);
rootWriter.list("list").endList();
rootWriter.end();

rootWriter.setPosition(1);
rootWriter.start();
rootWriter.bigInt("int").writeBigInt(1);
rootWriter.end();

writer.setValueCount(2);

MapReader rootReader = new SingleMapReaderImpl(parent).reader("root");

rootReader.setPosition(0);
assertTrue("row 0 list is not set", rootReader.reader("list").isSet());
assertEquals(Long.valueOf(0), rootReader.reader("list").reader().readLong());

rootReader.setPosition(1);
assertFalse("row 1 list is set", rootReader.reader("list").isSet());
}

@Test
public void listScalarType() {
ListVector listVector = new ListVector("list", allocator, null);
Expand Down

0 comments on commit bd195e3

Please sign in to comment.