Google 数据流上基于会话的窗口中使用的密钥是什么

What is the key used in Session based windowing on Google dataflow

我是数据流的新手。我在 google 文档中看到了这个例子。

PCollection<String> items = ...;
  PCollection<String> session_windowed_items = items.apply(
    Window.<String>into(Sessions.withGapDuration(Duration.standardMinutes(10))));

1) 在上面的例子中,dataflow 用来创建 windows 的键是什么?

2) 如果我的输入源是 pubsub,我应该设置任何消息属性吗?当我们使用基于会话的窗口时,我们如何指定应该使用的关键数据流。

Window.into 之后的第一个分组操作中将元素分配给会话。任何影响 GroupByKeyCombine.perKeySum.perKeyCoGroupByKey 等操作的键都将成为分组键。

您不需要设置消息属性来指定密钥。相反,您将编写一个 ParDo 将现有元素转换为 KV<K, V> 值,并且那里的键将从中派生。

您可能需要阅读 about group-by-key for 了解更多信息。