我正在尝试实现ApacheFlink-broadcasting。。我们如何使用java实现数据集的广播。请帮忙。
y53ybaqx1#
《flink dataset api编程指南》提供了有关如何在java中广播数据集的示例:
// 1. The DataSet to be broadcasted DataSet<Integer> toBroadcast = env.fromElements(1, 2, 3); DataSet<String> data = env.fromElements("a", "b"); data.map(new RichMapFunction<String, String>() { @Override public void open(Configuration parameters) throws Exception { // 3. Access the broadcasted DataSet as a Collection Collection<Integer> broadcastSet = getRuntimeContext().getBroadcastVariable("broadcastSetName"); } @Override public String map(String value) throws Exception { ... } }).withBroadcastSet(toBroadcast, "broadcastSetName"); // 2. Broadcast the DataSet
1条答案
按热度按时间y53ybaqx1#
《flink dataset api编程指南》提供了有关如何在java中广播数据集的示例: