You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Deneche A. Hakim (JIRA)" <ji...@apache.org> on 2016/09/28 02:03:20 UTC
[jira] [Created] (ARROW-308) UnionListWriter.setPosition() should
not call startList()
Deneche A. Hakim created ARROW-308:
--------------------------------------
Summary: UnionListWriter.setPosition() should not call startList()
Key: ARROW-308
URL: https://issues.apache.org/jira/browse/ARROW-308
Project: Apache Arrow
Issue Type: Bug
Components: Java - Vectors
Reporter: Deneche A. Hakim
Assignee: Deneche A. Hakim
UnionListWriter.setPosition() is implemented as follows:
{code}
@Override
public void setPosition(int index) {
super.setPosition(index);
startList();
}
{code}
It works fine, but if you run the following code:
{code}
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();
rootWriter.setPosition(2);
rootWriter.bigInt("int").writeBigInt(2);
rootWriter.start();
rootWriter.list("list").startList();
rootWriter.list("list").bigInt().writeBigInt(2);
rootWriter.list("list").endList();
rootWriter.end();
writer.setValueCount(3);
for (int i = 0; i < 3; i++) {
parent.getReader().setPosition(i);
System.out.printf("%d: %s%n", i, parent.getReader().readObject());
}
{code}
You get:
{noformat}
0: {"root":{"int":0,"list":[0]}}
1: {"root":{"int":1,"list":[]}}
2: {"root":{"int":2,"list":[2]}}
{noformat}
Even though we didn't write anything in the 2nd row "list", it shows up as empty instead of null. I tracked the problem to UnionListWriter.setPosition() calling startList() which marks the row as not null even if we don't write anything to it.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)