开发者社区> 问答> 正文

Apache Flink:运营商状态检查点

"我想使用Operator State APIin No-Keyed Stream来保存count下面示例中的状态。我该怎么办?

public static class MapFunction implements MapFunction,CheckpointedFunction{

int count = 0;
@Override
public String map(String value) throws Exception {
    // TODO Auto-generated method stub
        String message;
        message = value;
        count++;
        return message;
}

@Override
public void snapshotState(FunctionSnapshotContext context) throws Exception {
    // TODO Auto-generated method stub
}

@Override
public void initializeState(FunctionInitializationContext context) throws Exception {
    // TODO Auto-generated method stub
}

}"

展开
收起
flink小助手 2018-11-28 16:09:35 1349 0
1 条回答
写回答
取消 提交回答
  • flink小助手会定期更新直播回顾等资料和文章干货,还整合了大家在钉群提出的有关flink的问题及回答。

    "正如Dawid指出的那样,文档是一个很好的起点。最简单的方法是实现ListCheckpointed接口。当snapshotState()被调用时,你会回到你的单列表count(作为Integer)。当restoreState()被调用时,你会遍历列表中Integer值,总结他们设定的count变量。
    "

    2019-07-17 23:16:49
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Flink CDC Meetup PPT - 龚中强 立即下载
Flink CDC Meetup PPT - 王赫 立即下载
Flink CDC Meetup PPT - 覃立辉 立即下载

相关镜像