Skip to content

ARROW-2632: [Java] ArrowStreamWriter accumulates ArrowBlock but does not use them - #2079

Closed
pudidic wants to merge 2 commits into
apache:masterfrom
pudidic:ARROW-2632
Closed

pudidic wants to merge 2 commits into
apache:masterfrom
pudidic:ARROW-2632

Conversation

@pudidic

@pudidic pudidic commented May 24, 2018

Copy link
Copy Markdown
Contributor

ArrowStreamWriter inherits from ArrowWriter the behavior of accumulating an ArrowBlock for each ArrowRecordBatch that is written. But this data is never used in the context of ArrowStreamWriter. writeRecordBatch can be overridden in ArrowStreamWriter to avoid adding the memory overhead.

@siddharthteotia

Copy link
Copy Markdown
Contributor

@pudidic , do we need a unit test?

}

@Override
protected void writeRecordBatch(ArrowRecordBatch batch) throws IOException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how this method helps in saving memory overhead as mentioned in PR description. Can you please elaborate on the usage of this method?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @siddharthteotia

If you trace the data flow for ArrowStreamWriter, the line inherited by ArrowWriter.writeRecordBatch:

recordBlocks.add(block);

accumulates ArrowBlock in a list that is never used by ArrowStreamWriter.

The recordBlocks list is used by a different sub-class of ArrowWriter at ArrowFileWriter.endInternal.

This was confirmed by @elahrvivaz on the dev list.

@EricWohlstadter

Copy link
Copy Markdown

@pudidic
In the overridden ArrowStreamWriter.writeRecordBatch, you could still preserve the behavior of the LOG message in ArrowWriter.writeRecordBatch.

@EricWohlstadter

Copy link
Copy Markdown

+1 to @siddharthteotia suggestion for a unit test

@pudidic

pudidic commented May 25, 2018

Copy link
Copy Markdown
Contributor Author

@siddharthteotia, @EricWohlstadter no problem. I'm applying your feedbacks and merging with latest master branch changes. Thanks!

@BryanCutler BryanCutler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @pudidic for the fix and @EricWohlstadter for reporting!

@BryanCutler

Copy link
Copy Markdown
Member

Looks like the same issue for DictionaryBatches. I added https://issues.apache.org/jira/browse/ARROW-2645 to track.

@BryanCutler

Copy link
Copy Markdown
Member

merged to master

BryanCutler added a commit that referenced this pull request May 31, 2018
… specifc logic

Related to #2079 , the DictionaryBatch `ArrowBlock`s were being accumulated in the base class and used by `ArrowFileWriter` but not `ArrowStreamWriter`.  This refactors the `ArrowWriter` to move Lists of ArrowBlocks from the base class to only `ArrowFileWriter`.

Moved tests counting ArrowBlocks written from ArrowStreamWriter tests to ArrowFileWriter.

Author: Bryan Cutler <cutlerb@gmail.com>

Closes #2090 from BryanCutler/java-ArrowStreamWriter-accum-DictionaryBlocks-ARROW-2645 and squashes the following commits:

fc7f061 <Bryan Cutler> added comment about saving ArrowBlocks
5e4711a <Bryan Cutler> Moved lists of ArrowBlocks in ArrowWriter base class to ArrowFileWriter where they are used
pribor pushed a commit to GlobalWebIndex/arrow that referenced this pull request Oct 24, 2025
…not use them

ArrowStreamWriter inherits from ArrowWriter the behavior of accumulating an ArrowBlock for each ArrowRecordBatch that is written. But this data is never used in the context of ArrowStreamWriter. writeRecordBatch can be overridden in ArrowStreamWriter to avoid adding the memory overhead.

Author: Teddy Choi <pudidic@gmail.com>

Closes apache#2079 from pudidic/ARROW-2632 and squashes the following commits:

70ecf08 <Teddy Choi> Preserve logging. Add more list size checks in unit tests.
7b289d4 <Teddy Choi> ARROW-2632:  ArrowStreamWriter accumulates ArrowBlock but does not use them
pribor pushed a commit to GlobalWebIndex/arrow that referenced this pull request Oct 24, 2025
… specifc logic

Related to apache#2079 , the DictionaryBatch `ArrowBlock`s were being accumulated in the base class and used by `ArrowFileWriter` but not `ArrowStreamWriter`.  This refactors the `ArrowWriter` to move Lists of ArrowBlocks from the base class to only `ArrowFileWriter`.

Moved tests counting ArrowBlocks written from ArrowStreamWriter tests to ArrowFileWriter.

Author: Bryan Cutler <cutlerb@gmail.com>

Closes apache#2090 from BryanCutler/java-ArrowStreamWriter-accum-DictionaryBlocks-ARROW-2645 and squashes the following commits:

fc7f061 <Bryan Cutler> added comment about saving ArrowBlocks
5e4711a <Bryan Cutler> Moved lists of ArrowBlocks in ArrowWriter base class to ArrowFileWriter where they are used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants