Class Utils
java.lang.Object
com.scaleoutsoftware.collections.timewindowing.Utils
Helper functions used within the library.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidaddTimeOrdered(List<T> source, TimestampSelector<T> selector, T toAdd) Adds an item to the parameter source collection in chronological order.static <T> voidperformEviction(List<T> sourceCollection, TimestampSelector<T> timestampSelector, long removeBeforeMs) Removes items from the parameter source collection that have timestamps before the start timestatic <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.
-
Method Details
-
addTimeOrdered
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 collectionselector- the timestamp selector used to pull a timestamp from an itemtoAdd- 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 collectiontimestampSelector- the timestamp selector used to pull a timestamp from an itemremoveBeforeMs- 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)
-