Class BaseAggregateWindow

  • All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    AggregateWindow, TransactionalMemoryAggregateWindow

    public abstract class BaseAggregateWindow
    extends Object
    implements Serializable
    Abstract base class for all custom java aggregate functions.

    All custom java aggregate classes must extend AggregateWindow. The user's subclass must implement at least one accumulate method that corresponds to the argument number and data types that a StreamBase expression (using calljava or its alias) refers to (typically used in Aggregate and Query operators). The accumulate method will be called each time new data arrives for the window.

    There may be many overloaded accumulate methods, all with void return.

    The user's subclass must also implement a calculate method. When data is sent from the aggregate window, The calculate method must return a type matching a StreamBase data type (for Strings you may also return byte[], for blobs you must use ByteArrayView). The return type may be the Java primitive or the Java Object which allows a null return type.

    The calculate method will be called whenever a new tuple is generated. The calculate method may be called just once (as in the case when a tuple is generated when the aggregate window closes) or many times (as in the case when the aggregate window remains open, but a tuple is generated because "emit every N tuples" was selected).

    It is also possible that calculate may be called before accumulate is called. It is also possible that calculate may never be called.

    The AggregateWindow object is likely to be used several times. At the start of each new use, the init() method will be called. Then accumulate and calculate may be called. Finally, at the end of each use, release will be called.

    Note: Serializations of instances of this class that are created (e.g., by using ObjectOutputStream) in one version of StreamBase in general will not be deserializable in any other version of StreamBase.

    See Also:
    Serialized Form
    • Constructor Detail

      • BaseAggregateWindow

        public BaseAggregateWindow()
    • Method Detail

      • init

        public abstract void init()
        Called before each new use of this object.
      • release

        public void release()
        Called after the end of a use of this object.
      • setRuntimeEnv

        public abstract void setRuntimeEnv​(Object env)
        Called by internal streambase code to set the runtime environment
        Parameters:
        env - Runtime environment
      • getEnv

        public abstract Object getEnv()
        Get runtime environment
        Returns:
        Environment