public class Filters
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T,V> TStream<T> |
deadband(TStream<T> stream,
Function<T,V> value,
Predicate<V> inBand)
Deadband filter.
|
static <T,V> TStream<T> |
deadband(TStream<T> stream,
Function<T,V> value,
Predicate<V> inBand,
long maximumSuppression,
java.util.concurrent.TimeUnit unit)
Deadband filter with maximum suppression time.
|
static <T> TStream<T> |
deadtime(TStream<T> stream,
long deadtimePeriod,
java.util.concurrent.TimeUnit unit)
Deadtime filter.
|
public static <T,V> TStream<T> deadband(TStream<T> stream, Function<T,V> value, Predicate<V> inBand, long maximumSuppression, java.util.concurrent.TimeUnit unit)
A tuple t
is passed through the deadband filter if:
inBand.test(value.apply(t))
is false, that is the tuple's value is outside of the deadband
inBand.test(value.apply(t))
is true AND the last tuple's value was outside of the deadband.
This corresponds to the first tuple's value inside the deadband after a period being outside it.
maximumSuppression
seconds (in unit unit
)
T
- Tuple type.V
- Value type for the deadband function.stream
- Stream containing readings.value
- Function to obtain the tuple's value passed to the deadband function.inBand
- Function that defines the deadband.maximumSuppression
- Maximum amount of time to suppress values that are in the deadband.unit
- Unit for maximumSuppression
.public static <T,V> TStream<T> deadband(TStream<T> stream, Function<T,V> value, Predicate<V> inBand)
A tuple t
is passed through the deadband filter if:
inBand.test(value.apply(t))
is false, that is the value is outside of the deadband
inBand.test(value.apply(t))
is true and the last value was outside of the deadband.
This corresponds to the first value inside the deadband after a period being outside it.
Here's an example of how deadband()
would pass through tuples for a sequence of
values against the shaded dead band area. Circled values are ones that are passed through
the filter to the returned stream.
T
- Tuple type.V
- Value type for the deadband function.stream
- Stream containing readings.value
- Function to obtain the value passed to the deadband function.inBand
- Function that defines the deadband.public static <T> TStream<T> deadtime(TStream<T> stream, long deadtimePeriod, java.util.concurrent.TimeUnit unit)
E.g., for a deadtime period of 30 minutes, after letting a tuple pass through, any tuples received during the next 30 minutes are filtered out. Then the next arriving tuple is passed through and a new deadtime period is begun.
Use Deadtime
directly if you need to change the deadtime period
while the topology is running.
T
- tuple typestream
- TStream to add deadtime filter todeadtimePeriod
- the deadtime period in unit
unit
- the TimeUnit
to apply to deadtimePeriod
Deadtime
Copyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641