Main Content

execute

Execute event stream processing function on specific number of event windows

    This function requires Streaming Data Framework for MATLAB® Production Server™.

    Description

    example

    execute(esp,n) runs the streaming processing function specified in the Name property of processing object esp synchronously on n event windows.

    The execute function starts processing event windows at the current read position of the stream. Each event window is adjacent to the previous window, with no gaps between windows. To change the starting position of the entire sequence, call seek before calling execute.

    The first call to execute reads events from the position in the data stream where the read position was when esp was constructed. On subsequent calls to execute, the read position is set to Current. To change this behavior, call seek before execute.

    Examples

    collapse all

    Assume that you have a Kafka® server running at the network address kafka.host.com:9092 that has a topic RecamanSequence.

    Create an object connected to the RecamanSequence topic.

    ks = kafkaStream("kafka.host.com", 9092, "RecamanSequence");

    Assume that you have a streaming analytic function recamanSum and a function to initialize persistent state called initRecamanSum.

    Create an EventStreamProcessor object that runs the recamanSum function and initializes persistent state with the initRecamanSum function.

    esp = eventStreamProcessor(ks,@recamanSum, @initRecamanSum);
    esp = 
    
      EventStreamProcessor with properties:
    
          StreamFunction: @recamanSum
             InputStream: [1×1 matlab.io.stream.event.KafkaStream]
            OutputStream: [1×1 matlab.io.stream.event.InMemoryStream]
            InitialState: @initRecamanSum
           GroupVariable: [0×0 string]
            ReadPosition: Beginning
             ArchiveName: "recamanSum"
        ResetStateOnSeek: 1

    Iterate over the streaming analytic function ten times.

    execute(esp,10);

    Move the read position indicator to the beginning of the default output data stream.

    seek(esp.OutputStream,"Beginning");

    Examine the results.

    result = readtimetable(esp.OutputStream)

    Input Arguments

    collapse all

    Object to process event streams, specified as an EventStreamProcessor object.

    Number of event windows, specified as a positive integer.

    Version History

    Introduced in R2022b