本文整理汇总了Scala中org.apache.hadoop.hive.ql.io.sarg.SearchArgumentFactory类的典型用法代码示例。如果您正苦于以下问题:Scala SearchArgumentFactory类的具体用法?Scala SearchArgumentFactory怎么用?Scala SearchArgumentFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SearchArgumentFactory类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: OrcPredicateBuilder
//设置package包名称以及导入依赖的类
package io.eels.component.orc
import io.eels._
import org.apache.hadoop.hive.ql.io.sarg.{PredicateLeaf, SearchArgument, SearchArgumentFactory}
object OrcPredicateBuilder extends PredicateBuilder[SearchArgument] {
override def build(predicate: Predicate): SearchArgument = {
val builder = SearchArgumentFactory.newBuilder().startOr()
build(predicate, builder)
builder.end.build()
}
private def not(builder: SearchArgument.Builder, around: => Any): Unit = {
builder.startNot()
around
builder.end()
}
private def build(predicate: Predicate, builder: SearchArgument.Builder): Unit = predicate match {
case OrPredicate(predicates) =>
builder.startOr()
predicates.foreach(build(_, builder))
builder.end()
case AndPredicate(predicates) =>
builder.startAnd()
predicates.foreach(build(_, builder))
builder.end()
case EqualsPredicate(name: String, value: String) => builder.equals(name, PredicateLeaf.Type.STRING, value)
case EqualsPredicate(name: String, value: Boolean) => builder.equals(name, PredicateLeaf.Type.BOOLEAN, value)
case EqualsPredicate(name: String, value: Double) => builder.equals(name, PredicateLeaf.Type.FLOAT, java.lang.Double.valueOf(value))
case EqualsPredicate(name: String, value: Float) => builder.equals(name, PredicateLeaf.Type.FLOAT, java.lang.Float.valueOf(value))
case EqualsPredicate(name: String, value: Int) => builder.equals(name, PredicateLeaf.Type.LONG, java.lang.Long.valueOf(value))
case EqualsPredicate(name: String, value: Long) => builder.equals(name, PredicateLeaf.Type.LONG, java.lang.Long.valueOf(value))
case LtPredicate(name, value: Double) => builder.lessThan(name, PredicateLeaf.Type.FLOAT, java.lang.Double.valueOf(value))
case LtPredicate(name, value: Float) => builder.lessThan(name, PredicateLeaf.Type.FLOAT, java.lang.Float.valueOf(value))
case LtPredicate(name, value: Int) => builder.lessThan(name, PredicateLeaf.Type.LONG, java.lang.Long.valueOf(value))
case LtPredicate(name, value: Long) => builder.lessThan(name, PredicateLeaf.Type.LONG, java.lang.Long.valueOf(value))
case LtePredicate(name, value: Double) => builder.lessThanEquals(name, PredicateLeaf.Type.FLOAT, java.lang.Double.valueOf(value))
case LtePredicate(name, value: Float) => builder.lessThanEquals(name, PredicateLeaf.Type.FLOAT, java.lang.Float.valueOf(value))
case LtePredicate(name, value: Int) => builder.lessThanEquals(name, PredicateLeaf.Type.LONG, java.lang.Long.valueOf(value))
case LtePredicate(name, value: Long) => builder.lessThanEquals(name, PredicateLeaf.Type.LONG, java.lang.Long.valueOf(value))
case GtPredicate(name, value: Double) => not(builder, builder.lessThanEquals(name, PredicateLeaf.Type.FLOAT, java.lang.Double.valueOf(value)))
case GtPredicate(name, value: Float) => not(builder, builder.lessThanEquals(name, PredicateLeaf.Type.FLOAT, java.lang.Float.valueOf(value)))
case GtPredicate(name, value: Int) => not(builder, builder.lessThanEquals(name, PredicateLeaf.Type.LONG, java.lang.Long.valueOf(value)))
case GtPredicate(name, value: Long) => not(builder, builder.lessThanEquals(name, PredicateLeaf.Type.LONG, java.lang.Long.valueOf(value)))
case GtePredicate(name, value: Double) => not(builder, builder.lessThan(name, PredicateLeaf.Type.FLOAT, java.lang.Double.valueOf(value)))
case GtePredicate(name, value: Float) => not(builder, builder.lessThan(name, PredicateLeaf.Type.FLOAT, java.lang.Float.valueOf(value)))
case GtePredicate(name, value: Int) => not(builder, builder.lessThan(name, PredicateLeaf.Type.LONG, java.lang.Long.valueOf(value)))
case GtePredicate(name, value: Long) => not(builder, builder.lessThan(name, PredicateLeaf.Type.LONG, java.lang.Long.valueOf(value)))
}
}