def main
(args: array[string]
): unit =
/** * 按照地市進行統計top3課程
** @param spark
* @param accessdf
*/def citytypeaccesstopnstat
(spark: sparksession, accessdf: dataframe)
: unit =
執行結果如下:
建立資料表:
create
table day_nettype_city_access_topn_stat (
dayvarchar(8
)not
null
,uid bigint(10
)not
null
,city varchar(20
)not
null
,times bigint(10
)not
null
,times_rank bigint(10
)not
null
,primary
key(
day, uid)
)
package cn.ac.iie.log
case
class
daycitynettypeaccessstat
(day:string, uid: long, city:string, times: long, times_rank: long)
*
** 批量儲存daycitynettypeaccessstat到資料庫
**@param list
*/ def insertdaynettypecityaccesstopn
(list: listbuffer[daycitynettypeaccessstat]
): unit =
pstmt.
executebatch()
// 執行批量處理
// 手動提交
connection.
commit()
}catch
finally
}
// 將統計結果寫入到mysql中
try)
statdao.
insertdaynettypecityaccesstopn
(list)})
}catch
Atom下Markdown使用 Windows版
使用 度量方法 preprocess norm similarity 余弦相似度 frac dot 皮爾遜相似度 frac right 2 dot 歐式距離 hat 2 sqrt 2 times dot n 傑卡距離 bin v right frac n dot 曼哈頓距離 bin v right ...
使用Spark SQL構建批處理程式
streamingpro目前已經涵蓋流式 批處理,以及互動查詢三個領域,實現配置和sql化 今天介紹利用 streamingpro 完成批處理的流程。我們假設您將檔案放在了 tmp目錄下。gist 在批處理模式下,所有的資料來源和輸出都各自有乙個固定的模組 使用了spark的datasource a...
使用Spark SQL構建批處理程式
今天介紹利用 streamingpro 完成批處理的流程。我們假設您將檔案放在了 tmp目錄下。gist local模式 cd spark home master local 2 name test tmp streamingpro 0.2.1 snapshot dev 1.6.1.jar stre...