You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "metesynnada (via GitHub)" <gi...@apache.org> on 2023/04/18 15:43:22 UTC

[GitHub] [arrow-datafusion] metesynnada opened a new issue, #6050: Avoid RecordBatch clones during MemoryExec and MemoryStream construction

metesynnada opened a new issue, #6050:
URL: https://github.com/apache/arrow-datafusion/issues/6050

   ### Is your feature request related to a problem or challenge?
   
   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   The `MemoryExec` currently uses cloning for `RecordBatch`es, which is completely avoidable. The methods
   
   ```rust
   impl MemoryExec {
       /// Create a new execution plan for reading in-memory record batches
       /// The provided `schema` should not have the projection applied.
       pub fn try_new(
           partitions: &[Vec<RecordBatch>],
           schema: SchemaRef,
           projection: Option<Vec<usize>>,
       ) -> Result<Self> {
           let projected_schema = project_schema(&schema, projection.as_ref())?;
           Ok(Self {
               partitions: partitions.to_vec(),
               schema,
               projected_schema,
               projection,
               sort_information: None,
           })
       }
   }
   
   impl ExecutionPlan for MemoryExec {
       fn execute(
           &self,
           partition: usize,
           _context: Arc<TaskContext>,
       ) -> Result<SendableRecordBatchStream> {
           Ok(Box::pin(MemoryStream::try_new(
               self.partitions[partition].clone(),
               self.projected_schema.clone(),
               self.projection.clone(),
           )?))
       }
   }
   ```
   
   clones the data for transfer ownership. This can be avoided with shared pointer usage.
   
   ### Describe the solution you'd like
   
   Share data behind Arc<RwLock<..>> to avoid clones and improve performance.
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] metesynnada closed issue #6050: Avoid RecordBatch clones during MemoryExec and MemoryStream construction

Posted by "metesynnada (via GitHub)" <gi...@apache.org>.
metesynnada closed issue #6050: Avoid RecordBatch clones during MemoryExec and MemoryStream construction
URL: https://github.com/apache/arrow-datafusion/issues/6050


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] metesynnada commented on issue #6050: Avoid RecordBatch clones during MemoryExec and MemoryStream construction

Posted by "metesynnada (via GitHub)" <gi...@apache.org>.
metesynnada commented on issue #6050:
URL: https://github.com/apache/arrow-datafusion/issues/6050#issuecomment-1514629878

   You are right, it is a shared pointer cloning. Thanks for the remind.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] Dandandan commented on issue #6050: Avoid RecordBatch clones during MemoryExec and MemoryStream construction

Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan commented on issue #6050:
URL: https://github.com/apache/arrow-datafusion/issues/6050#issuecomment-1514588857

   It doesn't really clone the data right? It clones `RecordBatch` which shouldn't be that expensive (cloning the `Vec` probably the most expensive when having many columns). 
   ```
   pub struct RecordBatch {
       schema: SchemaRef,
       columns: Vec<Arc<dyn Array>>,
   
       /// The number of rows in this RecordBatch
       ///
       /// This is stored separately from the columns to handle the case of no columns
       row_count: usize,
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org