本例子是根据某个字段作为key,然后将记录合并为list集合。

 

        type myType = (String,Double)
        val goodsTradeRankRdd = goodsTradeRankDF.rdd.map(item => {
            val tenantId = item.getAs[String]("tenantId")
            val spuId = item.getAs[String]("spuId")
            val totalQty = item.getAs[Double]("totalQty")
            (tenantId,score(spuId,totalQty))
        }).combineByKey(
            List(_),
            (c:List[score],v) => v::c,
            (c1:List[score],c2:List[score]) => c1:::c2
        ).map(x => goodsTradeRank(x._1,x._2))

 

相关文章:

  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2021-11-28
  • 2021-10-10
  • 2021-09-22
猜你喜欢
  • 2021-10-11
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2022-01-04
  • 2022-12-23
相关资源
相似解决方案