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 PropagateUpdate(IExecutionContext context, TupleFactList 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(context.IdGenerator.NextTupleId(), 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 PropagateAssert(IExecutionContext context, TupleFactList tupleFactList) { if (tupleFactList.Count == 0) { return; } IBetaMemory memory = context.WorkingMemory.GetNodeMemory(this); var toAssert = new List <Tuple>(); using (var counter = PerfCounter.Assert(context, this)) { var enumerator = tupleFactList.GetEnumerator(); while (enumerator.MoveNext()) { var childTuple = new Tuple(context.IdGenerator.NextTupleId(), enumerator.CurrentTuple, enumerator.CurrentFact); childTuple.GroupId = enumerator.CurrentTuple.Id; toAssert.Add(childTuple); } counter.AddItems(tupleFactList.Count); } PropagateAssertInternal(context, memory, toAssert); }
private void PropagateAggregateRetracts(IExecutionContext context, Aggregation aggregation) { var retracts = new TupleFactList(); foreach (var retract in aggregation.Retracts) { var fact = ToAggregateFact(context, retract.ResultObject); retracts.Add(retract.Tuple, fact); } if (retracts.Count > 0) { MemoryNode.PropagateRetract(context, retracts); var enumerator = retracts.GetEnumerator(); while (enumerator.MoveNext()) { context.WorkingMemory.RemoveInternalFact(this, enumerator.CurrentFact); } } }