在大数据背景下,一般会将整理的数据存储到HBASE上,这时,就要用到api去连接HBASE,以实现对表的管理:
/**
* 上下文标签
*/
object ContextTags {
def main(args: Array[String]): Unit = {
if(args.length !=5){
println(
"""
|输入参数不合法
|inputPath:输入路径
|outputPath:输出路径
|stopwordsPath:停用词库路径
|dictPath:字典文件路径
|day:日期
""".stripMargin)
//day的意思是一天一个列簇,保存30天进行清空
sys.exit()
}
//创建一个集合存储输入目录
val Array(inputPath, outputPath,dicPath,stopwords,day) = args
val conf = new SparkConf().setAppName(s"${this.getClass.getName}")
//序列化
.setMaster("local[*]").set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
val sc = new SparkContext(conf)
val sQLContext = new SQLContext(sc)
//压缩
sQLContext.setConf("spark.sql.parquet.codec", "snappy")
//读取字典文件
val map = sc.textFile(dicPath)
.map(_.split("\t", -1)).
filter(_.length >=5).map(arr =>{
(arr(4), arr(1))