版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
Spark13DATAGURU專業(yè)數(shù)據(jù)分析Spark大數(shù)據(jù)快速計算平風(fēng) 課程詳 Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析RDD的編SparkSpark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析SparkSpark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析Driver
Ajarcontainingtheuser'sSparkapplication.Insomecasesuserswillwanttocreatean"uberjar"containingtheirapplicationalongwithitsdependencies.Theuser'sjarshouldneverincludeHadooporSparklibraries,however,thesewillbeaddedatTheprocessrunningthemain()functionoftheapplicationandcreatingtheCluster Anexternalserviceforacquiringresourcesonthecluster(e.g.standalonemanager,Mesos,Deploy Distinguisheswherethedriverprocessruns.In"cluster"mode,theframeworklaunchesthedriverinsideofthecluster."client"mode,thesubmitterlaunchesthedriveroutsideoftheWorker Anynodethatcanrunapplicationcodeinthe Aprocesslaunchedforanapplicationonaworkernode,thatrunstasksandkeepsdatainmemoryordiskstoragethem.Eachapplicationhasitsown Aunitofworkthatwillbesenttoone AparallelcomputationconsistingofmultipletasksthatgetsspawnedinresponsetoaSparkaction(e.g.save,collect);you'llseethistermusedinthedriver'slogs.EachjobgetsdividedintosmallerEachjobgetsdividedintosmallersetsoftaskscalledstagesthatdependoneachother(similartothemapandreducestagesinMapReduce);you'llseethistermusedinthedriver'slogs.DATAGURU專業(yè)數(shù)據(jù)分析SparkRDDSpark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析Spark編程模Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析RDDSpark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析描述scala>valmap1=rdd.map(_*3)res0:Array[Int]=Array(3,6,9,12,scala>valrddscala>valfiltered=res2:Array[String]=Array(jifeng,scala>valrdd=sc.parallelize(List("aaaddfdc","dcisfun"))scala>valfm=rdd.flatMap(str=>str.split(""))res3:Array[String]=Array(aa,ad,df,dc,dc,is,Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析描述reduceByKey(func,scala>valwd=fm.map(word=>(word,1))scala>wdnum.collect()Array[(String,Int)]=Array((aa,1),(is,1),(df,1),(dc,2),(ad,1),Array[(String,Int)]=Array((aa,1),(ad,1),(dc,2),(df,1),(fun,1),scala>valcntWrd=wdnum.map{case(word,count)=>(count,word)}scala>cntWrd.groupByKey().collect()Array[(Int,Iterable[String])]=Array(( pactBuffer(dc)),( pactBuffer(aa,is,df,ad,scala>fm.distinct().collect()Array[String]=Array(aa,is,df,dc,ad,Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析描述 scala>rdd.reduce(_+_)Int=scala>valrdd=rdd:Array[String]=Array(A,B,C,scala>rdd.count()Long=scala>rdd.take(3)Array[String]=Array(A,B,Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析描述scala>rdd.first()String=AScala>valrdd=scala>$ls//查看part-00000part-00001Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析描述Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析haRDhaRDRDaquet文件、Jh查詢he注意Spark1.1使用registerTempTable代替1.0版本的Spark1.1在hiveContext中,hql()將被棄用,sql()將代替hql()來提交查詢語句,統(tǒng)一了接口使用 表是一個臨時表,生命周期只在所定義的sqlContext或hiveContext實例之中spark1.1提供了語法解析器選項spark.sql.dialect,目前有兩種語法解析器,sql語法解析器和hiveql語法解析器sqlContext現(xiàn)在只支持sql語法解析器(SQL-92語法)hiveContext現(xiàn)在支持sql語法解析器和hivesql語法解析器,默認(rèn)為hivesql語法解析器,用戶可以通過配置切換成sql語法解析器Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析 [jifeng@feng03~]$mkdirhive[jifeng@feng03~]$cdhive/[jifeng@feng02hive]$tarzxfapache-hive-0.13.1-bin.tar.gz[jifeng@feng02hive]$lsSpark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析Hive[jifeng@feng03hive]$viexport2修改 下的文[jifeng@feng03conf]$perties.template[jifeng@feng02conf]$mvhive-env.sh.templatehive-env.sh[jifeng@feng02conf]$cphive-default.xml.templatehive-Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析Hive修改 下的文export[jifeng@feng02conf]$cd[jifeng@feng02bin]$vihive-#Defaulttouseexport"hive-config.sh"73L,2023CSpark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析Hive配置[jifeng@feng03conf]$vihive-<property><description>JDBCconnectstringforaJDBC <description>DriverclassnameforaJDBCSpark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析Hive<description>usernametouseagainstmetastore<description>passwordtouseagainstmetastoreSpark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析Hive啟動[jifeng@feng02hadoop-2.6.0]$./sbin/start-啟動[jifeng@feng03hive]$15/09/0516:31:10WARNconf.HiveConf:DEPRECATED:hive.metastore.ds.retry.*nolongerhasanyeffect.Usehive.hmshandler.retry.*insteadLogginginitializedusingconfigurationinjar:file:/home/jifeng/hive/apache-hive-0.13. hive>createdatabasesale;Timetaken:1.188Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析hive>createtableshop(locationid namestring)rowformatdelimitedfieldsterminatedbyexceptionwasthrownwhileadding/validatingclass(es):Specifiedkeywastoolong;maxkeylengthis767atatjava.lang.reflect.Constructor.newInstance(Constructor.java:526)atcom.mysql.jdbc.Util.getInstance(Util.java:360)mysql>alterdatabasehivecharactersetlatin1;QueryOK,1rowaffected(0.00sec)Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析hive>createtableshop(locationidint,name namestring)rowformatdelimitedfieldsterminatedby',';Timetaken:0.884hive>createtablesell(locationidint,fyearint,amountdouble,numdouble)rowformatdelimitedfieldsterminatedbyTimetaken:0.158hive>showtables;Timetaken:0.105seconds,Fetched:2row(s)Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析上傳文件到j(luò)ifeng@feng03hive]$hadoopfsputhome/jifeng/code/db/shop.txtuser/jifeng/fire/hive>loaddatainpath'/user/jifeng/fire/shop.txt'intotableshop;Loadingdatatotabledefault.shopTimetaken:0.657hive>loaddatainpath'/user/jifeng/fire/sell.txt'intotablesell;Loadingdatatotabledefault.sellTimetaken:0.38Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析Hivesupportisenabledbyaddingthe-Phiveand-Phive-thriftserverflagstoSpark’sConfigurationofHiveisdonebyplacingyourhive-site.xmlfileinspark-sql>select*fromshopwhere15/09/0516:54:52INFOscheduler.TaskSchedulerImpl:Addingtaskset2.0with2tasks15/09/0516:54:52INFOstorage.BlockManagerInfo:Addedbroadcast_3_piece0inmemoryon10:58340(size:35.2KB,free:267.2MB)15/09/0516:54:52INFOscheduler.TaskSetManager:Finishedtask0.0instage2.0(TID3)in574mson10(1/2)15/09/0516:54:53INFOscheduler.DAGScheduler:ResultStage2(processCmdatCliDriver.java:423)finishedin0.617s15/09/0516:54:53INFOscheduler.DAGScheduler:Job2finished:processCmdatCliDriver.java:423,took0.680182s Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析 importimportorg.apache.spark.sql.hive.HiveContextimportorg.apache.spark.mllib.linalg.VectorsvalsqlContext=newvalsqldata=sqlContext.sql("selectlocationid,sum(num)allnum,sum(amount)allamountfromsellgroupbylocationid")Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析valparsedData=sqldata.mapcaseRow(_,allnum,allamount)} valnumClusters=3valnumIterations=valmodel=KMeans.train(parsedData,numClusters,Spark大數(shù)據(jù)快速計算平風(fēng)
DATAGURU專業(yè)數(shù)據(jù)分析valresult1=sqldata.map{caseRow(locationid,allnum,allamount)vallinevectore=Vectors.dense(features)valprediction=locationid+""+allnum+""+allamoun
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 企事業(yè)單位標(biāo)識牌制作協(xié)議
- 應(yīng)用統(tǒng)計的課程設(shè)計
- 衛(wèi)生土地填埋課程設(shè)計
- 基坑降水施工合同:體育場館建設(shè)
- 鄭州投資房產(chǎn)交易合同樣本
- 沖壓廠電力供應(yīng)合同
- 礦物加工設(shè)備租賃合同
- 酒店后花園景觀工程協(xié)議
- 2024年升級版:個人收藏品租賃合同3篇
- 幼兒園摘水果課程設(shè)計
- apt攻擊專項應(yīng)急預(yù)案
- 小學(xué)三年級秋季學(xué)期《道德與法治》(統(tǒng)編版)學(xué)習(xí)任務(wù)單(全冊匯總)
- 奧迪A7L汽車說明書
- 美育-美即生活 美育期末試卷及答案
- 網(wǎng)站項目功能測試驗收報告
- 自考02313電力系統(tǒng)微型計算機(jī)繼電保護(hù)歷年(12-19)真題試卷
- 馬克思主義基本原理智慧樹知到答案章節(jié)測試2023年重慶工商大學(xué)
- 合理性、先進(jìn)性的證明
- 人教版數(shù)學(xué)三年級上冊分?jǐn)?shù)的初步認(rèn)識分?jǐn)?shù)的初步認(rèn)識-課件16
- 選必中第一單元大單元教學(xué)設(shè)計
- GB/T 34281-2017全民健身活動中心分類配置要求
評論
0/150
提交評論