public override void compileSingleCE(Rule.IRule rule) { ICondition[] conds = rule.Conditions; ObjectCondition oc = (ObjectCondition)conds[0]; if (oc.Negated) { // the ObjectCondition is negated, so we need to // handle it appropriate. This means we need to // Add a LIANode to _IntialFact and attach a NOTNode // to the LIANode. ObjectTypeNode otn = (ObjectTypeNode)ruleCompiler.Inputnodes.Get(ruleCompiler.Engine.InitFact); LIANode lianode = ruleCompiler.findLIANode(otn); NotJoin njoin = new NotJoin(ruleCompiler.Engine.nextNodeId()); njoin.Bindings = new Binding[0]; lianode.addSuccessorNode(njoin, ruleCompiler.Engine, ruleCompiler.Memory); // Add the join to the rule object rule.addJoinNode(njoin); oc.LastNode.addSuccessorNode(njoin, ruleCompiler.Engine, ruleCompiler.Memory); } else if (oc.Nodes.Count == 0) { // this means the rule has a binding, but no conditions ObjectTypeNode otn = ruleCompiler.findObjectTypeNode(oc.TemplateName); LIANode lianode = new LIANode(ruleCompiler.Engine.nextNodeId()); otn.addSuccessorNode(lianode, ruleCompiler.Engine, ruleCompiler.Memory); rule.Conditions[0].addNode(lianode); } }
public override void compileFirstJoin(ICondition condition, Rule.IRule rule) { ObjectCondition cond = (ObjectCondition)condition; ObjectTypeNode otn = ruleCompiler.findObjectTypeNode(cond.TemplateName); // the LeftInputAdapterNode is the first node to propogate to // the first joinNode of the rule LIANode node = new LIANode(ruleCompiler.Engine.nextNodeId()); // if the condition doesn't have any nodes, we want to Add it to // the objectType node if one doesn't already exist. // otherwise we Add it to the last AlphaNode if (cond.Nodes.Count == 0) { // try to find the existing LIANode for the given ObjectTypeNode // if we don't do this, we end up with multiple LIANodes // descending directly from the ObjectTypeNode LIANode existingLIANode = ruleCompiler.findLIANode(otn); if (existingLIANode == null) { otn.addSuccessorNode(node, ruleCompiler.Engine, ruleCompiler.Memory); cond.addNode(node); } else { existingLIANode.incrementUseCount(); cond.addNode(existingLIANode); } } else { // Add the LeftInputAdapterNode to the last alphaNode // In the case of node sharing, the LIANode could be the last // alphaNode, so we have to check and only Add the node to // the condition if it isn't a LIANode BaseAlpha old = (BaseAlpha)cond.LastNode; //if the last node of condition has a LIANode successor, //the LIANode should be shared with the new CE followed by another CE. // Houzhanbin,10/16/2007 BaseNode[] successors = (BaseNode[])old.SuccessorNodes; for (int i = 0; i < successors.Length; i++) { if (successors[i] is LIANode) { cond.addNode(successors[i]); return; } } if (!(old is LIANode)) { old.addSuccessorNode(node, ruleCompiler.Engine, ruleCompiler.Memory); cond.addNode(node); } } }
public override void compileSingleCE(Rule.IRule rule) { ICondition[] conds = rule.Conditions; ObjectCondition oc = (ObjectCondition) conds[0]; if (oc.Negated) { // the ObjectCondition is negated, so we need to // handle it appropriate. This means we need to // Add a LIANode to _IntialFact and attach a NOTNode // to the LIANode. ObjectTypeNode otn = (ObjectTypeNode) ruleCompiler.Inputnodes.Get(ruleCompiler.Engine.InitFact); LIANode lianode = ruleCompiler.findLIANode(otn); NotJoin njoin = new NotJoin(ruleCompiler.Engine.nextNodeId()); njoin.Bindings = new Binding[0]; lianode.addSuccessorNode(njoin, ruleCompiler.Engine, ruleCompiler.Memory); // Add the join to the rule object rule.addJoinNode(njoin); oc.LastNode.addSuccessorNode(njoin, ruleCompiler.Engine, ruleCompiler.Memory); } else if (oc.Nodes.Count == 0) { // this means the rule has a binding, but no conditions ObjectTypeNode otn = ruleCompiler.findObjectTypeNode(oc.TemplateName); LIANode lianode = new LIANode(ruleCompiler.Engine.nextNodeId()); otn.addSuccessorNode(lianode, ruleCompiler.Engine, ruleCompiler.Memory); rule.Conditions[0].addNode(lianode); } }
public override void compileFirstJoin(ICondition condition, Rule.IRule rule) { ObjectCondition cond = (ObjectCondition) condition; ObjectTypeNode otn = ruleCompiler.findObjectTypeNode(cond.TemplateName); // the LeftInputAdapterNode is the first node to propogate to // the first joinNode of the rule LIANode node = new LIANode(ruleCompiler.Engine.nextNodeId()); // if the condition doesn't have any nodes, we want to Add it to // the objectType node if one doesn't already exist. // otherwise we Add it to the last AlphaNode if (cond.Nodes.Count == 0) { // try to find the existing LIANode for the given ObjectTypeNode // if we don't do this, we end up with multiple LIANodes // descending directly from the ObjectTypeNode LIANode existingLIANode = ruleCompiler.findLIANode(otn); if (existingLIANode == null) { otn.addSuccessorNode(node, ruleCompiler.Engine, ruleCompiler.Memory); cond.addNode(node); } else { existingLIANode.incrementUseCount(); cond.addNode(existingLIANode); } } else { // Add the LeftInputAdapterNode to the last alphaNode // In the case of node sharing, the LIANode could be the last // alphaNode, so we have to check and only Add the node to // the condition if it isn't a LIANode BaseAlpha old = (BaseAlpha) cond.LastNode; //if the last node of condition has a LIANode successor, //the LIANode should be shared with the new CE followed by another CE. // Houzhanbin,10/16/2007 BaseNode[] successors = (BaseNode[]) old.SuccessorNodes; for (int i = 0; i < successors.Length; i++) { if (successors[i] is LIANode) { cond.addNode(successors[i]); return; } } if (!(old is LIANode)) { old.addSuccessorNode(node, ruleCompiler.Engine, ruleCompiler.Memory); cond.addNode(node); } } }