Stream 如何在Trident中映射具有持久状态的元组?

Stream 如何在Trident中映射具有持久状态的元组?,stream,state,apache-storm,trident,Stream,State,Apache Storm,Trident,我正在学习框架。Trident上有几种方法用于在批处理中聚合元组,其中包括允许使用接口预执行元组的有状态映射。但不幸的是,与其他9个重载的persistentAggregate()一样,只使用聚合器作为参数的另一个内置副本来保存映射状态,却不存在 因此,如何通过结合较低级别的Trident和Storm抽象和工具来实现所需的功能?探索API非常困难,因为几乎没有Javadoc文档 换句话说,persistentAggregate()方法允许通过更新某些持久状态来结束流处理: stream of t

我正在学习框架。Trident上有几种方法用于在批处理中聚合元组,其中包括允许使用接口预执行元组的有状态映射。但不幸的是,与其他9个重载的
persistentAggregate()
一样,只使用
聚合器作为参数的另一个内置副本来保存映射状态,却不存在

因此,如何通过结合较低级别的Trident和Storm抽象和工具来实现所需的功能?探索API非常困难,因为几乎没有Javadoc文档

换句话说,
persistentAggregate()
方法允许通过更新某些持久状态来结束流处理:

stream of tuples ---> persistent state
我想更新持久状态并发出不同的元组:

stream of tuples ------> stream of different tuples
                  with
            persistent state
Stream.aggregate(字段、聚合器、字段)
不提供容错:

stream of tuples ------> stream of different tuples
                  with
          simple in-memory state

可以使用该方法从状态创建新流。 这将允许您检索聚合值流

出于说明目的,我们可以通过添加此方法和调试过滤器来改进:

FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
    new Values("the cow jumped over the moon"),
    new Values("the man went to the store and bought some candy"),
    new Values("four score and seven years ago"),
    new Values("how many apples can you eat"));
spout.setCycle(true);

TridentTopology topology = new TridentTopology();        
topology.newStream("spout1", spout)
    .each(new Fields("sentence"), new Split(), new Fields("word"))
    .groupBy(new Fields("word"))
    .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))                
    .newValuesStream().each(new Fields("count"), new Debug());
运行此拓扑将(向控制台)输出聚合计数


希望能有所帮助

请您详细说明一下。你的问题不是clear@GlobalWarrior请参阅问题Update您是否可以使用同一组元组发布两个单独的流?其中一个保持状态,而另一个执行您想要的修改。@GlobalWarrior映射是有状态的。要生成一个新的元组,我需要知道当前状态,不需要聚合计数流。我想有状态地转换值流。方法解决了这个问题,但聚合器类不支持持久性。如果我理解,您希望根据以前的状态转换元组,然后更新状态并发出转换后的元组。你能确认吗?根据目前的状态。简单地说,我会对聚合器的持久化实现感到满意,但由于它不存在(至少在标准的Storm发行版中),我正在寻找不同的方法。您是否尝试过使用
stateQuery()