Interface NodeCalc
- All Known Subinterfaces:
LiteralNodeCalc
- All Known Implementing Classes:
AbstractBinaryMinMax
,AbstractBinaryNodeCalc
,AbstractMinMaxNodeCalc
,AbstractSingleChildNodeCalc
,BigDecimalNodeCalc
,BinaryMaxCalc
,BinaryMinCalc
,BinaryOperation
,CachedNodeCalc
,DoubleNodeCalc
,FloatNodeCalc
,IntegerNodeCalc
,MaxNodeCalc
,MinNodeCalc
,TimeNodeCalc
,TimeSeriesNameNodeCalc
,TimeSeriesNumNodeCalc
,UnaryOperation
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 <geoffroy.jamgotchian at rte-france.com>
-
Method Summary
Modifier and TypeMethodDescription<R,
A> R accept
(NodeCalcVisitor<R, A> visitor, A arg, int depth) <R,
A> R acceptHandle
(NodeCalcVisitor<R, A> visitor, A arg, Deque<Object> resultsStack) <R,
A> void acceptIterate
(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
static String
void
writeJson
(com.fasterxml.jackson.core.JsonGenerator generator) static void
-
Method Details
-
accept
-
acceptIterate
-
acceptHandle
-
writeJson
- Throws:
IOException
-
writeJson
-
toJson
-
parseJson
-
parseJson
-
createUnexpectedToken
-
parseJson
static NodeCalc parseJson(com.fasterxml.jackson.core.JsonParser parser, com.fasterxml.jackson.core.JsonToken token) throws IOException - Throws:
IOException
-