com.ibm.streams.operator.window.sort

Class TumblingWindowSort

  • All Implemented Interfaces:
    StateHandler, StreamWindowListener<Tuple>, java.io.Closeable, java.lang.AutoCloseable, java.util.EventListener


    public final class TumblingWindowSort
    extends SortedTupleWindow
    Implement a tuple window sort for a tumbling window. When the window tumbles if it contained one or more tuples then the tuples are submitted to the output port in sorted order. Any tuples left in the window when a final punctuation mark is received are optionally submitted in sorted order to the output port.

    This class supports partitioned and non-partitioned windows.

    • Constructor Detail

      • TumblingWindowSort

        public TumblingWindowSort(StreamWindow<Tuple> window,
                          boolean ascending,
                          java.util.List<java.lang.String> attributeNames,
                          StreamingOutput<?> outputPort,
                          boolean flushOnFinal)
        Creates and registers a listener for the window.
        Parameters:
        window - Window description for input port.
        ascending - True if the sort is to be in ascending order.
        attributeNames - Attributes to be sorted listed in order of significance, with most significant first.
        outputPort - Output port to submit sorted tuples on.
        flushOnFinal - True if tuples remaining in the window are to be submitted when a final punctuation mark is received. False if remaining tuples are to be discarded.
    • Method Detail

      • handleEvent

        public void handleEvent(StreamWindowEvent<Tuple> event)
                         throws java.lang.Exception
        Handle a TUMBLING window events.
        For a EVICTION event, all tuples in the window are submitted to the output port in sorted order,, followed by a WINDOW_MARKER.
        For the FINAL, if flushOnFinal is true then all remaining tuples in the window are are submitted to the output port in sorted order, followed by a WINDOW_MARKER, otherwise no action is taken.
        If no tuples are present in the window at the EVICTION or FINAL events then no WINDOW_MARKER is sent to the output port.
        After this class's handling of the events super.handleEvent(event) is called to allow SortedTupleWindow to maintain its state (including sorting of tuples on INSERTION) correctly.
        Specified by:
        handleEvent in interface StreamWindowListener<Tuple>
        Overrides:
        handleEvent in class SortedTupleWindow
        Parameters:
        event - Windowing event.
        Throws:
        java.lang.Exception - Exception processing an event.