有没有办法可以在reduceByKey()函数中的pyspark中获取键的名称,这样我才能得到传递给reduceByKey()函数的两个值之间的共同键?
例如:
inside reduceByKey(combineValues) where
def combineValues(a,b):
//can i get the key value common to both a and b here ??
return a+b;
答案 0 :(得分:1)
你可以在RDD上使用aggregate
函数,但是你失去了HashPartitioner的好处,所以如果重要的话,我建议你把密钥存储在你的值中。