quarks.analytics.sensors

Class Filters

  • java.lang.Object
    • quarks.analytics.sensors.Filters


  • public class Filters
    extends java.lang.Object
    Filters aimed at sensors.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      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,V> TStream<T> deadband(TStream<T> stream, Function<T,V> value, Predicate<V> inBand)
      Deadband filter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • deadband

        public 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. A filter that discards any tuples that are in the deadband, uninteresting to downstream consumers.

        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
        • OR 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.
        • OR it has been more than maximumSuppression seconds (in unit unit)
        • OR it is the first tuple (effectively the state of the filter starts as outside of the deadband).
        Type Parameters:
        T - Tuple type.
        V - Value type for the deadband function.
        Parameters:
        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.
        Returns:
        Filtered stream.
      • deadband

        public static <T,V> TStream<T> deadband(TStream<T> stream,
                                                Function<T,V> value,
                                                Predicate<V> inBand)
        Deadband filter. A filter that discards any tuples that are in the deadband, uninteresting to downstream consumers.

        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
        • OR 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.
        • OR it is the first tuple (effectively the state of the filter starts as outside of the deadband).

        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.

        • All tuples with a value outside the dead band.
        • Two tuples with values within the dead band that are the first time values return to being in band after being outside of the dead band.
        • The first tuple.

        Deadband example

        Type Parameters:
        T - Tuple type.
        V - Value type for the deadband function.
        Parameters:
        stream - Stream containing readings.
        value - Function to obtain the value passed to the deadband function.
        inBand - Function that defines the deadband.
        Returns:
        Filtered stream.

Copyright IBM 2015,2016 - 2f6ad0e-20160307-0902