Uh oh!
There was an error while loading. Please reload this page.
Make BallistaContext::collect streaming - #535
Conversation
edrevo
commented
Jun 10, 2021
cc @andygrove |
| 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() | ||
| } | ||
| } | ||
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-commenter
commented
Jun 10, 2021
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.
|
andygrove
commented
Jun 11, 2021
I ran integration tests locally and they passed so I am going to go ahead and merge this. |
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