Spark Introduction

Spark Introduction

ID:40402961

大小:1.30 MB

页数:60页

时间:2019-08-01

Spark Introduction_第1页
Spark Introduction_第2页
Spark Introduction_第3页
Spark Introduction_第4页
Spark Introduction_第5页
资源描述:

《Spark Introduction》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、SparkIntroduction@CrazyJvm什么是Spark?ApacheSparkisanopensourceclustercomputingsystemthataimstomakedataanalyticsfast--bothfasttorunandfasttowrite.就这么简单!Driver程序启动很多workers,然后workers在(分布式)文件系统中读取数据后转化为RDD,最后对RDD在内存中进行缓存和计算。为什么Spark的性能高?1、in-memorycomputation2、gener

2、alcomputationgraphs可参考Delayscheduling:Asimpletechniqueforachievinglocalityandfairnessinclusterscheduling提供了哪些语言的API?ScalaJavaPython怎样运行Spark?●Local●Standalone●Mesos●YARN可参考:@明风Andy出品的基于SparkonYarn的淘宝数据挖掘平台Scala光速入门玩Spark最好会点Scala。直接引用Matei-Zaharia之前介绍Scala的示例Sc

3、ala语言?1、基于JVM的FP+OO2、静态类型3、和JAVA可以互操作可以在Scala的命令行里试试!Scala--变量声明varx:Int=7valx=7//自动类型推导valy=“hi”//只读的相当于Java里的finalScala--函数defsquare(x:Int):Int=x*xdefsquare(x:Int):Int={x*x//在block中的最后一个值将被返回}defannounce(text:String){println(text)}Scala--泛型vararr=newArray[Int

4、](8)varlst=List(1,2,3)//1st的类型是List[Int]//索引访问arr(5)=7println(lst(1))Scala--FP的方式处理集合vallist=List(1,2,3)list.foreach(x=>println(x))//打印出1,2,3list.foreach(println)list.map(x=>x+2)//List(3,4,5)list.map(_+2)list.filter(x=>x%2==1)//List(1,3)list.filter(_%2==1)list.

5、reduce((x,y)=>x+y)//6list.reduce(_+_)Scala--闭包(x:Int)=>x+2x=>x+2_+2x=>{valnumberToAdd=2x+numberToAdd}//如果闭包很长,可以考虑作为参数传入defaddTwo(x:Int):Int=x+2list.map(addTwo)回到SparkSpark:从RDD说起RDDs:resilientdistributeddatasets1.immutablecollectionsofobjectsspreadacrossaclust

6、er2.buildthroughparalleltransformations(map,filter,groupBy,joinetc)3.automaticallyrebuildonfailure(基于lineage和checkpoint)4.differentstoragelevel(可(序列化)存在内存或者硬盘中)单独看下StorageLevel来建立几个RDDsc就是SparkContext,可以看做用户在spark上的入口。RDD到底是啥玩意儿?internally,eachRDDischaracterize

7、dbyfivemainproperties:*-Alistofpartitions*-Afunctionforcomputingeachsplit*-AlistofdependenciesonotherRDDs*-Optionally,aPartitionerforkey-valueRDDs(e.g.tosaythattheRDDishash-partitioned)*-Optionally,alistofpreferredlocationstocomputeeachspliton(e.g.blocklocation

8、sforanHDFSfile)进一步看下RDD●RDDs(可以从一系列数据源创建)●Transformations(延迟执行)●Action(defrunJob[T,U:ClassManifest](rdd:RDD[T],func:Iterator[T]=>U):Array[U])Transformation和Action举个经典的例子可以略微

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。