org.apache.ignite.streamer.window

## Class StreamerBoundedSizeSortedWindow<E>

- java.lang.Object
- - org.apache.ignite.streamer.window.StreamerWindowAdapter<E>
  - - org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow<E>

All Implemented Interfaces:
  Iterable<E>, LifecycleAware, StreamerWindow<E>, StreamerWindowMBean

    public class StreamerBoundedSizeSortedWindow<E>
    extends StreamerWindowAdapter<E>

Size-bounded sorted window. Unlike `StreamerBoundedSizeWindow`, which limits window only on size, this window also provides events in sorted order.

### Field Summary

Fields
`protected int` `maxSize` Window maximum size.

### Constructor Summary

Constructors
Constructor and Description
`StreamerBoundedSizeSortedWindow()`

### Method Summary

Methods
`protected int` `addAllInternal(Collection<E> evts, Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> col, Set<E> set)` Adds all events to queue implementation.
`protected boolean` `addInternal(E evt, Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> col, Set<E> set)` Adds event to queue implementation.
`void` `checkConfiguration()` Check window configuration.
`protected Collection<T>` `collection()` Get underlying collection.
`protected void` `consistencyCheck(Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> col, Set<E> set, AtomicInteger size)` Checks consistency.
`protected Collection<E>` `dequeue0(int cnt)` Dequeues up to cnt elements from window.
`protected boolean` `enqueue0(E evt)` Adds event to window.
`int` `evictionQueueSize()` Gets number of entries available for eviction.
`Comparator<E>` `getComparator()` Gets event comparator.
`int` `getMaximumSize()` Gets window maximum size.
`boolean` `isUnique()`
`protected GridStreamerWindowIterator<E>` `iterator0()` Returns an iterator over a set of elements of type T without check for iteration limit.
`protected GridStreamerWindowIterator<E>` `iteratorInternal(Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> col, Set<E> set, AtomicInteger size)` Creates iterator based on implementation collection type.
`protected Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>>` `newCollection()` Creates new collection specific for window implementation.
`protected Collection<E>` `pollEvicted0(int cnt)` If window supports eviction, this method will return up to cnt evicted elements.
`protected Collection<E>` `pollEvictedBatch0()` If window supports batch eviction, this method will poll next evicted batch from window.
`protected E` `pollInternal(Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> col, Set<E> set)`
`protected void` `reset0()` Reset routine.
`void` `setComparator(Comparator<E> comp)` Sets event comparator.
`void` `setMaximumSize(int maxSize)` Sets window maximum size.
`void` `setUnique(boolean unique)`
`int` `size()` Gets number of events currently stored in window.
`protected void` `stop0()` Dispose window.

### Methods inherited from class org.apache.ignite.streamer.window.StreamerWindowAdapter

`clearEvicted, dequeue, dequeue, dequeueAll, enqueue, enqueue, enqueueAll, getClassName, getEvictionQueueSize, getFilter, getName, getSize, index, index, indexes, indexProviders, iterator, name, pollEvicted, pollEvicted, pollEvictedAll, pollEvictedBatch, reset, setFilter, setIndexes, setName, snapshot, start, stop, updateIndexes`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### maxSize

    protected int maxSize

Window maximum size.

### Constructor Detail

#### StreamerBoundedSizeSortedWindow

    public StreamerBoundedSizeSortedWindow()

### Method Detail

#### getComparator

    public Comparator<E> getComparator()

Gets event comparator.

Returns:
  Event comparator.

#### setComparator

    public void setComparator(Comparator<E> comp)

Sets event comparator.

Parameters:
  `comp` - Comparator.

#### newCollection

    protected Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> newCollection()

Creates new collection specific for window implementation. This collection will be subsequently passed to addInternal(...) and pollInternal() methods.

Returns:
  Collection - holder.

#### addInternal

    protected boolean addInternal(E evt,
                      Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> col,
                      @Nullable
                      Set<E> set)

Adds event to queue implementation.

Parameters:
  `evt` - Event to add.
  `col` - Collection to add to.
  `set` - Set to check.
Returns:
  `True` if event was added.

