当前位置: 首页>>代码示例>>Scala>>正文


Scala SearchArgumentFactory类代码示例

本文整理汇总了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)))
  }
} 
开发者ID:51zero,项目名称:eel-sdk,代码行数:60,代码来源:OrcPredicateBuilder.scala


注:本文中的org.apache.hadoop.hive.ql.io.sarg.SearchArgumentFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。