本文整理汇总了Scala中org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat类的典型用法代码示例。如果您正苦于以下问题:Scala OrcOutputFormat类的具体用法?Scala OrcOutputFormat怎么用?Scala OrcOutputFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OrcOutputFormat类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: OrcHiveDialect
//设置package包名称以及导入依赖的类
package io.eels.component.hive.dialect
import com.sksamuel.exts.Logging
import io.eels.component.hive.{HiveDialect, HiveOutputStream}
import io.eels.component.orc.{OrcPublisher, OrcWriteOptions, OrcWriter}
import io.eels.datastream.{Publisher, Subscriber}
import io.eels.schema.StructType
import io.eels.{Predicate, Row}
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.permission.FsPermission
import org.apache.hadoop.fs.{FileSystem, Path}
import org.apache.hadoop.hive.ql.io.orc.{OrcInputFormat, OrcOutputFormat, OrcSerde}
import scala.math.BigDecimal.RoundingMode.RoundingMode
case class OrcHiveDialect(options: OrcWriteOptions = OrcWriteOptions()) extends HiveDialect with Logging {
override val serde: String = classOf[OrcSerde].getCanonicalName
override val inputFormat: String = classOf[OrcInputFormat].getCanonicalName
override val outputFormat: String = classOf[OrcOutputFormat].getCanonicalName
override def input(path: Path,
metastoreSchema: StructType,
projectionSchema: StructType,
predicate: Option[Predicate])
(implicit fs: FileSystem, conf: Configuration): Publisher[Seq[Row]] = new Publisher[Seq[Row]] {
override def subscribe(subscriber: Subscriber[Seq[Row]]): Unit = {
new OrcPublisher(path, projectionSchema.fieldNames(), predicate).subscribe(subscriber)
}
}
override def output(schema: StructType,
path: Path,
permission: Option[FsPermission],
roundingMode: RoundingMode,
metadata: Map[String, String])(implicit fs: FileSystem, conf: Configuration): HiveOutputStream = {
val path_x = path
val writer = new OrcWriter(path, schema, options)
new HiveOutputStream {
override def write(row: Row): Unit = {
require(row.values.nonEmpty, "Attempting to write an empty row")
writer.write(row)
}
override def close(): Unit = {
writer.close()
permission.foreach(fs.setPermission(path, _))
}
override def records: Int = writer.records
override def path: Path = path_x
}
}
}
开发者ID:51zero,项目名称:eel-sdk,代码行数:58,代码来源:OrcHiveDialect.scala
注:本文中的org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论