Interface NodeCalc
-
- All Known Subinterfaces:
LiteralNodeCalc
- All Known Implementing Classes:
AbstractMinMaxNodeCalc
,AbstractSingleChildNodeCalc
,BigDecimalNodeCalc
,BinaryOperation
,DoubleNodeCalc
,FloatNodeCalc
,IntegerNodeCalc
,MaxNodeCalc
,MinNodeCalc
,TimeNodeCalc
,TimeSeriesNameNodeCalc
,TimeSeriesNumNodeCalc
,UnaryOperation
public interface NodeCalc
A NodeCalc is an element of the timeseries computation tree. These computation trees are typically the results of running user scripts, for example written in groovy. They can be serialized to json or traversed by visitors. Traversing them with visitor allows to compute various results, such as evaluating the tree or find the names of the timeseries used in the tree.The writeJson method is used to serialize the tree to json.
The accept, acceptIterate and acceptHandle methods together with the
NodeCalcVisitor
interface form the hybrid recursive/iterative visitor pattern. This visitor pattern uses recursion on the children up to a stack depth limit because performance is almost 5 times better when using recursion compared to the iterative algorithm using stacks, but excessive depths cause StackOverflowErrors.The accept method are the main entrypoint of the hybrid visit and implements the recursive visit as well as performing the switch from the recursive to iterative behavior.
The acceptIterate and acceptHandle methods are used by
NodeCalcVisitors
during the iterative traversal of the tree. The acceptIterate method push children nodes the be traversed in the stack. The acceptHandle method extract the already calculated children results from the stack and use them to compute and return the result for this node.- Author:
- Geoffroy Jamgotchian
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <R,A>
Raccept(NodeCalcVisitor<R,A> visitor, A arg, int depth)
<R,A>
RacceptHandle(NodeCalcVisitor<R,A> visitor, A arg, Deque<Object> resultsStack)
<R,A>
voidacceptIterate(NodeCalcVisitor<R,A> visitor, A arg, Deque<Object> nodesStack)
static TimeSeriesException
createUnexpectedToken(com.fasterxml.jackson.core.JsonToken token)
static NodeCalc
parseJson(com.fasterxml.jackson.core.JsonParser parser)
static NodeCalc
parseJson(com.fasterxml.jackson.core.JsonParser parser, com.fasterxml.jackson.core.JsonToken token)
static NodeCalc
parseJson(String json)
static String
toJson(NodeCalc node)
void
writeJson(com.fasterxml.jackson.core.JsonGenerator generator)
static void
writeJson(NodeCalc node, com.fasterxml.jackson.core.JsonGenerator generator)
-
-
-
Method Detail
-
accept
<R,A> R accept(NodeCalcVisitor<R,A> visitor, A arg, int depth)
-
acceptIterate
<R,A> void acceptIterate(NodeCalcVisitor<R,A> visitor, A arg, Deque<Object> nodesStack)
-
acceptHandle
<R,A> R acceptHandle(NodeCalcVisitor<R,A> visitor, A arg, Deque<Object> resultsStack)
-
writeJson
void writeJson(com.fasterxml.jackson.core.JsonGenerator generator) throws IOException
- Throws:
IOException
-
writeJson
static void writeJson(NodeCalc node, com.fasterxml.jackson.core.JsonGenerator generator)
-
parseJson
static NodeCalc parseJson(com.fasterxml.jackson.core.JsonParser parser)
-
createUnexpectedToken
static TimeSeriesException createUnexpectedToken(com.fasterxml.jackson.core.JsonToken token)
-
parseJson
static NodeCalc parseJson(com.fasterxml.jackson.core.JsonParser parser, com.fasterxml.jackson.core.JsonToken token) throws IOException
- Throws:
IOException
-
-