/** * Attaches the node into the network. Usually to the parent <code>ObjectSource</code> or <code>TupleSource</code> */ public abstract void attach(BuildContext context);
private NodeSet getAncestors(BaseNode o2) { NodeSet ancestors = ancestorsMap.get(o2.getId()); if (ancestors == null) { ancestors = new NodeSet(); o2.collectAncestors(ancestors); ancestorsMap.put(o2.getId(), ancestors); } return ancestors; } });
public void collectAncestors(NodeSet nodeSet) { if (nodeSet.add(this)) { doCollectAncestors(nodeSet); } }
public void remove(RuleRemovalContext context, ReteooBuilder builder, InternalWorkingMemory[] workingMemories) { context.addRemovedNode(this); this.removeAssociation( context.getRule() ); doRemove( context, builder, workingMemories ); if ( !this.isInUse() && !(this instanceof EntryPointNode) ) { builder.getIdGenerator().releaseId( this.getId() ); } }
node.setPartitionId( partition ); node.attach(context); context.releaseId( candidate.getId() ); node.addAssociation( context.getRule(), context.peekRuleComponent() ); return node;
private void updatePropagations( BaseNode baseTerminalNode, BuildContext context ) { baseTerminalNode.networkUpdated( new UpdateContext() ); for ( InternalWorkingMemory workingMemory : context.getWorkingMemories() ) { final PropagationContext propagationContext = new PropagationContextImpl(workingMemory.getNextPropagationIdCounter(), PropagationContext.RULE_ADDITION, null, null, null); for ( BaseNode node : context.getNodes() ) { node.updateSinkOnAttach( context, propagationContext, workingMemory ); } propagationContext.evaluateActionQueue( workingMemory ); } }
for (BaseNode node : nodes) { NodeSet nodeSet = new NodeSet(); node.collectAncestors(nodeSet); removingNode.remove(context, this, workingMemories);
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal( in ); sink = (ObjectSinkPropagator) in.readObject(); source = (ObjectSource) in.readObject(); alphaNodeHashingThreshold = in.readInt(); }
public boolean contains(BaseNode node) { return nodeIds.contains(node.getId()); } }
private void updateLeafSet(BaseNode baseNode, NodeSet leafSet) { if ( baseNode instanceof AlphaNode ) { ((AlphaNode) baseNode).resetInferredMask(); for ( ObjectSink sink : ((AlphaNode) baseNode).getSinkPropagator().getSinks() ) { if ( ((BaseNode)sink).isInUse() ) { updateLeafSet( ( BaseNode ) sink, leafSet ); } } } else if ( baseNode instanceof LeftInputAdapterNode ) { for ( LeftTupleSink sink : ((LeftInputAdapterNode) baseNode).getSinkPropagator().getSinks() ) { if ( sink instanceof RuleTerminalNode ) { leafSet.add( (BaseNode) sink ); } else if ( ((BaseNode)sink).isInUse() ) { updateLeafSet( ( BaseNode ) sink, leafSet ); } } } else if ( baseNode instanceof EvalConditionNode ) { for ( LeftTupleSink sink : ((EvalConditionNode) baseNode).getSinkPropagator().getSinks() ) { if ( ((BaseNode)sink).isInUse() ) { updateLeafSet( ( BaseNode ) sink, leafSet ); } } } else if ( baseNode instanceof BetaNode ) { if ( ((BaseNode)baseNode).isInUse() ) { leafSet.add( baseNode ); } } }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal( in ); sink = (LeftTupleSinkPropagator) in.readObject(); leftDeclaredMask = in.readLong(); leftInferredMask = in.readLong(); leftNegativeMask = in.readLong(); }
public boolean add(BaseNode node) { if (nodeIds.add(node.getId())) { nodes.add(node); return true; } return false; }
if ( node.isInUse() ) { if ( node instanceof AlphaNode ) { updateLeafSet(node, leafSet );
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal( in ); tupleSource = (LeftTupleSource) in.readObject(); declaredMask = in.readLong(); inferredMask = in.readLong(); negativeMask = in.readLong(); }
private TerminalNode addSubRule( final BuildContext context, final GroupElement subrule, final int subruleIndex, final Rule rule ) throws InvalidPatternException { // gets the appropriate builder final ReteooComponentBuilder builder = this.utils.getBuilderFor( subrule ); // checks if an initial-fact is needed if (builder.requiresLeftActivation( this.utils, subrule )) { this.addInitialFactPattern( subrule ); } // builds and attach builder.build( context, this.utils, subrule ); ActivationListenerFactory factory = context.getRuleBase().getConfiguration().getActivationListenerFactory( rule.getActivationListener() ); TerminalNode terminal = factory.createActivationListener( context.getNextId(), context.getTupleSource(), rule, subrule, subruleIndex, context ); BaseNode baseTerminalNode = (BaseNode) terminal; baseTerminalNode.attach( context ); context.addNode( baseTerminalNode ); updatePropagations( baseTerminalNode, context ); return terminal; }