Repository: arrow Updated Branches: refs/heads/master 768c7d0be -> bd195e304
ARROW-308: UnionListWriter.setPosition() should not call startList() Project: http://git-wip-us.apache.org/repos/asf/arrow/repo Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/bd195e30 Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/bd195e30 Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/bd195e30 Branch: refs/heads/master Commit: bd195e304d82dcf6e2cea266b4d0871bd2b88564 Parents: 768c7d0 Author: adeneche <[email protected]> Authored: Wed Sep 28 07:26:05 2016 -0700 Committer: adeneche <[email protected]> Committed: Wed Sep 28 13:03:44 2016 -0700 ---------------------------------------------------------------------- .../main/codegen/templates/UnionListWriter.java | 1 - .../complex/writer/TestComplexWriter.java | 32 +++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/arrow/blob/bd195e30/java/vector/src/main/codegen/templates/UnionListWriter.java ---------------------------------------------------------------------- diff --git a/java/vector/src/main/codegen/templates/UnionListWriter.java b/java/vector/src/main/codegen/templates/UnionListWriter.java index d502803..04531a7 100644 --- a/java/vector/src/main/codegen/templates/UnionListWriter.java +++ b/java/vector/src/main/codegen/templates/UnionListWriter.java @@ -84,7 +84,6 @@ public class UnionListWriter extends AbstractFieldWriter { @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 /> http://git-wip-us.apache.org/repos/asf/arrow/blob/bd195e30/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java ---------------------------------------------------------------------- diff --git a/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java b/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java index c1da104..398aea9 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java @@ -52,7 +52,7 @@ import io.netty.buffer.ArrowBuf; 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; @@ -116,6 +116,36 @@ public class TestComplexWriter { } @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); listVector.allocateNew();
