You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by 邓俊华 <de...@startdt.com> on 2018/01/15 02:29:50 UTC

回复:How can I count the element in datastream

Yes, I want count all the elements. But I can't do cumulative.eg:   distinctOrder.map(new MapFunction<Order, Object>() {

    @Override
    public Object map(Order value) throws Exception {
       
        return null;
    }
}).setParallelism(1).print();

------------------------------------------------------------------发件人:Tzu-Li (Gordon) Tai <tz...@apache.org>发送时间:2018年1月12日(星期五) 22:37收件人:user <us...@flink.apache.org>主 题:Re: How can I count the element in datastream
Hi!

Do you mean that you want to count all elements across all partitions of a
DataStream?
To do that, you'll need to transform the DataStream with an operator of
parallelism 1, e.g.

DatatStream<String> stream = ...;
stream.map(new CountingMap<>()).setParallelism(1);

Cheers,
Gordon



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/