在 hadoop 环境中,SortValues 是否仅在 运行 中转换 Java Beam 中的 SDK 扩展?

Does SortValues transform Java SDK extension in Beam only run in hadoop environment?

我已经在本地机器 (Windows)

上使用 DirectRunner 尝试了 SortValues 转换的示例代码
PCollection<KV<String, KV<String, Integer>>> input = ...

PCollection<KV<String, Iterable<KV<String, Integer>>>> grouped =
input.apply(GroupByKey.<String, KV<String, Integer>>create());

PCollection<KV<String, Iterable<KV<String, Integer>>>> groupedAndSorted =
grouped.apply(SortValues.<String, String, Integer>create(BufferedExternalSorter.options()));

但我收到错误 PipelineExecutionException: java.lang.NoClassDefFoundError: org/apache/hadoop/io/Writable。这是否意味着此转换功能仅适用于 Hadoop 环境?

从今天开始,如果您使用 Beam 的发布版本低于 2.0.0,则必须在您的 maven pom 文件中添加两个 hadoop 依赖项才能使该 SortValues 模块正常工作。

  1. 添加 hadoop-common 版本 2.7.3 或更高版本
  2. 添加 hadoop-mapreduce-client-core 版本 2.7.3 或更高版本。

否则,您只需使用发布版本 >= 2.0.0 的 Beam。