我有一个得分表,该表可以添加新球员,单击鼠标左键可增加得分,单击鼠标右键可降低得分。默认情况下,我拥有的mousedown事件可与我已经加载到页面上的播放器一起使用,但是以后通过输入和按钮添加的任何播放器均不遵循我的mousedown事件的规则。要使将来的表项跟随我的事件和功能,我需要做些什么?
val hiveContext = new org.apache.spark.sql.hive.HiveContext(sc)
val df = hiveContext.read.parquet("hdfs://m7-common-cdh02:8020/user/guyc/data/demoTable/data")
df.show()
+-----------+-----------+-----+--------------------+
|act_idn_sky|sample_date|label| score|
+-----------+-----------+-----+--------------------+
| 1003| 2017-12-21| 0| 0.4891524644941294|
| 1000| 2017-12-21| 1| 0.7903595514185819|
| 1001| 2017-12-21| 1| 0.03421212604433099|
| 1004| 2017-12-21| 0|0.033869532272332914|
| 1005| 2017-12-21| 0| 0.8114563148864252|
| 1002| 2017-12-21| 1| 0.9779307907366478|
+-----------+-----------+-----+--------------------+
df.registerTempTable("t1")
val out = hiveContext.sql("with nt as (select label, score from (select * from (select label, score, row_number() over (order by score desc) as position from t1)t_1 join (select count(*) as countall from t1)t_2 )ta where position <= countall * 0.4) select count(*) as c_positive from nt where label = 1")
out: org.apache.spark.sql.DataFrame = [c_positive: bigint]
out.show()
+----------+
|c_positive|
+----------+
| 1|
| 0|
| 0|
| 0|
| 0|
+----------+
out.count()
res3: Long = 1
out.rdd.take(10)
res4: Array[org.apache.spark.sql.Row] = Array([1], [0], [0], [0], [0])
out.rdd.count()
res5: Long = 5
});