public void PropagateUpdate(IExecutionContext context, ITupleFactList tupleFactList) { if (tupleFactList.Count == 0) { return; } IBetaMemory memory = context.WorkingMemory.GetNodeMemory(this); var toAssert = new List <Tuple>(); var toUpdate = new List <Tuple>(); var enumerator = tupleFactList.GetEnumerator(); while (enumerator.MoveNext()) { Tuple childTuple = memory.FindTuple(enumerator.CurrentTuple, enumerator.CurrentFact); if (childTuple == null) { childTuple = new Tuple(enumerator.CurrentTuple, enumerator.CurrentFact); childTuple.GroupId = enumerator.CurrentTuple.Id; toAssert.Add(childTuple); } else { toUpdate.Add(childTuple); } } PropagateAssertInternal(context, memory, toAssert); PropagateUpdateInternal(context, toUpdate); }
public void PropagateRetract(IExecutionContext context, TupleFactList tupleFactList) { if (tupleFactList.Count == 0) { return; } IBetaMemory memory = context.WorkingMemory.GetNodeMemory(this); var toRetract = new List <Tuple>(); using (var counter = PerfCounter.Retract(context, this)) { var enumerator = tupleFactList.GetEnumerator(); while (enumerator.MoveNext()) { Tuple childTuple = memory.FindTuple(enumerator.CurrentTuple, enumerator.CurrentFact); if (childTuple != null) { toRetract.Add(childTuple); } } counter.AddInputs(tupleFactList.Count); counter.AddOutputs(toRetract.Count); } PropagateRetractInternal(context, memory, toRetract); }
public void PropagateRetract(IExecutionContext context, Tuple tuple, Fact fact) { IBetaMemory memory = context.WorkingMemory.GetNodeMemory(this); Tuple childTuple = memory.FindTuple(tuple, fact); if (childTuple != null) { foreach (var sink in _sinks) { sink.PropagateRetract(context, childTuple); } memory.Remove(childTuple); } }
public void PropagateUpdate(IExecutionContext context, Tuple tuple, Fact fact) { IBetaMemory memory = context.WorkingMemory.GetNodeMemory(this); Tuple childTuple = memory.FindTuple(tuple, fact); if (childTuple == null) { PropagateAssert(context, tuple, fact); } else { foreach (var sink in _sinks) { sink.PropagateUpdate(context, childTuple); } } }