flink join上的丰富函数,scala api

n6lpvg4x  于 2021-06-26  发布在  Flink
关注(0)|答案(1)|浏览(255)

我在和Flink和斯卡拉斗争。
我有一个连接变换 DataSet 这很管用,但我想把它变成一个 RichFuntion ,以便访问广播集:

val newBoard: DataSet[Cell] = board.rightOuterJoin(neighbours)
                             .where("coords").equalTo("cellCoords"){

    (cell, neighbours) => {
            // Do some rich function things, like 
            // override the open method so I can get
            // the broadcasted set
    }

  }

}.withBroadcastSet(board, "aliveCells")

我看了所有的文件,但我找不到任何例子 RichJoinFuntion 在scala中使用。我只找到在中使用的丰富函数的例子 map 或者 filter ,但对于 join 转换(括号之间的函数与括号之间的函数)。

rbl8hiat

rbl8hiat1#

你可以使用 RichJoinFunction 使用scala数据集api,如下所示

val newBoard: DataSet[Cell] = board.rightOuterJoin(neighbours)
                             .where("coords").equalTo("cellCoords")
                               .apply(new YourJoinFunction())
                               .withBroadcastSet(board, "aliveCells")

class YourJoinFunction extends RichJoinFunction[IN1, IN2, Cell] {
  override def join(first: IN1, second: IN2): Cell = {
    // Do some rich function things, like 
    // override the open method so I can get
    // the broadcasted set
  }
}

相关问题