arrow-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Deneche A. Hakim (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (ARROW-308) UnionListWriter.setPosition() should not call startList()
Date Thu, 29 Sep 2016 21:37:20 GMT

    [ https://issues.apache.org/jira/browse/ARROW-308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15533196#comment-15533196
] 

Deneche A. Hakim edited comment on ARROW-308 at 9/29/16 9:36 PM:
-----------------------------------------------------------------

--The fix I merged is incomplete, many writers are working under the assumption that UnionListWriter.setPosition()
also calls startList(). Working on proper fix, but if it takes too long I will probably just
revert the merged PR until I get it done--


was (Author: adeneche):
The fix I merged is incomplete, many writers are working under the assumption that UnionListWriter.setPosition()
also calls startList(). Working on proper fix, but if it takes too long I will probably just
revert the merged PR until I get it done

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

Mime
View raw message