#### addAllInternal

    protected int addAllInternal(Collection<E> evts,
                     Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> col,
                     @Nullable
                     Set<E> set)

Adds all events to queue implementation.

Parameters:
  `evts` - Events to add.
  `col` - Collection to add to.
  `set` - Set to check.
Returns:
  Added events number.

#### pollInternal

    protected E pollInternal(Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> col,
                 Set<E> set)

Parameters:
  `col` - Collection to add to.
  `set` - Set to check.
Returns:
  Polled object.

#### iteratorInternal

    protected GridStreamerWindowIterator<E> iteratorInternal(Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> col,
                                                 Set<E> set,
                                                 AtomicInteger size)

Creates iterator based on implementation collection type.

Parameters:
  `col` - Collection.
  `set` - Set to check.
  `size` - Size.
Returns:
  Iterator.

#### consistencyCheck

    protected void consistencyCheck(Collection<org.apache.ignite.streamer.window.StreamerBoundedSizeSortedWindow.Holder<E>> col,
                        Set<E> set,
                        AtomicInteger size)

Checks consistency. Used in tests.

Parameters:
  `col` - Collection.
  `set` - Set if unique.
  `size` - Size holder.

#### getMaximumSize

    public int getMaximumSize()

Gets window maximum size.

Returns:
  Maximum size.

#### setMaximumSize

    public void setMaximumSize(int maxSize)

Sets window maximum size.

Parameters:
  `maxSize` - Maximum size.

#### isUnique

    public boolean isUnique()

Returns:
  True if only unique elements will be accepted.

#### setUnique

    public void setUnique(boolean unique)

Parameters:
  `unique` - If true, only unique elements will be accepted.

#### checkConfiguration

    public void checkConfiguration()

Check window configuration.

Specified by:
  `checkConfiguration` in class `StreamerWindowAdapter<E>`

#### stop0

    protected void stop0()

Dispose window.

Specified by:
  `stop0` in class `StreamerWindowAdapter<E>`

#### size

    public int size()

Gets number of events currently stored in window.

Returns:
  Current size of the window.

#### evictionQueueSize

    public int evictionQueueSize()

Gets number of entries available for eviction.

Returns:
  Number of entries available for eviction.

#### enqueue0

    protected boolean enqueue0(E evt)

Adds event to window.

Specified by:
  `enqueue0` in class `StreamerWindowAdapter<E>`
Parameters:
  `evt` - Event.
Returns:
  `True` if event added.

#### pollEvicted0

    protected Collection<E> pollEvicted0(int cnt)

If window supports eviction, this method will return up to cnt evicted elements.

Specified by:
  `pollEvicted0` in class `StreamerWindowAdapter<E>`
Parameters:
  `cnt` - Count.
Returns:
  Evicted elements.

#### pollEvictedBatch0

    protected Collection<E> pollEvictedBatch0()

If window supports batch eviction, this method will poll next evicted batch from window. If windows does not support batch eviction but supports eviction, will return collection of single last evicted element. If window does not support eviction, will return empty collection.

Specified by:
  `pollEvictedBatch0` in class `StreamerWindowAdapter<E>`
Returns:
  Elements from evicted batch.

#### dequeue0

    protected Collection<E> dequeue0(int cnt)

Dequeues up to cnt elements from window. If current window size is less than cnt, will dequeue all elements from window.

Specified by:
  `dequeue0` in class `StreamerWindowAdapter<E>`
Parameters:
  `cnt` - Count.
Returns:
  Dequeued elements.

#### iterator0

    protected GridStreamerWindowIterator<E> iterator0()

Returns an iterator over a set of elements of type T without check for iteration limit. That is, in case concurrent thread constantly adding new elements to the window we could iterate forever.

Specified by:
  `iterator0` in class `StreamerWindowAdapter<E>`
Returns:
  Iterator.

#### reset0

    protected void reset0()

Reset routine.

Specified by:
  `reset0` in class `StreamerWindowAdapter<E>`

#### collection

    protected Collection<T> collection()

Get underlying collection.

Returns:
  Collection.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015