獨特

Javadoc Javadoc


產生一個包含輸入集合中不同元素的集合。

在某些資料集中,使用 ApproximateUnique 計算近似答案可能會更有效率,這也允許確定每個鍵的不同值。

範例

範例 1:從 StringPCollection 中找出不同的元素。

static final String[] WORDS_ARRAY = new String[]{
            "hi", "hi", "sue",
            "sue",  "bob"
    };
static final List<String> WORDS = Arrays.asList(WORDS_ARRAY);

PCollection<String> input =
        pipeline.apply(Create.of(WORDS)).withCoder(StringUtf8Coder.of());

PCollection<String> distinctWords = input.apply(Distinct.create());

範例 2:從 IntegerPCollection 中找出不同的元素。