|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.espertech.esper.view.ViewSupport
com.espertech.esper.view.stat.WeightedAverageView
public class WeightedAverageView
View for computing a weighted average. The view uses 2 fields within the parent view to compute the weighted average. The X field and weight field. In a price-volume example it calculates the volume-weighted average price as (sum(price * volume) / sum(volume)). Example: weighted_avg("price", "volume")
Field Summary | |
---|---|
protected double |
currentValue
|
protected java.lang.Object[] |
lastValuesEventNew
|
protected double |
sumW
|
protected double |
sumXtimesW
|
Fields inherited from class com.espertech.esper.view.ViewSupport |
---|
EMPTY_VIEW_ARRAY, parent |
Constructor Summary | |
---|---|
WeightedAverageView(WeightedAverageViewFactory viewFactory,
AgentInstanceViewFactoryChainContext agentInstanceContext)
Constructor requires the name of the field to use in the parent view to compute the weighted average on, as well as the name of the field in the parent view to get the weight from. |
Method Summary | |
---|---|
View |
cloneView()
Duplicates the view. |
static EventType |
createEventType(StatementContext statementContext,
StatViewAdditionalProps additionalProps,
int streamNum)
Creates the event type for this view. |
double |
getCurrentValue()
|
EventType |
getEventType()
Provides metadata information about the type of object the event collection contains. |
ExprNode |
getFieldNameWeight()
Returns the expression supplying the weight values. |
ExprNode |
getFieldNameX()
Returns the expression supplying the X values. |
java.lang.Object[] |
getLastValuesEventNew()
|
double |
getSumW()
|
double |
getSumXtimesW()
|
ViewFactory |
getViewFactory()
|
java.util.Iterator<EventBean> |
iterator()
Allows iteration through all elements in this event collection. |
void |
setCurrentValue(double currentValue)
|
void |
setLastValuesEventNew(java.lang.Object[] lastValuesEventNew)
|
void |
setSumW(double sumW)
|
void |
setSumXtimesW(double sumXtimesW)
|
java.lang.String |
toString()
|
void |
update(EventBean[] newData,
EventBean[] oldData)
Notify that data has been added or removed from the Viewable parent. |
Methods inherited from class com.espertech.esper.view.ViewSupport |
---|
addView, addView, dumpChildViews, dumpUpdateParams, dumpUpdateParams, findDescendent, findViewIndex, getParent, getViews, hasViews, removeAllViews, removeView, removeView, setParent, updateChildren, updateChildren |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.espertech.esper.view.View |
---|
getParent, setParent |
Methods inherited from interface com.espertech.esper.view.Viewable |
---|
addView, getViews, hasViews, removeAllViews, removeView |
Field Detail |
---|
protected double sumXtimesW
protected double sumW
protected double currentValue
protected java.lang.Object[] lastValuesEventNew
Constructor Detail |
---|
public WeightedAverageView(WeightedAverageViewFactory viewFactory, AgentInstanceViewFactoryChainContext agentInstanceContext)
Method Detail |
---|
public View cloneView()
CloneableView
Expected to return a same view in initialized state for grouping.
cloneView
in interface CloneableView
public final ExprNode getFieldNameX()
public final ExprNode getFieldNameWeight()
public void update(EventBean[] newData, EventBean[] oldData)
View
update
in interface View
newData
- is the new data that has been added to the parent viewoldData
- is the old data that has been removed from the parent viewpublic final EventType getEventType()
EventCollection
getEventType
in interface EventCollection
public final java.util.Iterator<EventBean> iterator()
EventCollection
iterator
in interface EventCollection
iterator
in interface java.lang.Iterable<EventBean>
public final java.lang.String toString()
toString
in class java.lang.Object
public static EventType createEventType(StatementContext statementContext, StatViewAdditionalProps additionalProps, int streamNum)
statementContext
- is the event adapter service
public double getSumXtimesW()
public void setSumXtimesW(double sumXtimesW)
public double getSumW()
public void setSumW(double sumW)
public double getCurrentValue()
public void setCurrentValue(double currentValue)
public java.lang.Object[] getLastValuesEventNew()
public void setLastValuesEventNew(java.lang.Object[] lastValuesEventNew)
public ViewFactory getViewFactory()
getViewFactory
in interface GroupableView
|
© 2006-2015 EsperTech Inc. All rights reserved. Visit us at espertech.com |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |