Github user guoyuepeng commented on a diff in the pull request:
https://github.com/apache/incubator-griffin/pull/396#discussion_r210854573
--- Diff:
measure/src/main/scala/org/apache/griffin/measure/step/builder/dsl/expr/TreeNode.scala
---
@@ -18,28 +18,42 @@ under the License.
*/
package org.apache.griffin.measure.step.builder.dsl.expr
+import scala.reflect.ClassTag
+
trait TreeNode extends Serializable {
var children = Seq[TreeNode]()
def addChild(expr: TreeNode) = { children :+= expr }
def addChildren(exprs: Seq[TreeNode]) = { children ++= exprs }
- def preOrderTraverseDepthFirst[T, A <: TreeNode](z: T)(seqOp: (A, T) =>
T, combOp: (T, T) => T): T = {
- if (this.isInstanceOf[A]) {
- val tv = seqOp(this.asInstanceOf[A], z)
- children.foldLeft(combOp(z, tv)) { (ov, tn) =>
- combOp(ov, tn.preOrderTraverseDepthFirst(z)(seqOp, combOp))
+ def preOrderTraverseDepthFirst[T, A <: TreeNode](z: T)(seqOp: (A, T) =>
T, combOp: (T, T) => T)(implicit tag: ClassTag[A]): T = {
+
+ val clazz = tag.runtimeClass
+
+ this.getClass match {
+ case `clazz` => {
--- End diff --
we cannot use this patch, please remove this .
---