本文整理汇总了Scala中org.apache.spark.sql.catalyst.trees.TreeNode类的典型用法代码示例。如果您正苦于以下问题:Scala TreeNode类的具体用法?Scala TreeNode怎么用?Scala TreeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TreeNode类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: CExpressions
//设置package包名称以及导入依赖的类
package org.sparkline.spark.udfs.contains
import org.apache.spark.sql.catalyst.trees.TreeNode
import org.sparkline.spark.udfs.BitmapUtils
object CExpressions {
abstract class CExpression extends TreeNode[CExpression] {
override def children: Seq[CExpression] = ???
def apply(row : Array[Array[Byte]]) : Boolean
def logicalOp(op : String, r : CExpression) : CExpression = op.toUpperCase match {
case "AND" => And(this, r)
case "OR" => Or(this, r)
}
def not(r : CExpression) : CExpression = Not(this)
}
case class BitmapContains(bIndex : Int, ids : Array[Int]) extends CExpression {
override def children: Seq[CExpression] = Seq()
override def apply(row : Array[Array[Byte]]) : Boolean = {
val b = row(bIndex)
BitmapUtils.contains(b, ids)
}
override def asCode: String = {
val idsStr = ids.mkString("new int[", ",", "]")
s"new BitmapContains($bIndex, $idsStr)"
}
}
case class And(l : CExpression, r : CExpression) extends CExpression {
override def children: Seq[CExpression] = Seq(l,r)
override def apply(row : Array[Array[Byte]]) : Boolean = {
l(row) && r(row)
}
}
case class Or(l : CExpression, r : CExpression) extends CExpression {
override def children: Seq[CExpression] = Seq(l,r)
override def apply(row : Array[Array[Byte]]) : Boolean = {
l(row) || r(row)
}
}
case class Not(c : CExpression) extends CExpression {
override def children: Seq[CExpression] = Seq(c)
override def apply(row : Array[Array[Byte]]) : Boolean = {
! c(row)
}
}
}