com.espertech.esper.epl.agg.aggregator
Class AggregatorNth

java.lang.Object
  extended by com.espertech.esper.epl.agg.aggregator.AggregatorNth
All Implemented Interfaces:
AggregationMethod

public class AggregatorNth
extends java.lang.Object
implements AggregationMethod

Aggregator to return the Nth oldest element to enter, with N=1 the most recent value is returned. If N is larger than the enter minus leave size, null is returned. A maximum N historical values are stored, so it can be safely used to compare recent values in large views without incurring excessive overhead.


Field Summary
protected  java.lang.Object[] circularBuffer
           
protected  int currentBufferElementPointer
           
protected  long numDataPoints
           
protected  java.lang.Class returnType
           
protected  int sizeBuf
           
 
Constructor Summary
AggregatorNth(java.lang.Class returnType, int sizeBuf)
          Ctor.
 
Method Summary
 void clear()
          Clear out the collection.
 void enter(java.lang.Object value)
          Apply the value as entering aggregation (entering window).
 java.lang.Object getValue()
          Returns the current value held.
 java.lang.Class getValueType()
          Returns the type of the current value.
 void leave(java.lang.Object value)
          Apply the value as leaving aggregation (leaving window).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

returnType

protected final java.lang.Class returnType

sizeBuf

protected final int sizeBuf

circularBuffer

protected java.lang.Object[] circularBuffer

currentBufferElementPointer

protected int currentBufferElementPointer

numDataPoints

protected long numDataPoints
Constructor Detail

AggregatorNth

public AggregatorNth(java.lang.Class returnType,
                     int sizeBuf)
Ctor.

Parameters:
returnType - return type
sizeBuf - size
Method Detail

enter

public void enter(java.lang.Object value)
Description copied from interface: AggregationMethod
Apply the value as entering aggregation (entering window).

The value can be null since 'null' values may be counted as unique separate values.

Specified by:
enter in interface AggregationMethod
Parameters:
value - to add to aggregate

leave

public void leave(java.lang.Object value)
Description copied from interface: AggregationMethod
Apply the value as leaving aggregation (leaving window).

The value can be null since 'null' values may be counted as unique separate values.

Specified by:
leave in interface AggregationMethod
Parameters:
value - to remove from aggregate

getValueType

public java.lang.Class getValueType()
Description copied from interface: AggregationMethod
Returns the type of the current value.

Specified by:
getValueType in interface AggregationMethod
Returns:
type of values held

getValue

public java.lang.Object getValue()
Description copied from interface: AggregationMethod
Returns the current value held.

Specified by:
getValue in interface AggregationMethod
Returns:
current value

clear

public void clear()
Description copied from interface: AggregationMethod
Clear out the collection.

Specified by:
clear in interface AggregationMethod

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com