Commit a7f214f8 authored by 张彦钊's avatar 张彦钊

Merge branch 'master' of git.wanmeizhensuo.com:ML/ffm-baseline

esmm 测试项目
parents 2a94c657 4043ac08
...@@ -558,85 +558,85 @@ object alpha_ctr { ...@@ -558,85 +558,85 @@ object alpha_ctr {
//println(param.date) //println(param.date)
val partition_date = stat_date.replace("-","") val partition_date = stat_date.replace("-","")
// val click_count_recommend = sc.sql( val click_count_recommend = sc.sql(
// s""" s"""
// |select '${stat_date}' as stat_date,count(*) as click_count_recommend |select '${stat_date}' as stat_date,count(*) as click_count_recommend
// |from bl.bl_alpha_et_mg_maidianlog_inc_d |from bl.bl_alpha_et_mg_maidianlog_inc_d
// |where params['tab_name']='recommend' |where params['tab_name']='recommend'
// |and params['page_name']='home' |and params['page_name']='home'
// |and type='on_click_feed_topic_card' |and type='on_click_feed_topic_card'
// |and partition_day='${partition_date}' |and partition_day='${partition_date}'
// """.stripMargin """.stripMargin
// ) )
// click_count_recommend.show() click_count_recommend.show()
//
// val click_count_focus = sc.sql( val click_count_focus = sc.sql(
// s""" s"""
// |select '${stat_date}' as stat_date,count(*) as click_count_focus |select '${stat_date}' as stat_date,count(*) as click_count_focus
// |from bl.bl_alpha_et_mg_maidianlog_inc_d |from bl.bl_alpha_et_mg_maidianlog_inc_d
// |where params['tab_name']='focus' |where params['tab_name']='focus'
// |and params['page_name']='home' |and params['page_name']='home'
// |and type='on_click_feed_topic_card' |and type='on_click_feed_topic_card'
// |and partition_day='${partition_date}' |and partition_day='${partition_date}'
// """.stripMargin """.stripMargin
// ) )
// click_count_focus.show() click_count_focus.show()
//
//
// def parse_json(str:String): Int ={ def parse_json(str:String): Int ={
// var t = List[Map[String, Any]]() var t = List[Map[String, Any]]()
// val result = JSON.parseFull(str) val result = JSON.parseFull(str)
// result match { result match {
// case Some(b: List[Map[String, Any]]) => t = t ++ b case Some(b: List[Map[String, Any]]) => t = t ++ b
// case None => println("Parsing failed") case None => println("Parsing failed")
// case other => println("Unknown data structure: " + other) case other => println("Unknown data structure: " + other)
// } }
// t.size t.size
//
// } }
//
// val expoure_cards=sc.sql( val expoure_cards=sc.sql(
// s""" s"""
// |select params['exposure_cards'] as exposure_cards |select params['exposure_cards'] as exposure_cards
// |from bl.bl_alpha_et_mg_maidianlog_inc_d |from bl.bl_alpha_et_mg_maidianlog_inc_d
// |where params['tab_name'] = 'recommend' |where params['tab_name'] = 'recommend'
// |and params['page_name'] = 'home' |and params['page_name'] = 'home'
// |and type = 'page_precise_exposure' |and type = 'page_precise_exposure'
// |and partition_day='${partition_date}' |and partition_day='${partition_date}'
// """.stripMargin """.stripMargin
// ) )
// val a =expoure_cards.rdd.map(row => row(0).toString).map(row=>parse_json(row)).collect().sum val a =expoure_cards.rdd.map(row => row(0).toString).map(row=>parse_json(row)).collect().sum
// val result1=List((stat_date,a)) val result1=List((stat_date,a))
// val df1 = sc.createDataFrame(result1).toDF("stat_date","expoure_count_recommend") val df1 = sc.createDataFrame(result1).toDF("stat_date","expoure_count_recommend")
//
// val expoure_cards2=sc.sql( val expoure_cards2=sc.sql(
// s""" s"""
// |select params['exposure_cards'] as exposure_cards |select params['exposure_cards'] as exposure_cards
// |from bl.bl_alpha_et_mg_maidianlog_inc_d |from bl.bl_alpha_et_mg_maidianlog_inc_d
// |where params['tab_name'] = 'focus' |where params['tab_name'] = 'focus'
// |and params['page_name'] = 'home' |and params['page_name'] = 'home'
// |and type = 'page_precise_exposure' |and type = 'page_precise_exposure'
// |and partition_day='${partition_date}' |and partition_day='${partition_date}'
// """.stripMargin """.stripMargin
// ) )
// val b =expoure_cards2.rdd.map(row => row(0).toString).map(row=>parse_json(row)).collect().sum val b =expoure_cards2.rdd.map(row => row(0).toString).map(row=>parse_json(row)).collect().sum
// val result2=List((stat_date,b)) val result2=List((stat_date,b))
// val df2 = sc.createDataFrame(result2).toDF("stat_date","expoure_count_focus") val df2 = sc.createDataFrame(result2).toDF("stat_date","expoure_count_focus")
//
//
//
// val result=click_count_recommend.join(click_count_focus,"stat_date") val result=click_count_recommend.join(click_count_focus,"stat_date")
// .join(df1,"stat_date") .join(df1,"stat_date")
// .join(df2,"stat_date") .join(df2,"stat_date")
//
//
//
// GmeiConfig.writeToJDBCTable(result, "alpha_ctr", SaveMode.Append) GmeiConfig.writeToJDBCTable(result, "alpha_ctr", SaveMode.Append)
val device_duration_avge = sc.sql( val device_duration_avge = sc.sql(
s""" s"""
|SELECT '${stat_date}' as stat_date,sum(a.time_all)/count(a.device_id) as averge_time from (select device_id,sum(params['duration']) as time_all |SELECT '${stat_date}' as stat_date,sum(a.time_all)/count(a.device_id) as device_duration_avge,count(distinct(a.device_id)) as device_num from (select device_id,sum(params['duration']) as time_all
|from bl.bl_alpha_et_mg_maidianlog_inc_d |from bl.bl_alpha_et_mg_maidianlog_inc_d
|where type='on_app_session_over' |where type='on_app_session_over'
|and partition_day='${partition_date}' |and partition_day='${partition_date}'
...@@ -647,10 +647,10 @@ object alpha_ctr { ...@@ -647,10 +647,10 @@ object alpha_ctr {
val duration_everytime_avge=sc.sql( val duration_everytime_avge=sc.sql(
s""" s"""
|SELECT '${stat_date}' as stat_date,sum(a.time_duration)/count(a.device_id) as averge_time from (select device_id,params['duration'] as time_duration |SELECT '${stat_date}' as stat_date,sum(a.time_duration)/count(a.device_id) as duration_everytime_avge from (select device_id,params['duration'] as time_duration
|from bl.bl_alpha_et_mg_maidianlog_inc_d |from bl.bl_alpha_et_mg_maidianlog_inc_d
|where type='on_app_session_over' |where type='on_app_session_over'
|and partition_day='20190404') a |and partition_day='${partition_date}') a
""".stripMargin """.stripMargin
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment