java.lang.Object
com.scaleoutsoftware.collections.timewindowing.Utils

public class Utils extends Object
Helper functions used within the library.
  • Method Details

    • addTimeOrdered

      public static <T> void addTimeOrdered(List<T> source, TimestampSelector<T> selector, T toAdd)
      Adds an item to the parameter source collection in chronological order.
      Type Parameters:
      T - the type of items in the source collection
      Parameters:
      source - the source collection
      selector - the timestamp selector used to pull a timestamp from an item
      toAdd - the item to add
    • performEviction

      public static <T> void performEviction(List<T> sourceCollection, TimestampSelector<T> timestampSelector, long removeBeforeMs)
      Removes items from the parameter source collection that have timestamps before the start time
      Type Parameters:
      T - the type of the items in the source collection
      Parameters:
      sourceCollection - the source collection
      timestampSelector - the timestamp selector used to pull a timestamp from an item
      removeBeforeMs - the timestamp for eviction for the collection -- items before this timestamp are removed.
    • performWatermarkedWindowedEviction

      public static <T> EvictionMetadata<T> performWatermarkedWindowedEviction(List<T> sourceCollection, TimestampSelector<T> timestampSelector, long watermarkMs, long windowSizeMs, long everyMs, long nextWindowStartTimeMs)
      Removes items from the parameter source collection that have timestamps before the watermark. Windows whose inclusive end have passed the watermark are closed and returned as part of the eviction metadata. Windows have inclusive starts and inclusive ends.
      Type Parameters:
      T - the type of the items in the source collection
      Parameters:
      sourceCollection - the source collection.
      timestampSelector - the user's timestamp selector callback.
      watermarkMs - the calling collections watermark in milliseconds.
      windowSizeMs - the window size in milliseconds.
      everyMs - how frequently a window occurs in milliseconds.
      nextWindowStartTimeMs - the next windows start time in milliseconds. First time callers should pass the source collections start time.
      Returns:
      the nextWindowStartTimeMs. This should be saved and reused when calling performWatermarkedWindowedEviction(List, TimestampSelector, long, long, long, long)