Class WindowingCollection<T>

java.lang.Object
com.scaleoutsoftware.collections.timewindowing.WindowingCollection<T>
Type Parameters:
T - the object type of the source collection.
All Implemented Interfaces:
Iterable<TimeWindow<T>>
Direct Known Subclasses:
SessionWindowCollection, SlidingWindowCollection, TumblingWindowCollection

public abstract class WindowingCollection<T> extends Object implements Iterable<TimeWindow<T>>
Used to transform a List into an iterable collection of TimeWindow. Items whose timestamp precede the collections start time are evicted from the collection.
  • Field Details

    • _sourceCollection

      public List<T> _sourceCollection
      The source collection of items for a windowing collection.
    • _timestampSelector

      public TimestampSelector<T> _timestampSelector
      The timestamp selector is used to select a timestamp from an element in the source collection.
    • _startTimeMs

      public long _startTimeMs
      The inclusive start time of first window of a windowing collection.
  • Constructor Details

    • WindowingCollection

      public WindowingCollection(List<T> sourceCollection, TimestampSelector<T> timestampSelector, long startTimeMs)
      Instantiate a new WindowingCollection.
      Parameters:
      sourceCollection - the underlying source collection
      timestampSelector - the TimestampSelector is used to pull a timestamp from an item in the source collection and subsequent insertions.
      startTimeMs - the first time an object can be in a time window -- items before the start time will be evicted. The start time is also the start time of the first time window.
  • Method Details

    • add

      public void add(T item)
      Adds an item to the underlying source collection in chronological order.
      Parameters:
      item - the item to add.