Beam/Dataflow 2.2.0-从pcollection中提取前n个元素 [英] Beam/Dataflow 2.2.0 - extract first n elements from pcollection
本文介绍了Beam/Dataflow 2.2.0-从pcollection中提取前n个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以提取光束集合中的前n个元素?该文档似乎并未指示任何此类功能.我认为这样的操作首先需要分配全局元素编号,然后需要过滤器-拥有此功能会很不错.
Is there any way to extract first n elements in a beam pcollection? The documentation doesn't seem to indicate any such function. I think such an operation would require first a global element number assignment and then a filter - would be nice to have this functionality.
我使用Google DataFlow Java SDK 2.2.0
.
推荐答案
PCollection本身是无序的,因此不存在前N个元素"的概念-但是:
PCollection's are unordered per se, so the notion of "first N elements" does not exist - however:
-
如果根据某些条件需要前N个元素,则可以使用如果需要N个元素,则可以使用
In case you need any N elements, you can use Sample.
这篇关于Beam/Dataflow 2.2.0-从pcollection中提取前n个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文