Make BallistaContext::collect streaming#535
Merged
andygrove merged 1 commit intoapache:masterfrom Jun 11, 2021
Merged
Conversation
Contributor
Author
|
cc @andygrove |
edrevo
commented
Jun 10, 2021
Comment on lines
+77
to
+102
| struct WrappedStream { | ||
| stream: Pin<Box<dyn Stream<Item = ArrowResult<RecordBatch>> + Send + Sync>>, | ||
| schema: SchemaRef, | ||
| } | ||
|
|
||
| impl RecordBatchStream for WrappedStream { | ||
| fn schema(&self) -> SchemaRef { | ||
| self.schema.clone() | ||
| } | ||
| } | ||
|
|
||
| impl Stream for WrappedStream { | ||
| type Item = ArrowResult<RecordBatch>; | ||
|
|
||
| fn poll_next( | ||
| mut self: Pin<&mut Self>, | ||
| cx: &mut std::task::Context<'_>, | ||
| ) -> std::task::Poll<Option<Self::Item>> { | ||
| self.stream.poll_next_unpin(cx) | ||
| } | ||
|
|
||
| fn size_hint(&self) -> (usize, Option<usize>) { | ||
| self.stream.size_hint() | ||
| } | ||
| } | ||
|
|
Contributor
Author
There was a problem hiding this comment.
I was surprised I couldn't find anything like this. If there is a similar struct that I missed please do let me know and I'll use that one.
Also, since this is a pretty general wrapper, if you want me to move this to another place and make it public, I can do that too.
Codecov Report
@@ Coverage Diff @@
## master #535 +/- ##
==========================================
- Coverage 76.03% 76.02% -0.02%
==========================================
Files 157 157
Lines 26990 26994 +4
==========================================
Hits 20521 20521
- Misses 6469 6473 +4
Continue to review full report at Codecov.
|
Member
|
I ran integration tests locally and they passed so I am going to go ahead and merge this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #534.
Rationale for this change
The collect implementation in BallistaContext is bringing all of the contents in memory even though there is no need for it.
What changes are included in this PR?
Collect will now use streams all the way to avoid hogging memory
Are there any user-facing changes?
No