You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/05/16 15:11:40 UTC

[GitHub] [arrow] andygrove opened a new pull request #7203: ARROW-8822: [Rust] [DataFusion] Add InMemoryScan to LogicalPlan

andygrove opened a new pull request #7203:
URL: https://github.com/apache/arrow/pull/7203


   Add InMemoryScan to LogicalPlan.


----------------------------------------------------------------
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.

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



[GitHub] [arrow] andygrove closed pull request #7203: ARROW-8822: [Rust] [DataFusion] Add InMemoryScan to LogicalPlan

Posted by GitBox <gi...@apache.org>.
andygrove closed pull request #7203:
URL: https://github.com/apache/arrow/pull/7203


   


----------------------------------------------------------------
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.

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



[GitHub] [arrow] github-actions[bot] commented on pull request #7203: ARROW-8822: [Rust] [DataFusion] Add InMemoryScan to LogicalPlan

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #7203:
URL: https://github.com/apache/arrow/pull/7203#issuecomment-629661955


   https://issues.apache.org/jira/browse/ARROW-8822


----------------------------------------------------------------
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.

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



[GitHub] [arrow] houqp commented on a change in pull request #7203: ARROW-8822: [Rust] [DataFusion] Add InMemoryScan to LogicalPlan

Posted by GitBox <gi...@apache.org>.
houqp commented on a change in pull request #7203:
URL: https://github.com/apache/arrow/pull/7203#discussion_r426290642



##########
File path: rust/datafusion/src/execution/physical_plan/memory.rs
##########
@@ -0,0 +1,162 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Execution plan for reading in-memory batches of data
+
+use std::sync::{Arc, Mutex};
+
+use crate::error::Result;
+use crate::execution::physical_plan::{BatchIterator, ExecutionPlan, Partition};
+use arrow::datatypes::Schema;
+use arrow::record_batch::RecordBatch;
+
+/// Execution plan for reading in-memory batches of data
+pub struct MemoryExec {
+    /// The partitions to query
+    partitions: Vec<Vec<RecordBatch>>,
+    /// Schema representing the data after the optional projection is applied
+    schema: Arc<Schema>,
+    /// Optional projection
+    projection: Option<Vec<usize>>,
+}
+
+impl ExecutionPlan for MemoryExec {
+    /// Get the schema for this execution plan
+    fn schema(&self) -> Arc<Schema> {
+        self.schema.clone()
+    }
+
+    /// Get the partitions for this execution plan. Each partition can be executed in parallel.
+    fn partitions(&self) -> Result<Vec<Arc<dyn Partition>>> {
+        let partitions = self
+            .partitions
+            .iter()
+            .map(|vec| {
+                Arc::new(MemoryPartition::new(
+                    vec.clone(),
+                    self.schema.clone(),
+                    self.projection.clone(),
+                )) as Arc<dyn Partition>
+            })
+            .collect();
+        Ok(partitions)
+    }
+}
+
+impl MemoryExec {
+    /// Create a new execution plan for reading in-memory record batches
+    pub fn try_new(
+        partitions: &Vec<Vec<RecordBatch>>,
+        schema: Arc<Schema>,
+        projection: Option<Vec<usize>>,
+    ) -> Result<Self> {
+        Ok(Self {
+            partitions: partitions.clone(),
+            schema,
+            projection,
+        })
+    }
+}
+
+/// Memory partition
+struct MemoryPartition {
+    /// Vector of record batches
+    data: Vec<RecordBatch>,
+    /// Schema representing the data
+    schema: Arc<Schema>,
+    /// Optional projection
+    projection: Option<Vec<usize>>,
+}
+
+impl MemoryPartition {
+    /// Create a new in-memory partition
+    fn new(
+        data: Vec<RecordBatch>,
+        schema: Arc<Schema>,
+        projection: Option<Vec<usize>>,
+    ) -> Self {
+        Self {
+            data: data.clone(),

Review comment:
       would it be better to take ownership of the vec here without incurring the clone?




----------------------------------------------------------------
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.

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



[GitHub] [arrow] andygrove commented on pull request #7203: ARROW-8822: [Rust] [DataFusion] Add InMemoryScan to LogicalPlan

Posted by GitBox <gi...@apache.org>.
andygrove commented on pull request #7203:
URL: https://github.com/apache/arrow/pull/7203#issuecomment-630814547


   Since there is no feedback in the past two days, I'm going to go ahead and merge this one.


----------------------------------------------------------------
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.

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



[GitHub] [arrow] andygrove commented on a change in pull request #7203: ARROW-8822: [Rust] [DataFusion] Add InMemoryScan to LogicalPlan

Posted by GitBox <gi...@apache.org>.
andygrove commented on a change in pull request #7203:
URL: https://github.com/apache/arrow/pull/7203#discussion_r426294811



##########
File path: rust/datafusion/src/execution/physical_plan/memory.rs
##########
@@ -0,0 +1,162 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Execution plan for reading in-memory batches of data
+
+use std::sync::{Arc, Mutex};
+
+use crate::error::Result;
+use crate::execution::physical_plan::{BatchIterator, ExecutionPlan, Partition};
+use arrow::datatypes::Schema;
+use arrow::record_batch::RecordBatch;
+
+/// Execution plan for reading in-memory batches of data
+pub struct MemoryExec {
+    /// The partitions to query
+    partitions: Vec<Vec<RecordBatch>>,
+    /// Schema representing the data after the optional projection is applied
+    schema: Arc<Schema>,
+    /// Optional projection
+    projection: Option<Vec<usize>>,
+}
+
+impl ExecutionPlan for MemoryExec {
+    /// Get the schema for this execution plan
+    fn schema(&self) -> Arc<Schema> {
+        self.schema.clone()
+    }
+
+    /// Get the partitions for this execution plan. Each partition can be executed in parallel.
+    fn partitions(&self) -> Result<Vec<Arc<dyn Partition>>> {
+        let partitions = self
+            .partitions
+            .iter()
+            .map(|vec| {
+                Arc::new(MemoryPartition::new(
+                    vec.clone(),
+                    self.schema.clone(),
+                    self.projection.clone(),
+                )) as Arc<dyn Partition>
+            })
+            .collect();
+        Ok(partitions)
+    }
+}
+
+impl MemoryExec {
+    /// Create a new execution plan for reading in-memory record batches
+    pub fn try_new(
+        partitions: &Vec<Vec<RecordBatch>>,
+        schema: Arc<Schema>,
+        projection: Option<Vec<usize>>,
+    ) -> Result<Self> {
+        Ok(Self {
+            partitions: partitions.clone(),
+            schema,
+            projection,
+        })
+    }
+}
+
+/// Memory partition
+struct MemoryPartition {
+    /// Vector of record batches
+    data: Vec<RecordBatch>,
+    /// Schema representing the data
+    schema: Arc<Schema>,
+    /// Optional projection
+    projection: Option<Vec<usize>>,
+}
+
+impl MemoryPartition {
+    /// Create a new in-memory partition
+    fn new(
+        data: Vec<RecordBatch>,
+        schema: Arc<Schema>,
+        projection: Option<Vec<usize>>,
+    ) -> Self {
+        Self {
+            data: data.clone(),

Review comment:
       Good point. Thanks. Updated.




----------------------------------------------------------------
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.

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