/** * Propagate a change of a tuple in the result memory. */ protected void propagateModification(Tuple left, Object right, int tupleindex, OAVAttributeType type, Object oldvalue, Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { Tuple tuple = mem.getTuple(state, left, right); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].modifyTuple(tuple, tupleindex, type, oldvalue, newvalue, state, mem, agenda); }
/** * Propagate a change of a tuple in the result memory. */ protected void propagateModification(Tuple left, Object right, int tupleindex, OAVAttributeType type, Object oldvalue, Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { Tuple tuple = mem.getTuple(state, left, right); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].modifyTuple(tuple, tupleindex, type, oldvalue, newvalue, state, mem, agenda); }
/** * Create an index tuple from a tuple. * The index tuple excludes the index position at * which the compression happens (and all elements * thereafter -> why, could be the last node?). * @param tuple The tuple. * @return The index tuple. */ protected Tuple createIndexTuple(IOAVState state, Tuple tuple, ReteMemory mem) { List obs = tuple.getObjects(); Tuple t = null; for(int i=0; i<obs.size(); i++) { if(i<tupleindex) t = mem.getTuple(state, t, obs.get(i)); // Create tuple from tuples } return t; }
/** * Create an index tuple from a tuple. * The index tuple excludes the index position at * which the compression happens (and all elements * thereafter -> why, could be the last node?). * @param tuple The tuple. * @return The index tuple. */ protected Tuple createIndexTuple(IOAVState state, Tuple tuple, ReteMemory mem) { List obs = tuple.getObjects(); Tuple t = null; for(int i=0; i<obs.size(); i++) { if(i<tupleindex) t = mem.getTuple(state, t, obs.get(i)); // Create tuple from tuples } return t; }
/** * Check if a match is contained. */ protected boolean isMatchContained(IOAVState state, Tuple left, Object right, ReteMemory mem) { return mem.hasNodeMemory(this) && ((BetaMemory)mem.getNodeMemory(this)).getResultMemory() .contains(mem.getTuple(state, left, right)); }
/** * Check if a match is contained. */ protected boolean isMatchContained(IOAVState state, Tuple left, Object right, ReteMemory mem) { return mem.hasNodeMemory(this) && ((BetaMemory)mem.getNodeMemory(this)).getResultMemory() .contains(mem.getTuple(state, left, right)); }
/** * Add a match to the node memory and propagate if necessary. */ protected void addMatch(Tuple left, Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { Tuple result = mem.getTuple(state, left, right); BetaMemory bmem = (BetaMemory)mem.getNodeMemory(this); if(bmem.addResultTuple(result)) { ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].addTuple(result, state, mem, agenda); } }
/** * Add a match to the node memory and propagate if necessary. */ protected void addMatch(Tuple left, Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { Tuple result = mem.getTuple(state, left, right); BetaMemory bmem = (BetaMemory)mem.getNodeMemory(this); if(bmem.addResultTuple(result)) { ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].addTuple(result, state, mem, agenda); } }
/** * Remove a match from the node memory and propagate if necessary. */ protected void removeMatch(Tuple left, Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { if(mem.hasNodeMemory(this)) { Tuple result = mem.getTuple(state, left, right); if(((BetaMemory)mem.getNodeMemory(this)).removeResultTuple(result)) { // if(getNodeId()==3713) // System.out.println("remmi: "+result); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].removeTuple(result, state, mem, agenda); } } }
/** * Remove a match from the node memory and propagate if necessary. */ protected void removeMatch(Tuple left, Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { if(mem.hasNodeMemory(this)) { Tuple result = mem.getTuple(state, left, right); if(((BetaMemory)mem.getNodeMemory(this)).removeResultTuple(result)) { // if(getNodeId()==3713) // System.out.println("remmi: "+result); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].removeTuple(result, state, mem, agenda); } } }
/** * Send an object to this node. * @param object The object. */ public void addObject(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Add object called: "+this+" "+object); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTADDED); Collection amem = (Collection)mem.getNodeMemory(this); Tuple tuple = mem.getTuple(state, null, object); amem.add(tuple); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].addTuple(tuple, state, mem, agenda); state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTADDED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Send an object to this node. * @param object The object. */ public void addObject(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Add object called: "+this+" "+object); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTADDED); Collection amem = (Collection)mem.getNodeMemory(this); Tuple tuple = mem.getTuple(state, null, object); amem.add(tuple); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].addTuple(tuple, state, mem, agenda); state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTADDED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Send a removed object to this node. * @param object The object. */ public void removeObject(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Remove object called: "+this+" "+object); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTREMOVED); if(mem.hasNodeMemory(this)) { Collection amem = (Collection)mem.getNodeMemory(this); Tuple tuple = mem.getTuple(state, null, object); if(amem.remove(tuple)) { ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].removeTuple(tuple, state, mem, agenda); } } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Send a removed object to this node. * @param object The object. */ public void removeObject(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Remove object called: "+this+" "+object); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTREMOVED); if(mem.hasNodeMemory(this)) { Collection amem = (Collection)mem.getNodeMemory(this); Tuple tuple = mem.getTuple(state, null, object); if(amem.remove(tuple)) { ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].removeTuple(tuple, state, mem, agenda); } } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Propagate an object change to this node. * @param object The new object. */ public void modifyObject(Object object, OAVAttributeType type, Object oldvalue, Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTMODIFIED); if(getRelevantAttributes().contains(type)) { // Check if modification changes node memory. Tuple tuple = mem.getTuple(state, null, object); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].modifyTuple(tuple, 0, type, oldvalue, newvalue, state, mem, agenda); } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTMODIFIED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Propagate an object change to this node. * @param object The new object. */ public void modifyObject(Object object, OAVAttributeType type, Object oldvalue, Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTMODIFIED); if(getRelevantAttributes().contains(type)) { // Check if modification changes node memory. Tuple tuple = mem.getTuple(state, null, object); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].modifyTuple(tuple, 0, type, oldvalue, newvalue, state, mem, agenda); } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTMODIFIED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }