任何人都可以在Spark的背景下解释细粒度转换与粗粒度转换之间的区别吗?我正在阅读有关RDD的论文(https://www.cs.berkeley.edu/~matei/papers/2012/nsdi_spark.pdf),并且不太清楚粗略转换如何以有效的方式提供容错.
我在Hive中有一个包含5列的表,即email,a_first_date,b_first_date,c_first_date,d_first_date.
a,b,c,d是用户可以采取的4种不同动作,上表中的4列表示用户进行第一次相应动作的日期.例如,'a_first_date'中的值具有用户执行操作a的日期.
输出:我想要的是2列电子邮件,overall_first_date,即用户第一次行动的日期?
示例表:(假设所有值都是除电子邮件之外的BIGINT类型)
email,a_first_date,b_first_date,c_first_date,d_first_date
abc,20140707,20140702,20140801,20140907
xyz,20140107,20140822,20140201,20141007
输出:
email,overall_first_date
abc,20140702
xyz,20140107
可能的几个解决方案是编写UDF或使用IF ELSE将这些值相互比较,然后找到最小值,但这将涉及大量的比较.
或者我可以做一个:
select email, min(action) as overall_first_date from
(
select email, a_first_date as action from mytable
UNION ALL
select email, b_first_date as action from mytable
UNION ALL
select email, c_first_date as action from mytable
UNION ALL
select email, d_first_date as action from mytable
) q1
GROUP BY email
Run Code Online (Sandbox Code Playgroud)
但这又不是一个好方法.
有人可以建议一个更好的方法来实现这一目标吗?