forked from oap-project/gazelle_plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NSE-782] backport master changes to 1.3.1 branch (oap-project#814)
* [NSE-772] Code refactor for ColumnarBatchScan (oap-project#805) * Override doCanonicalize in ColumnarBatchScanExec * Refactor ColumnarBatchScan * [NSE-778] Failed to find include file while running code gen (oap-project#779) * fix can not find include file * add maven test content back Co-authored-by: PHILO-HE <feilong.he@intel.com> Co-authored-by: Jacky Lee <lijunqing@baidu.com>
- Loading branch information
1 parent
ad756df
commit 9224df6
Showing
11 changed files
with
150 additions
and
156 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
78 changes: 78 additions & 0 deletions
78
native-sql-engine/core/src/main/scala/com/intel/oap/execution/ColumnarBatchScanExec.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,78 @@ | ||
/* | ||
* 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 com.intel.oap.execution | ||
|
||
import com.intel.oap.GazellePluginConfig | ||
import org.apache.spark.rdd.RDD | ||
import org.apache.spark.sql.catalyst.expressions.{DynamicPruningExpression, Literal, _} | ||
import org.apache.spark.sql.catalyst.plans.QueryPlan | ||
import org.apache.spark.sql.connector.read.{Scan} | ||
import org.apache.spark.sql.execution.metric.SQLMetrics | ||
import org.apache.spark.sql.vectorized.ColumnarBatch | ||
|
||
|
||
class ColumnarBatchScanExec(output: Seq[AttributeReference], @transient scan: Scan, | ||
runtimeFilters: Seq[Expression]) | ||
extends ColumnarBatchScanExecBase(output, scan, runtimeFilters) { | ||
val tmpDir: String = GazellePluginConfig.getConf.tmpFile | ||
override def supportsColumnar(): Boolean = true | ||
override lazy val metrics = Map( | ||
"numOutputRows" -> SQLMetrics.createMetric(sparkContext, "number of output rows"), | ||
"numInputBatches" -> SQLMetrics.createMetric(sparkContext, "input_batches"), | ||
"numOutputBatches" -> SQLMetrics.createMetric(sparkContext, "output_batches"), | ||
"scanTime" -> SQLMetrics.createTimingMetric(sparkContext, "totaltime_batchscan"), | ||
"inputSize" -> SQLMetrics.createSizeMetric(sparkContext, "input size in bytes")) | ||
|
||
override def doExecuteColumnar(): RDD[ColumnarBatch] = { | ||
val numOutputRows = longMetric("numOutputRows") | ||
val numInputBatches = longMetric("numInputBatches") | ||
val numOutputBatches = longMetric("numOutputBatches") | ||
val scanTime = longMetric("scanTime") | ||
val inputSize = longMetric("inputSize") | ||
val inputColumnarRDD = | ||
new ColumnarDataSourceRDD(sparkContext, partitions, readerFactory, | ||
true, scanTime, numInputBatches, inputSize, tmpDir) | ||
inputColumnarRDD.map { r => | ||
numOutputRows += r.numRows() | ||
numOutputBatches += 1 | ||
r | ||
} | ||
} | ||
|
||
override def doCanonicalize(): ColumnarBatchScanExec = { | ||
if (runtimeFilters == null) { | ||
// For spark3.1. | ||
new ColumnarBatchScanExec(output.map(QueryPlan.normalizeExpressions(_, output)), scan, null) | ||
} else { | ||
// For spark3.2. | ||
new ColumnarBatchScanExec( | ||
output.map(QueryPlan.normalizeExpressions(_, output)), scan, | ||
QueryPlan.normalizePredicates( | ||
runtimeFilters.filterNot(_ == DynamicPruningExpression(Literal.TrueLiteral)), | ||
output)) | ||
} | ||
} | ||
|
||
override def canEqual(other: Any): Boolean = other.isInstanceOf[ColumnarBatchScanExec] | ||
|
||
override def equals(other: Any): Boolean = other match { | ||
case that: ColumnarBatchScanExec => | ||
(that canEqual this) && super.equals(that) | ||
case _ => false | ||
} | ||
} |
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
52 changes: 0 additions & 52 deletions
52
shims/spark311/src/main/scala/com/intel/oap/execution/ColumnarBatchScanExec.scala
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
shims/spark311/src/main/scala/com/intel/oap/execution/ColumnarBatchScanExecBase.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,30 @@ | ||
/* | ||
* 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 com.intel.oap.execution | ||
|
||
import org.apache.spark.sql.catalyst.expressions._ | ||
import org.apache.spark.sql.execution.datasources.v2.BatchScanExec | ||
import org.apache.spark.sql.connector.read.Scan | ||
|
||
/** For spark 3.1, the runtimeFilters: Seq[Expression] is not introduced in BatchScanExec. | ||
*/ | ||
abstract class ColumnarBatchScanExecBase(output: Seq[AttributeReference], @transient scan: Scan, | ||
runtimeFilters: Seq[Expression]) | ||
extends BatchScanExec(output, scan) { | ||
|
||
} |
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
53 changes: 0 additions & 53 deletions
53
shims/spark321/src/main/scala/com/intel/oap/execution/ColumnarBatchScanExec.scala
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
shims/spark321/src/main/scala/com/intel/oap/execution/ColumnarBatchScanExecBase.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,31 @@ | ||
/* | ||
* 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 com.intel.oap.execution | ||
|
||
import org.apache.spark.sql.catalyst.expressions._ | ||
import org.apache.spark.sql.execution.datasources.v2.BatchScanExec | ||
import org.apache.spark.sql.connector.read.Scan | ||
|
||
/** | ||
* This class is used to adapt to spark3.2 BatchScanExec with runtimeFilters. | ||
*/ | ||
abstract class ColumnarBatchScanExecBase(output: Seq[AttributeReference], @transient scan: Scan, | ||
runtimeFilters: Seq[Expression]) | ||
extends BatchScanExec(output, scan, runtimeFilters) { | ||
|
||
} |
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