You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Rok Mihevc (Jira)" <ji...@apache.org> on 2023/01/11 07:09:02 UTC
[jira] [Commented] (ARROW-337) UnionListWriter.list() is doing more than it should, this can cause data corruption
[ https://issues.apache.org/jira/browse/ARROW-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17657371#comment-17657371 ]
Rok Mihevc commented on ARROW-337:
----------------------------------
This issue has been migrated to [issue #15815|https://github.com/apache/arrow/issues/15815] on GitHub. Please see the [migration documentation|https://github.com/apache/arrow/issues/14542] for further details.
> UnionListWriter.list() is doing more than it should, this can cause data corruption
> -----------------------------------------------------------------------------------
>
> Key: ARROW-337
> URL: https://issues.apache.org/jira/browse/ARROW-337
> Project: Apache Arrow
> Issue Type: Bug
> Components: Java
> Reporter: Abdel Hakim Deneche
> Assignee: Abdel Hakim Deneche
> Priority: Major
> Fix For: 0.2.0
>
>
> If you run the following code:
> {code}
> MapVector parent = new MapVector("parent", allocator, null);
> ComplexWriter writer = new ComplexWriterImpl("root", parent);
> MapWriter rootWriter = writer.rootAsMap();
> ListWriter listWriter = rootWriter.list("list");
> ListWriter list = listWriter.list();
> rootWriter.start();
> {
> listWriter.startList();
> {
> list.startList();
> list.bigInt().writeBigInt(0);
> list.endList();
> }
> {
> list.startList();
> list.bigInt().writeBigInt(1);
> list.endList();
> }
> listWriter.endList();
> }
> rootWriter.end();
> writer.setValueCount(1);
> MapReader rootReader = new SingleMapReaderImpl(parent).reader("root");
> System.out.println(rootReader.reader("list").readObject());
> {code}
> You should expect it to print {noformat}[[0],[1]]{noformat}
> but it actually prints {noformat}[[0,1]]{noformat}
> If you change the code so that UnionListWriter.list() is called along with startList() then the code works fine:
> {code}
> MapVector parent = new MapVector("parent", allocator, null);
> ComplexWriter writer = new ComplexWriterImpl("root", parent);
> MapWriter rootWriter = writer.rootAsMap();
> rootWriter.start();
> {
> ListWriter listWriter = rootWriter.list("mylist");
> listWriter.startList();
> {
> ListWriter list = listWriter.list();
> list.startList();
> list.bigInt().writeBigInt(0);
> list.endList();
> }
> {
> ListWriter list = listWriter.list();
> list.startList();
> list.bigInt().writeBigInt(1);
> list.endList();
> }
> listWriter.endList();
> }
> rootWriter.end();
> writer.setValueCount(1);
> MapReader rootReader = new SingleMapReaderImpl(parent).reader("root");
> System.out.println(rootReader.reader("mylist").readObject());
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)