You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by caozhen <ca...@163.com> on 2020/10/12 12:00:04 UTC

Re: 关于stream注册成表的数据存储时长问题

我理解:

对于print,map 等无状态操作,不存储数据。
对于window 这种有状态操作,只存储窗口内的数据。
对于groupby 这种有状态操作,随着key越多,存储的数据越多,默认不清理,可以配置清理策略。

-------


&nbsp; &nbsp; 我的数据是接的kafka数据源,接到数据后注册成表,我想知道通过这种方式创建的表,表里的数据会一直追加吗?
是否会一直存在导致占用内存越来越大的问题???如何清理过期数据???


注册表代码如下:
//获取订单回调kafka数据
DataStreamSource<String&amp;gt; dataStreamSource =
KafkaConfigUtil.buildKafka(env).setParallelism(1);

//订单数据展开成所需数据格式
SingleOutputStreamOperator&lt;OrderDetail&amp;gt; orderDetails =
dataStreamSource.flatMap(new OrderSplitService())
        .setParallelism(parameterTool.getInt(STREAM_PARALLELISM, 5));
//过滤
SingleOutputStreamOperator&lt;OrderDetail&amp;gt; simpleResults =
orderDetails.flatMap(new OrderDetailFilterService())
        .setParallelism(parameterTool.getInt(STREAM_PARALLELISM, 5));

Table orderDetailTable = tableEnv.fromDataStream(simpleResults,       
$(&quot;orderNo&quot;),
$(&quot;memberId&quot;),$(&quot;merchantId&quot;),$(&quot;storeId&quot;),$(&quot;internalId&quot;),$(&quot;type&quot;),
       
$(&quot;quantity&quot;),$(&quot;unitPrice&quot;),$(&quot;gmtPaidLong&quot;),$(&quot;gmtPaid&quot;),$(&quot;gmtPaidTimeStamp&quot;),$(&quot;userActionTime&quot;).proctime());注册后的表内数据,试过打印,但是每次接到一次kafka只会打印一条数据。后续还需要用这个表的数据做滑动窗口。
&lt;/quote>




--
Sent from: http://apache-flink.147419.n8.nabble.com/