com.ibm.streams.operator.window.sort
Class TumblingWindowSort
- java.lang.Object
-
- com.ibm.streams.operator.window.StatefulWindowListener<java.util.List<Tuple>,Tuple>
-
- com.ibm.streams.operator.window.sort.SortedTupleWindow
-
- com.ibm.streams.operator.window.sort.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.
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.String
IBM_COPYRIGHT
-
Constructor Summary
Constructors Constructor and Description 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.
-
Method Summary
Methods Modifier and Type Method and Description void
handleEvent(StreamWindowEvent<Tuple> event)
Handle a TUMBLING window events.protected boolean
supportsWindow()
Only support a TUMBLING window.-
Methods inherited from class com.ibm.streams.operator.window.sort.SortedTupleWindow
getInitializedState
-
Methods inherited from class com.ibm.streams.operator.window.StatefulWindowListener
checkpoint, close, drain, evictionsOccurred, getPartitionState, getWindow, insertionsOccurred, reset, resetToInitialState, retireCheckpoint, seenInitialFull
-
-
-
-
Field Detail
-
IBM_COPYRIGHT
public static final java.lang.String IBM_COPYRIGHT
- See Also:
- Constant Field Values
-
-
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
-
supportsWindow
protected boolean supportsWindow()
Only support a TUMBLING window.- Overrides:
supportsWindow
in classStatefulWindowListener<java.util.List<Tuple>,Tuple>
- Returns:
- True.
-
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 eventssuper.handleEvent(event)
is called to allowSortedTupleWindow
to maintain its state (including sorting of tuples on INSERTION) correctly.- Specified by:
handleEvent
in interfaceStreamWindowListener<Tuple>
- Overrides:
handleEvent
in classSortedTupleWindow
- Parameters:
event
- Windowing event.- Throws:
java.lang.Exception
- Exception processing an event.
-
-