public class SlidingWindowToolkit
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
SlidingWindowToolkit.IOrderedWindowVisitor
|
static interface |
SlidingWindowToolkit.IUnorderedWindowValueFunction<V>
|
static interface |
SlidingWindowToolkit.IUnorderedWindowVisitor
|
Modifier and Type | Field and Description |
---|---|
private static java.util.Comparator<IQuantity> |
QUANTITY_COMPARATOR |
Constructor and Description |
---|
SlidingWindowToolkit() |
Modifier and Type | Method and Description |
---|---|
static void |
slidingWindowOrdered(SlidingWindowToolkit.IOrderedWindowVisitor callback,
java.util.Iterator<IItem> items,
IMemberAccessor<IQuantity,IItem> posAccessor,
IQuantity windowSize,
IQuantity slideSize)
Runs a sliding window through all items, looping through items once, removing from the start
and adding and the end of a windowItem set to match the current time window.
|
static void |
slidingWindowUnordered(SlidingWindowToolkit.IUnorderedWindowVisitor callback,
IItemCollection items,
IQuantity windowSize,
IQuantity slideSize)
Runs a sliding window through all items, by calculating the window start and end and filter
through all the items.
|
static void |
slidingWindowUnordered(SlidingWindowToolkit.IUnorderedWindowVisitor callback,
IItemCollection items,
IQuantity windowSize,
IQuantity slideSize,
boolean includeIntersecting)
Runs a sliding window through all items, by calculating the window start and end and filter
through all the items.
|
static Pair<IQuantity,IRange<IQuantity>> |
slidingWindowUnorderedMinMaxValue(IItemCollection items,
IQuantity windowSize,
java.util.concurrent.FutureTask<IResult> cancellationSupplier,
SlidingWindowToolkit.IUnorderedWindowValueFunction<IQuantity> valueFunction,
boolean max,
boolean includeIntersecting)
Calculates max/min window quantity value of items.
|
static <V> Pair<V,IRange<IQuantity>> |
slidingWindowUnorderedMinMaxValue(IItemCollection items,
IQuantity windowSize,
java.util.concurrent.FutureTask<IResult> cancellationSupplier,
SlidingWindowToolkit.IUnorderedWindowValueFunction<V> valueFunction,
java.util.Comparator<V> valueComparator,
boolean max,
boolean includeIntersecting)
Calculates max/min window value of items.
|
static Pair<IQuantity,IRange<IQuantity>> |
slidingWindowUnorderedMinMaxValue(IItemCollection items,
IQuantity windowSize,
IQuantity slideSize,
java.util.concurrent.FutureTask<IResult> cancellationSupplier,
SlidingWindowToolkit.IUnorderedWindowValueFunction<IQuantity> valueFunction,
boolean max,
boolean includeIntersecting)
Calculates max/min window quantity value of items.
|
static <V> Pair<V,IRange<IQuantity>> |
slidingWindowUnorderedMinMaxValue(IItemCollection items,
IQuantity windowSize,
IQuantity slideSize,
java.util.concurrent.FutureTask<IResult> cancellationSupplier,
SlidingWindowToolkit.IUnorderedWindowValueFunction<V> valueFunction,
java.util.Comparator<V> valueComparator,
boolean max,
boolean includeIntersecting)
Calculates max/min window value of items.
|
private static final java.util.Comparator<IQuantity> QUANTITY_COMPARATOR
public static void slidingWindowOrdered(SlidingWindowToolkit.IOrderedWindowVisitor callback, java.util.Iterator<IItem> items, IMemberAccessor<IQuantity,IItem> posAccessor, IQuantity windowSize, IQuantity slideSize)
Suitable if the items are guaranteed to be ordered.
callback
- method that can do calculations on the items in the windowitems
- input itemsposAccessor
- an accessor that should give a position value that is used with windowsSize and
slideSizewindowSize
- size for the sliding windowslideSize
- how big the slide should be, if slideSize is null
, it will slide one item
at a timepublic static void slidingWindowUnordered(SlidingWindowToolkit.IUnorderedWindowVisitor callback, IItemCollection items, IQuantity windowSize, IQuantity slideSize)
callback
- method that can do calculations on the items in the window.items
- input itemswindowSize
- size for the sliding windowslideSize
- how big the slide should bepublic static void slidingWindowUnordered(SlidingWindowToolkit.IUnorderedWindowVisitor callback, IItemCollection items, IQuantity windowSize, IQuantity slideSize, boolean includeIntersecting)
callback
- method that can do calculations on the items in the window.items
- input itemswindowSize
- size for the sliding windowslideSize
- how big the slide should beincludeIntersecting
- if the window filter should include events intersecting the window, or just those
with end time in the window. It's up to the caller to take this into account and
for example cap event duration to the window timespan.public static Pair<IQuantity,IRange<IQuantity>> slidingWindowUnorderedMinMaxValue(IItemCollection items, IQuantity windowSize, java.util.concurrent.FutureTask<IResult> cancellationSupplier, SlidingWindowToolkit.IUnorderedWindowValueFunction<IQuantity> valueFunction, boolean max, boolean includeIntersecting)
items
- items to use for evaluationwindowSize
- window sizecancellationSupplier
- if the evaluation should be cancelledvalueFunction
- provides the window value for itemsmax
- true to get the max value, false to get min valueincludeIntersecting
- true to include also intersecting items, false to only include contained items. If
set to true, it's up to the valueFunction to only use the duration events that is
actually included in the window.public static Pair<IQuantity,IRange<IQuantity>> slidingWindowUnorderedMinMaxValue(IItemCollection items, IQuantity windowSize, IQuantity slideSize, java.util.concurrent.FutureTask<IResult> cancellationSupplier, SlidingWindowToolkit.IUnorderedWindowValueFunction<IQuantity> valueFunction, boolean max, boolean includeIntersecting)
items
- items to use for evaluationwindowSize
- window sizeslideSize
- window slide sizecancellationSupplier
- if the evaluation should be cancelledvalueFunction
- provides the window value for itemsmax
- true to get the max value, false to get min valueincludeIntersecting
- true to include also intersecting items, false to only include contained items. If
set to true, it's up to the valueFunction to only use the duration events that is
actually included in the window.public static <V> Pair<V,IRange<IQuantity>> slidingWindowUnorderedMinMaxValue(IItemCollection items, IQuantity windowSize, java.util.concurrent.FutureTask<IResult> cancellationSupplier, SlidingWindowToolkit.IUnorderedWindowValueFunction<V> valueFunction, java.util.Comparator<V> valueComparator, boolean max, boolean includeIntersecting)
items
- items to use for evaluationwindowSize
- window sizecancellationSupplier
- if the evaluation should be cancelledvalueFunction
- provides the window value for itemsvalueComparator
- compares valuesmax
- true to get the max value, false to get min valueincludeIntersecting
- true to include also intersecting items, false to only include contained items. If
set to true, it's up to the valueFunction to only use the duration events that is
actually included in the window.public static <V> Pair<V,IRange<IQuantity>> slidingWindowUnorderedMinMaxValue(IItemCollection items, IQuantity windowSize, IQuantity slideSize, java.util.concurrent.FutureTask<IResult> cancellationSupplier, SlidingWindowToolkit.IUnorderedWindowValueFunction<V> valueFunction, java.util.Comparator<V> valueComparator, boolean max, boolean includeIntersecting)
items
- items to use for evaluationwindowSize
- window sizeslideSize
- window slide sizecancellationSupplier
- if the evaluation should be cancelledvalueFunction
- provides the window value for itemsvalueComparator
- compares valuesmax
- true to get the max value, false to get min valueincludeIntersecting
- true to include also intersecting items, false to only include contained items. If
set to true, it's up to the valueFunction to only use the duration events that is
actually included in the window.