Package deltix.data.stream
Class BufferedStreamSorter<T extends deltix.data.stream.TimeStampedMessage>
- java.lang.Object
-
- deltix.data.stream.BufferedStreamSorter<T>
-
- All Implemented Interfaces:
deltix.data.stream.MessageChannel<T>,deltix.util.lang.Disposable,java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
BufferedStreamSorterEx
public class BufferedStreamSorter<T extends deltix.data.stream.TimeStampedMessage> extends java.lang.Object implements deltix.data.stream.MessageChannel<T>This class enables the sorting of messages in situations when an upper bound can be placed on how badly unsorted the messages are. This class will successfully sort a "slightly unordered" stream of messages, as long as no message is older than any preceding message by more than a specified time interval, called buffer width.
-
-
Constructor Summary
Constructors Constructor Description BufferedStreamSorter(deltix.data.stream.MessageChannel<T> delegate, long width)Creates a message sorter with a small starting capacity.BufferedStreamSorter(deltix.data.stream.MessageChannel<T> delegate, long width, int capacity)Creates a message sorter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()deltix.data.stream.MessageChannel<T>getDelegate()longgetMaxTime()longgetMaxViolation()intgetQueueSize()longgetWidth()voidsend(T msg)This method takes ownership of the supplied object.
-
-
-
Constructor Detail
-
BufferedStreamSorter
public BufferedStreamSorter(deltix.data.stream.MessageChannel<T> delegate, long width, int capacity)
Creates a message sorter.- Parameters:
delegate- The channel that will receive sorted messages.width- Buffer width in milliseconds.capacity- Initial buffer capacity in messages.
-
BufferedStreamSorter
public BufferedStreamSorter(deltix.data.stream.MessageChannel<T> delegate, long width)
Creates a message sorter with a small starting capacity.- Parameters:
delegate- The channel that will receive sorted messages.width- Buffer width BufferedStreamSorter in milliseconds.
-
-
Method Detail
-
send
public void send(T msg)
This method takes ownership of the supplied object. Therefore, the supplied message object may not be reused by the caller.- Specified by:
sendin interfacedeltix.data.stream.MessageChannel<T extends deltix.data.stream.TimeStampedMessage>- Parameters:
msg- A message to buffer and eventually send down the delegate channel.- Throws:
java.lang.IllegalArgumentException- When the new message is older than last flushed message, which can happen if the set queue width is too small.
-
getDelegate
public deltix.data.stream.MessageChannel<T> getDelegate()
-
getMaxTime
public long getMaxTime()
-
getMaxViolation
public long getMaxViolation()
-
getWidth
public long getWidth()
-
getQueueSize
public int getQueueSize()
-
flush
public void flush()
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfacedeltix.util.lang.Disposable
-
-