[Spark base]-01

来源:互联网 发布:ipad视频怎么导入mac 编辑:程序博客网 时间:2024/05/16 09:09

首先学习基本的linux指令是必须的

下面给出ubuntu环境下搭载Spark网址:

http://blog.csdn.net/u010171031/article/details/51849562

其中特别是要找到spark-1.6.1-bin-hadoop2.6/usr 的绝对位置,,加上source /etc/profile,然后可以执行任何的python_shell(scala),pyspark(python),sparkR(R)

Spark首要概念是RDD(分布式数据集,可创造,可转换,不可迭代):

1)RDD

Actions:返回一个值

transformations:返回一个指向新RDDs的指针

#create RDDtextFile=sc.textFile("README.md")#simple operations#actions
textFile.count()
textFile.first()#transformationlinesWithSpark=textFile.filter(lambda line: "Spark" in line)

linesWithSpark.count()
#使用数据流模式(mapreduce)wordcounts=textFile.flatMap(lambda line:line.split()).map(lambda word :(word,1)).reduceByKey(lambda a,b :a+b)wordcounts.collect()  #收集每个字的统计次数

                                             
0 0
原创粉丝点击