-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Hook DataFusion Parquet native scan with Comet execution (#1094)
* init * more * fix * more * more * fix
- Loading branch information
Showing
7 changed files
with
166 additions
and
463 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
56 changes: 56 additions & 0 deletions
56
spark/src/main/scala/org/apache/spark/sql/comet/CometExecRDD.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.apache.spark.sql.comet | ||
|
||
import org.apache.spark.{Partition, SparkContext, TaskContext} | ||
import org.apache.spark.rdd.{RDD, RDDOperationScope} | ||
import org.apache.spark.sql.vectorized.ColumnarBatch | ||
|
||
/** | ||
* A RDD that executes Spark SQL query in Comet native execution to generate ColumnarBatch. | ||
*/ | ||
private[spark] class CometExecRDD( | ||
sc: SparkContext, | ||
partitionNum: Int, | ||
var f: (Seq[Iterator[ColumnarBatch]]) => Iterator[ColumnarBatch]) | ||
extends RDD[ColumnarBatch](sc, Nil) { | ||
|
||
override def compute(s: Partition, context: TaskContext): Iterator[ColumnarBatch] = { | ||
f(Seq.empty) | ||
} | ||
|
||
override protected def getPartitions: Array[Partition] = { | ||
Array.tabulate(partitionNum)(i => | ||
new Partition { | ||
override def index: Int = i | ||
}) | ||
} | ||
} | ||
|
||
object CometExecRDD { | ||
def apply(sc: SparkContext, partitionNum: Int)( | ||
f: (Seq[Iterator[ColumnarBatch]]) => Iterator[ColumnarBatch]): RDD[ColumnarBatch] = | ||
withScope(sc) { | ||
new CometExecRDD(sc, partitionNum, f) | ||
} | ||
|
||
private[spark] def withScope[U](sc: SparkContext)(body: => U): U = | ||
RDDOperationScope.withScope[U](sc)(body) | ||
} |
Oops, something went wrong.