如何命名 Cloud Dataflow 管道中的 MapElements 步骤

How can I name a MapElements step in a Cloud Dataflow pipeline

dataflow docs 之后,我可以使用 ParDo.named:

命名 Google Cloud Dataflow 管道的每个步骤
PCollection<Integer> wordLengths = words.apply(
  ParDo
    .named("ComputeWordLengths")   // the transform name
    .of(new DoFn<String, Integer>() {
      @Override
      public void processElement(ProcessContext c) {
        c.output(c.element().length());
      }
    }));

但是,如果我改用 MapElements,文档中的示例不会命名该步骤:

PCollection<Integer> wordLengths = words.apply(
  MapElements.via((String word) -> word.length())
      .withOutputType(new TypeDescriptor<Integer>() {});

如何命名此 MapElements 步骤?

我有几个 MapElements 步骤,但我遇到了这样的错误:

Mar 01, 2016 1:36:39 PM com.google.cloud.dataflow.sdk.Pipeline applyInternal
WARNING: Transform MapElements2 does not have a stable unique name. This will prevent updating of pipelines.

您可以在应用时指定名称。例如:

words.apply("name", MapElements.via(...)) 
// instead of 
words.apply(MapElements.via(...))

有关详细信息,请参阅 named apply method 上的 JavaDoc。