public class ReteBuilder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
indexing
Flag to turn on/off indexing.
|
protected boolean |
nodesharing
Flag to turn on/off nodesharing.
|
protected boolean |
notjoin
Flag to turn on/off placing join constraints in a not node
(otherwise separate beta nodes will be created and not nodes will have no constraints).
|
protected BuildReport |
report
The build report.
|
static boolean |
REPORTING
The flag for turning on/off reporting.
|
Constructor and Description |
---|
ReteBuilder()
Create a new rete builder.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addAlphaNode(IConstraintEvaluator[] evas,
BuildContext context)
Add a new alpha node.
|
protected void |
addBetaNode(IConstraintEvaluator[] evas,
ConstraintIndexer[] ids,
BuildContext context)
Add a new beta node.
|
protected void |
addCollectNode(IConstraintEvaluator[] evas,
int tuplecnt,
BuildContext context)
Add a new collect node.
|
protected void |
addInitialFactNode(BuildContext context)
Add an initial fact node.
|
protected void |
addNotNode(IConstraintEvaluator[] evas,
ConstraintIndexer[] ids,
int tuplecnt,
BuildContext context)
Add a new not node.
|
ReteNode |
addRule(ReteNode root,
IRule rule)
Add a new rule to the network.
|
protected void |
addSplitNode(OAVAttributeType attr,
java.lang.String[] binds,
BuildContext context)
Add a new split node.
|
protected void |
addTerminalNode(IRule rule,
BuildContext context)
Add a new terminal node.
|
protected void |
addTestNode(IConstraintEvaluator eva,
BuildContext context)
Add a new test node.
|
protected void |
addTypeNode(OAVObjectType type,
BuildContext context)
Add a new type node.
|
void |
buildAndCondition(AndCondition curcond,
BuildContext context)
Build an and condition.
|
void |
buildCollectCondition(CollectCondition curcond,
BuildContext context)
Build a collect condition.
|
void |
buildCondition(ICondition curcond,
BuildContext context)
Build any kind condition.
|
protected java.util.List |
buildConstraintEvaluator(ICondition cond,
IConstraint c,
BuildContext context)
Generate constraint evaluator for a constraint.
|
protected java.util.List |
buildConstraintIndexer(ObjectCondition cond,
IConstraint c,
BuildContext context)
Generate a constraint indexer for a top-level equal join.
|
IValueExtractor |
buildFunctionExtractor(int tupleindex,
FunctionCall fc,
int subindex,
BuildContext context)
Build a function extractor for a function call.
|
void |
buildNotCondition(NotCondition curcond,
BuildContext context)
Build a not condition.
|
void |
buildObjectCondition(ObjectCondition curcond,
BuildContext context)
Build an object condition.
|
void |
buildOrCondition(OrCondition curcond,
BuildContext context)
Build an or condition.
|
void |
buildTestCondition(TestCondition curcond,
BuildContext context)
Build a test condition.
|
protected IValueExtractor |
buildVariableExtractor(Variable var,
BuildContext context)
Build a variable extractor for an alpha or beta context.
|
protected void |
connectLeft(INode source,
INode consumer,
BuildContext context)
Connect two nodes by attaching the source to the left (tuple) input of the consumer.
|
protected void |
connectRight(INode source,
INode consumer,
BuildContext context)
Connect two nodes by attaching the source to the right (object) input of the consumer.
|
IValueExtractor |
createArrayExtractor(int tupleindex,
ArraySelector as,
BuildContext context,
boolean prefix)
Build an array extractor for an array selector.
|
IValueExtractor |
createMethodExtractor(int tupleindex,
MethodCall mc,
BuildContext context,
boolean prefix)
Build a method extractor for a method call.
|
protected IValueExtractor |
createObjectExtractor(OAVAttributeType attr,
java.lang.Object key)
Create an object extractor for the given (OAV or Java) attribute.
|
protected IValueExtractor |
createPrefixExtractor(OAVAttributeType attr,
java.lang.Object key)
Create a prefix extractor for the given (OAV or Java) attribute.
|
protected IValueExtractor |
createTupleExtractor(int tupleindex,
OAVAttributeType attr,
java.lang.Object key)
Create a tuple extractor for the given (OAV or Java) attribute.
|
IValueExtractor |
createValueExtractor(int tupleindex,
java.lang.Object valuesource,
int subindex,
BuildContext context,
boolean prefix)
Creates an appropriate extractor for the given parameters.
|
BuildReport |
getBuildReport()
Get the build report.
|
protected int |
getChildCount(INode node)
Count the number of children.
|
protected IValueExtractor |
getLeftVariableExtractor(BuildContext context,
Variable var)
Get the evaluator for the first occurrence of the
given variable (when needed as left input).
|
protected IValueExtractor |
getRightVariableExtractor(BuildContext context,
Variable var)
Get the evaluator for the first occurrence of the
given variable (when needed as right input).
|
protected boolean |
isAlphaExecutable(ICondition cond,
IConstraint c)
Test if all needed variables are available from the condition directly.
|
protected void |
removeNodeUsage(INode node)
Remove a node usage.
|
void |
removeRule(ReteNode root,
IRule rule)
Remove a rule from a rete network.
|
public static final boolean REPORTING
protected boolean indexing
protected boolean nodesharing
protected boolean notjoin
protected BuildReport report
public ReteNode addRule(ReteNode root, IRule rule)
root
- The root node (when null a new network will be created).rule
- The rule to add.public void removeRule(ReteNode root, IRule rule)
root
- The root node.rule
- The rule to remove.public BuildReport getBuildReport()
public void buildCondition(ICondition curcond, BuildContext context)
public void buildAndCondition(AndCondition curcond, BuildContext context)
public void buildOrCondition(OrCondition curcond, BuildContext context)
public void buildNotCondition(NotCondition curcond, BuildContext context)
public void buildObjectCondition(ObjectCondition curcond, BuildContext context)
curcond
- the object condition.context
- The build context.public void buildTestCondition(TestCondition curcond, BuildContext context)
public void buildCollectCondition(CollectCondition curcond, BuildContext context)
protected void removeNodeUsage(INode node)
node
- The node usage to remove.protected int getChildCount(INode node)
node
- The node.protected void connectLeft(INode source, INode consumer, BuildContext context)
source
- The source node.consumer
- The consumer node.protected void connectRight(INode source, INode consumer, BuildContext context)
source
- The source node.consumer
- The consumer node.protected java.util.List buildConstraintIndexer(ObjectCondition cond, IConstraint c, BuildContext context)
protected java.util.List buildConstraintEvaluator(ICondition cond, IConstraint c, BuildContext context)
cond
- The object condition.c
- The constraint.context
- The build context.public IValueExtractor buildFunctionExtractor(int tupleindex, FunctionCall fc, int subindex, BuildContext context)
fc
- The function call.protected IValueExtractor buildVariableExtractor(Variable var, BuildContext context)
var
- The variable.context
- The build context.alpha
- Is the extractor for alpha or beta context.protected boolean isAlphaExecutable(ICondition cond, IConstraint c)
protected void addTypeNode(OAVObjectType type, BuildContext context)
type
- The type node.context
- the build context.protected void addAlphaNode(IConstraintEvaluator[] evas, BuildContext context)
eva
- The constraint evaluator.context
- The build context.protected void addSplitNode(OAVAttributeType attr, java.lang.String[] binds, BuildContext context)
attr
- The attribute.binds
- The binding variable codes.context
- The build context.protected void addBetaNode(IConstraintEvaluator[] evas, ConstraintIndexer[] ids, BuildContext context)
evas
- The constraint evaluators.ids
- The constraint indexers.context
- The build context.protected void addNotNode(IConstraintEvaluator[] evas, ConstraintIndexer[] ids, int tuplecnt, BuildContext context)
evas
- The constraint evaluators.ids
- The constraint indexers.context
- The build context.protected void addInitialFactNode(BuildContext context)
context
- The build context.protected void addTestNode(IConstraintEvaluator eva, BuildContext context)
eva
- The constraint evaluator.context
- The build context.protected void addCollectNode(IConstraintEvaluator[] evas, int tuplecnt, BuildContext context)
eva
- The constraint evaluator.context
- The build context.protected void addTerminalNode(IRule rule, BuildContext context)
rule
- The rule.context
- The build context.protected IValueExtractor getRightVariableExtractor(BuildContext context, Variable var)
var
- The variable.protected IValueExtractor getLeftVariableExtractor(BuildContext context, Variable var)
var
- The variable.public IValueExtractor createValueExtractor(int tupleindex, java.lang.Object valuesource, int subindex, BuildContext context, boolean prefix)
tupleindex
- The tuple index (-1 for none).attr
- The attribute.subindex
- The subindex when multisplit (-1 for none).public IValueExtractor createMethodExtractor(int tupleindex, MethodCall mc, BuildContext context, boolean prefix)
mc
- The method call.public IValueExtractor createArrayExtractor(int tupleindex, ArraySelector as, BuildContext context, boolean prefix)
as
- The array selector.protected IValueExtractor createObjectExtractor(OAVAttributeType attr, java.lang.Object key)
attr
- The attribute.protected IValueExtractor createTupleExtractor(int tupleindex, OAVAttributeType attr, java.lang.Object key)
attr
- The attribute.protected IValueExtractor createPrefixExtractor(OAVAttributeType attr, java.lang.Object key)
attr
- The attribute.