|
spark-redis使用简易脚本 package com.*****
import org.apache.spark.{SparkConf, SparkContext}
import com.redislabs.provider.redis._
/**
* \* Created By ****.
* \* User: ****
* \* Date: 2019-09-26
* \* Time: 18:26
* \* To change this template use File | Settings | File Templates.
* \* Description:
* \*/
object Test {
def main(args: Array[String]) {
if (args.length < 1) {
System.err.println("Usage: <file>")
System.exit(1)
}
val conf = new SparkConf()
conf.set("redis.host","xx.xxx.xx.xxx")
conf.set("redis.port","6379")
// conf.set("redis.db","0")
val sc = new SparkContext(conf)
val data = Array(("key1", "v1"), ("key2", "world"), ("key3", "hello"), ("key4", "Hong"), ("key5", "Kong"))
val distData = sc.parallelize(data)
sc.toRedisHASH(distData,"foo")
val stringRDD = sc.fromRedisHash(Array("foo")).collect().foreach(println(_))
val stringRDD1 = sc.fromRedisKV(Array("aaa","bbb")).map(x=>(x._1,x._2.toString)).collect().foreach(println(_))
sc.stop()
}
} |
----------------------------
原文链接:https://blog.csdn.net/voidfaceless/article/details/101758856
程序猿的技术大观园:www.javathinker.net
[这个贴子最后由 flybird 在 2020-03-22 12:08:59 重新编辑]
|
网站系统异常
系统异常信息 |
Request URL:
http://www.javathinker.net/WEB-INF/lybbs/jsp/topic.jsp?postID=2955
java.lang.NullPointerException
如果你不知道错误发生的原因,请把上面完整的信息提交给本站管理人员。
|
|