Class StreamMiningAlgorithm<T extends Response>

  • All Implemented Interfaces:
    Serializable, org.apache.flink.api.common.functions.FlatMapFunction<BEvent,​T>, org.apache.flink.api.common.functions.Function, org.apache.flink.api.common.functions.RichFunction
    Direct Known Subclasses:
    InfiniteSizeDirectlyFollowsMapper

    public abstract class StreamMiningAlgorithm<T extends Response>
    extends org.apache.flink.api.common.functions.RichFlatMapFunction<BEvent,​T>
    This abstract class defines the root of the mining algorithms hierarchy. It is a RichFlatMapFunction of elements with type BEvent that is capable of producing responses of type Response.

    Since this map is actually "rich" this means that classes that extends this one can have access to the state of the operator and use it in a distributed fashion. Additionally, being this map a "flat" it might return 0 or 1 results for each event being consumed.

    Author:
    Andrea Burattin
    See Also:
    Serialized Form
    • Constructor Detail

      • StreamMiningAlgorithm

        public StreamMiningAlgorithm()
    • Method Detail

      • open

        public void open​(org.apache.flink.configuration.Configuration parameters)
                  throws Exception
        Specified by:
        open in interface org.apache.flink.api.common.functions.RichFunction
        Overrides:
        open in class org.apache.flink.api.common.functions.AbstractRichFunction
        Throws:
        Exception
      • flatMap

        public void flatMap​(BEvent event,
                            org.apache.flink.util.Collector<T> out)
                     throws Exception
        Specified by:
        flatMap in interface org.apache.flink.api.common.functions.FlatMapFunction<BEvent,​T extends Response>
        Specified by:
        flatMap in class org.apache.flink.api.common.functions.RichFlatMapFunction<BEvent,​T extends Response>
        Throws:
        Exception
      • ingest

        public abstract T ingest​(BEvent event)
        This abstract method is what each derive class is expected to implement. The argument of the method is the new observation and the returned value is the result of the mining.

        If this method returns value null, then the value is not moved forward into the pipeline.

        Parameters:
        event - the new event being observed
        Returns:
        the result of the mining of the event, or null if nothing should go through the rest of the pipeline
      • getProcessedEvents

        public long getProcessedEvents()
        Returns the total number of events processed so far
        Returns:
        the total number of events processed so far
      • process

        protected T process​(BEvent event)