public override void PropagateUpdate(IExecutionContext context, IList <Tuple> tuples) { if (_isSubnetJoin) { return; } var joinedSets = JoinedSets(context, tuples); var toUpdate = new TupleFactList(); var toRetract = new TupleFactList(); foreach (var set in joinedSets) { foreach (var fact in set.Facts) { if (MatchesConditions(context, set.Tuple, fact)) { toUpdate.Add(set.Tuple, fact); } else { toRetract.Add(set.Tuple, fact); } } } MemoryNode.PropagateUpdate(context, toUpdate); MemoryNode.PropagateRetract(context, toRetract); }
public override void PropagateUpdate(IExecutionContext context, List <Tuple> tuples) { if (_isSubnetJoin) { return; } var toUpdate = new TupleFactList(); var toRetract = new TupleFactList(); using (var counter = PerfCounter.Update(context, this)) { var joinedSets = JoinedSets(context, tuples); foreach (var set in joinedSets) { foreach (var fact in set.Facts) { if (MatchesConditions(context, set.Tuple, fact)) { toUpdate.Add(set.Tuple, fact); } else { toRetract.Add(set.Tuple, fact); } } } counter.AddInputs(tuples.Count); counter.AddOutputs(toUpdate.Count + toRetract.Count); } MemoryNode.PropagateRetract(context, toRetract); MemoryNode.PropagateUpdate(context, toUpdate); }
private void RetractBinding(Tuple tuple, TupleFactList toRetract) { var fact = tuple.RemoveState <Fact>(this); if (fact != null) { toRetract.Add(tuple, fact); } }
private void RetractBinding(IExecutionContext context, Tuple tuple, TupleFactList toRetract) { var fact = context.WorkingMemory.RemoveState <Fact>(this, tuple); if (fact != null) { toRetract.Add(tuple, fact); } }
public override void PropagateRetract(IExecutionContext context, IList <Tuple> tuples) { var toRetract = new TupleFactList(); foreach (var tuple in tuples) { var fact = tuple.GetState <Fact>(this); toRetract.Add(tuple, fact); } MemoryNode.PropagateRetract(context, toRetract); }
public override void PropagateUpdate(IExecutionContext context, List <Tuple> tuples) { var toUpdate = new TupleFactList(); foreach (var tuple in tuples) { if (tuple.GetQuantifier(this).Value > 0) { toUpdate.Add(tuple, null); } } MemoryNode.PropagateUpdate(context, toUpdate); }
public override void PropagateAssert(IExecutionContext context, IList <Tuple> tuples) { var toAssert = new TupleFactList(); foreach (var tuple in tuples) { var value = BindingExpression.Invoke(context, tuple); var fact = new Fact(value, ResultType); tuple.SetState(this, fact); toAssert.Add(tuple, fact); } MemoryNode.PropagateAssert(context, toAssert); }
public override void PropagateRetract(IExecutionContext context, List <Tuple> tuples) { var toRetract = new TupleFactList(); foreach (var tuple in tuples) { if (tuple.RemoveQuantifier(this).Value > 0) { toRetract.Add(tuple, null); } } MemoryNode.PropagateRetract(context, toRetract); }
private void PropagateAggregateAsserts(IExecutionContext context, Aggregation aggregation) { var asserts = new TupleFactList(); foreach (var assert in aggregation.Asserts) { var fact = ToAggregateFact(context, assert.ResultObject); asserts.Add(assert.Tuple, fact); } if (asserts.Count > 0) { MemoryNode.PropagateAssert(context, asserts); } }
private void PropagateAggregateUpdates(IExecutionContext context, Aggregation aggregation) { var updates = new TupleFactList(); foreach (var update in aggregation.Updates) { var fact = ToAggregateFact(context, update.ResultObject); updates.Add(update.Tuple, fact); } if (updates.Count > 0) { MemoryNode.PropagateUpdate(context, updates); } }
public override void PropagateRetract(IExecutionContext context, IList <Tuple> tuples) { var joinedSets = JoinedSets(context, tuples); var toRetract = new TupleFactList(); foreach (var set in joinedSets) { foreach (var fact in set.Facts) { toRetract.Add(set.Tuple, fact); } } MemoryNode.PropagateRetract(context, toRetract); }
public override void PropagateRetract(IExecutionContext context, IList <Tuple> tuples) { var toRetract = new TupleFactList(); foreach (var tuple in tuples) { IAggregator aggregator = GetAggregator(tuple); foreach (var aggregate in aggregator.Aggregates) { Fact aggregateFact = ToAggregateFact(context, aggregate); toRetract.Add(tuple, aggregateFact); } } MemoryNode.PropagateRetract(context, toRetract); }
public override void PropagateAssert(IExecutionContext context, IList <Fact> facts) { var joinedSets = JoinedSets(context, facts); var toAssert = new TupleFactList(); foreach (var set in joinedSets) { foreach (var fact in set.Facts) { if (MatchesConditions(context, set.Tuple, fact)) { toAssert.Add(set.Tuple, fact); } } } MemoryNode.PropagateAssert(context, toAssert); }
public override void PropagateUpdate(IExecutionContext context, IList <Tuple> tuples) { var toUpdate = new TupleFactList(); foreach (var tuple in tuples) { var fact = tuple.GetState <Fact>(this); var oldValue = fact.RawObject; var newValue = BindingExpression.Invoke(context, tuple); if (!ReferenceEquals(oldValue, newValue)) { fact.RawObject = newValue; } toUpdate.Add(tuple, fact); } MemoryNode.PropagateUpdate(context, toUpdate); }
private void AssertBinding(IExecutionContext context, Tuple tuple, TupleFactList toAssert) { try { var value = BindingExpression.Invoke(context, NodeInfo, tuple); var fact = new Fact(value, ResultType); tuple.SetState(this, fact); toAssert.Add(tuple, fact); } catch (ExpressionEvaluationException e) { if (!e.IsHandled) { throw new RuleLhsExpressionEvaluationException("Failed to evaluate binding expression", e.Expression.ToString(), e.InnerException); } } }
private void UpdateBinding(IExecutionContext context, Tuple tuple, Fact fact, TupleFactList toUpdate, TupleFactList toRetract) { try { var value = BindingExpression.Invoke(context, NodeInfo, tuple); fact.RawObject = value; toUpdate.Add(tuple, fact); } catch (ExpressionEvaluationException e) { if (!e.IsHandled) { throw new RuleLhsExpressionEvaluationException("Failed to evaluate binding expression", e.Expression.ToString(), e.InnerException); } RetractBinding(tuple, toRetract); } }
public override void PropagateAssert(IExecutionContext context, List <Tuple> tuples) { var joinedSets = JoinedSets(context, tuples); var toAssert = new TupleFactList(); foreach (var set in joinedSets) { var quantifier = set.Tuple.CreateQuantifier(this); foreach (var fact in set.Facts) { quantifier.Value++; } if (quantifier.Value > 0) { toAssert.Add(set.Tuple, null); } } MemoryNode.PropagateAssert(context, 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); } } }
private void UpdateBinding(IExecutionContext context, Tuple tuple, Fact fact, TupleFactList toUpdate, TupleFactList toRetract) { try { var value = BindingExpression.Invoke(tuple); fact.RawObject = value; toUpdate.Add(tuple, fact); } catch (Exception e) { bool isHandled = false; context.EventAggregator.RaiseBindingFailed(context.Session, e, BindingExpression.Expression, tuple, ref isHandled); if (!isHandled) { throw new RuleExpressionEvaluationException("Failed to evaluate binding expression", BindingExpression.Expression.ToString(), e); } RetractBinding(tuple, toRetract); } }
public override void PropagateRetract(IExecutionContext context, List <Tuple> tuples) { var toRetract = new TupleFactList(); using (var counter = PerfCounter.Retract(context, this)) { foreach (var tuple in tuples) { if (context.RemoveQuantifier(this, tuple).Value > 0) { toRetract.Add(tuple, null); } } counter.AddInputs(tuples.Count); counter.AddOutputs(toRetract.Count); } MemoryNode.PropagateRetract(context, toRetract); }
private void AssertBinding(IExecutionContext context, Tuple tuple, TupleFactList toAssert) { try { var value = BindingExpression.Invoke(tuple); var fact = new Fact(value, ResultType); tuple.SetState(this, fact); toAssert.Add(tuple, fact); } catch (Exception e) { bool isHandled = false; context.EventAggregator.RaiseBindingFailed(context.Session, e, BindingExpression.Expression, tuple, ref isHandled); if (!isHandled) { throw new RuleExpressionEvaluationException("Failed to evaluate binding expression", BindingExpression.Expression.ToString(), e); } } }
public override void PropagateUpdate(IExecutionContext context, IList <Tuple> tuples) { if (_isSubnetJoin) { return; } var toUpdate = new TupleFactList(); foreach (var tuple in tuples) { IAggregator aggregator = GetAggregator(tuple); foreach (var aggregate in aggregator.Aggregates) { Fact aggregateFact = ToAggregateFact(context, aggregate); toUpdate.Add(tuple, aggregateFact); } } MemoryNode.PropagateUpdate(context, toUpdate); }
public override void PropagateUpdate(IExecutionContext context, List <Tuple> tuples) { var toUpdate = new TupleFactList(); using (var counter = PerfCounter.Update(context, this)) { foreach (var tuple in tuples) { if (context.GetQuantifier(this, tuple).Value == 0) { toUpdate.Add(tuple, null); } } counter.AddInputs(tuples.Count); counter.AddOutputs(toUpdate.Count); } MemoryNode.PropagateUpdate(context, toUpdate); }
public override void PropagateRetract(IExecutionContext context, List <Fact> facts) { var joinedSets = JoinedSets(context, facts); var toRetract = new TupleFactList(); foreach (var set in joinedSets) { var quantifier = set.Tuple.GetQuantifier(this); int startingCount = quantifier.Value; foreach (var fact in set.Facts) { quantifier.Value--; } if (startingCount > 0 && quantifier.Value == 0) { toRetract.Add(set.Tuple, null); } } MemoryNode.PropagateRetract(context, toRetract); }
public override void PropagateRetract(IExecutionContext context, List <Tuple> tuples) { var toRetract = new TupleFactList(); using (var counter = PerfCounter.Retract(context, this)) { var joinedSets = JoinedSets(context, tuples); foreach (var set in joinedSets) { foreach (var fact in set.Facts) { toRetract.Add(set.Tuple, fact); } } counter.AddInputs(tuples.Count); counter.AddOutputs(toRetract.Count); } MemoryNode.PropagateRetract(context, toRetract); }
public override void PropagateUpdate(IExecutionContext context, IList <Tuple> tuples) { var toUpdate = new TupleFactList(); var joinedSets = JoinedSets(context, tuples); foreach (var set in joinedSets) { if (_isSubnetJoin && HasRightFacts(context, set)) { //Update already propagated from the right continue; } IAggregator aggregator = GetAggregator(set.Tuple); foreach (var aggregate in aggregator.Aggregates) { Fact aggregateFact = ToAggregateFact(context, aggregate); toUpdate.Add(set.Tuple, aggregateFact); } } MemoryNode.PropagateUpdate(context, toUpdate); }
public override void PropagateAssert(IExecutionContext context, List <Tuple> tuples) { var toAssert = new TupleFactList(); using (var counter = PerfCounter.Assert(context, this)) { var joinedSets = JoinedSets(context, tuples); foreach (var set in joinedSets) { var quantifier = context.CreateQuantifier(this, set.Tuple); quantifier.Value += set.Facts.Count; if (quantifier.Value > 0) { toAssert.Add(set.Tuple, null); } } counter.AddInputs(tuples.Count); counter.AddOutputs(toAssert.Count); } MemoryNode.PropagateAssert(context, toAssert); }
public override void PropagateAssert(IExecutionContext context, IList <Fact> facts) { var joinedSets = JoinedSets(context, facts); var toRetract = new TupleFactList(); foreach (var set in joinedSets) { var quantifier = set.Tuple.Quantifier(this); int startingCount = quantifier.Value; foreach (var fact in set.Facts) { if (MatchesConditions(context, set.Tuple, fact)) { quantifier.Value++; } } if (startingCount == 0 && quantifier.Value > 0) { toRetract.Add(set.Tuple, null); } } MemoryNode.PropagateRetract(context, toRetract); }
public override void PropagateAssert(IExecutionContext context, List <Fact> facts) { var toAssert = new TupleFactList(); using (var counter = PerfCounter.Assert(context, this)) { var joinedSets = JoinedSets(context, facts); foreach (var set in joinedSets) { foreach (var fact in set.Facts) { if (MatchesConditions(context, set.Tuple, fact)) { toAssert.Add(set.Tuple, fact); } } } counter.AddInputs(facts.Count); counter.AddOutputs(toAssert.Count); } MemoryNode.PropagateAssert(context, toAssert); }
public override void PropagateRetract(IExecutionContext context, List <Fact> facts) { var toRetract = new TupleFactList(); using (var counter = PerfCounter.Retract(context, this)) { var joinedSets = JoinedSets(context, facts); foreach (var set in joinedSets) { var quantifier = context.GetQuantifier(this, set.Tuple); int startingCount = quantifier.Value; quantifier.Value -= set.Facts.Count; if (startingCount > 0 && quantifier.Value == 0) { toRetract.Add(set.Tuple, null); } } counter.AddInputs(facts.Count); counter.AddOutputs(toRetract.Count); } MemoryNode.PropagateRetract(context, toRetract); }