public override void PropagateUpdate(IExecutionContext context, IList <Fact> facts) { var joinedSets = JoinedSets(context, facts); var aggregation = new Aggregation(); foreach (var set in joinedSets) { if (set.Facts.Count == 0) { continue; } var matchingFacts = GetMatchingFacts(context, set); if (matchingFacts.Count > 0) { IFactAggregator aggregator = GetFactAggregator(set.Tuple); if (aggregator != null) { UpdateInAggregate(context, aggregator, aggregation, set.Tuple, matchingFacts); } else { var fullSet = JoinedSet(context, set.Tuple); var allMatchingFacts = GetMatchingFacts(context, fullSet); aggregator = CreateFactAggregator(fullSet.Tuple); AddToAggregate(context, aggregator, aggregation, fullSet.Tuple, allMatchingFacts); } } } PropagateAggregation(context, aggregation); }
public override void PropagateUpdate(IExecutionContext context, IList <Tuple> tuples) { var joinedSets = JoinedSets(context, tuples); var aggregation = new Aggregation(); foreach (var set in joinedSets) { IFactAggregator aggregator = GetFactAggregator(set.Tuple); if (aggregator != null) { if (_isSubnetJoin && HasRightFacts(context, set)) { //Update already propagated from the right continue; } var matchingFacts = GetMatchingFacts(context, set); UpdateInAggregate(context, aggregator, aggregation, set.Tuple, matchingFacts); } else { var matchingFacts = GetMatchingFacts(context, set); aggregator = CreateFactAggregator(set.Tuple); AddToAggregate(context, aggregator, aggregation, set.Tuple, matchingFacts); } } PropagateAggregation(context, aggregation); }
public override void PropagateUpdate(IExecutionContext context, List <Tuple> tuples) { var aggregationContext = new AggregationContext(context, NodeInfo); var aggregation = new Aggregation(); using (var counter = PerfCounter.Update(context, this)) { var joinedSets = JoinedSets(context, tuples); foreach (var set in joinedSets) { IFactAggregator aggregator = GetFactAggregator(context, set.Tuple); if (aggregator != null) { if (_isSubnetJoin && set.Facts.Count > 0) { //Update already propagated from the right continue; } UpdateInAggregate(aggregationContext, aggregator, aggregation, set.Tuple, set.Facts); } else { var matchingFacts = set.Facts; aggregator = CreateFactAggregator(context, set.Tuple); AddToAggregate(aggregationContext, aggregator, aggregation, set.Tuple, matchingFacts); } } counter.AddInputs(tuples.Count); counter.AddOutputs(aggregation.Count); } PropagateAggregation(context, aggregation); }
public override void PropagateRetract(IExecutionContext context, List <Fact> facts) { var aggregationContext = new AggregationContext(context, NodeInfo); var aggregation = new Aggregation(); using (var counter = PerfCounter.Retract(context, this)) { var joinedSets = JoinedSets(context, facts); foreach (var set in joinedSets) { if (set.Facts.Count == 0) { continue; } IFactAggregator aggregator = GetFactAggregator(context, set.Tuple); if (aggregator != null) { RetractFromAggregate(aggregationContext, aggregator, aggregation, set.Tuple, set.Facts); } } counter.AddInputs(facts.Count); counter.AddOutputs(aggregation.Count); } PropagateAggregation(context, aggregation); }
public override void PropagateAssert(IExecutionContext context, List <Fact> facts) { var aggregationContext = new AggregationContext(context, NodeInfo); var aggregation = new Aggregation(); using (var counter = PerfCounter.Assert(context, this)) { var joinedSets = JoinedSets(context, facts); foreach (var set in joinedSets) { if (set.Facts.Count == 0) { continue; } IFactAggregator aggregator = GetFactAggregator(context, set.Tuple); if (aggregator == null) { aggregator = CreateFactAggregator(context, set.Tuple); var originalSet = JoinedSet(context, set.Tuple); var matchingOriginalFacts = originalSet.Facts; AddToAggregate(aggregationContext, aggregator, aggregation, originalSet.Tuple, matchingOriginalFacts); } AddToAggregate(aggregationContext, aggregator, aggregation, set.Tuple, set.Facts); } counter.AddInputs(facts.Count); counter.AddOutputs(aggregation.Count); } PropagateAggregation(context, aggregation); }
public override void PropagateUpdate(IExecutionContext context, List <Tuple> tuples) { var aggregationContext = new AggregationContext(context.Session, context.EventAggregator, NodeInfo); var joinedSets = JoinedSets(context, tuples); var aggregation = new Aggregation(); foreach (var set in joinedSets) { IFactAggregator aggregator = GetFactAggregator(set.Tuple); if (aggregator != null) { if (_isSubnetJoin && set.Facts.Count > 0) { //Update already propagated from the right continue; } var matchingFacts = set.Facts; UpdateInAggregate(aggregationContext, aggregator, aggregation, set.Tuple, matchingFacts); } else { var matchingFacts = set.Facts; aggregator = CreateFactAggregator(set.Tuple); AddToAggregate(aggregationContext, aggregator, aggregation, set.Tuple, matchingFacts); } } PropagateAggregation(context, aggregation); }
public override void PropagateAssert(IExecutionContext context, IList <Fact> facts) { var joinedSets = JoinedSets(context, facts); var aggregation = new Aggregation(); foreach (var set in joinedSets) { if (set.Facts.Count == 0) { continue; } var matchingFacts = GetMatchingFacts(context, set); if (matchingFacts.Count > 0) { IFactAggregator aggregator = GetFactAggregator(set.Tuple); if (aggregator == null) { aggregator = CreateFactAggregator(set.Tuple); var originalSet = JoinedSet(context, set.Tuple); var matchingOriginalFacts = GetMatchingFacts(context, originalSet); AddToAggregate(context, aggregator, aggregation, originalSet.Tuple, matchingOriginalFacts); } AddToAggregate(context, aggregator, aggregation, set.Tuple, matchingFacts); } } PropagateAggregation(context, aggregation); }
public override void PropagateAssert(IExecutionContext context, IList <Tuple> tuples) { var joinedSets = JoinedSets(context, tuples); var aggregation = new Aggregation(); foreach (var set in joinedSets) { var matchingFacts = GetMatchingFacts(context, set); IFactAggregator aggregator = CreateFactAggregator(set.Tuple); AddToAggregate(context, aggregator, aggregation, set.Tuple, matchingFacts); } PropagateAggregation(context, aggregation); }
public override void PropagateAssert(IExecutionContext context, List <Tuple> tuples) { var aggregationContext = new AggregationContext(context.Session, context.EventAggregator, NodeInfo); var joinedSets = JoinedSets(context, tuples); var aggregation = new Aggregation(); foreach (var set in joinedSets) { var matchingFacts = set.Facts; IFactAggregator aggregator = CreateFactAggregator(set.Tuple); AddToAggregate(aggregationContext, aggregator, aggregation, set.Tuple, matchingFacts); } PropagateAggregation(context, aggregation); }
public override void PropagateRetract(IExecutionContext context, IList <Tuple> tuples) { var aggregation = new Aggregation(); foreach (var tuple in tuples) { IFactAggregator aggregator = RemoveFactAggregator(tuple); if (aggregator != null) { aggregation.Remove(tuple, aggregator.AggregateFacts); } } PropagateAggregation(context, aggregation); }
private void RetractFromAggregate(AggregationContext context, IFactAggregator aggregator, Aggregation aggregation, Tuple tuple, List <Fact> facts) { try { aggregator.Remove(context, aggregation, tuple, facts); } catch (ExpressionEvaluationException e) { if (!e.IsHandled) { throw new RuleLhsExpressionEvaluationException("Failed to evaluate aggregate expression", e.Expression.ToString(), e.InnerException); } ResetAggregator(aggregation, tuple, aggregator); } }
private void AddToAggregate(IExecutionContext context, IFactAggregator aggregator, Aggregation aggregation, Tuple tuple, IList <Fact> facts) { try { aggregator.Add(aggregation, tuple, facts); } catch (AggregateExpressionException e) { bool isHandled = false; context.EventAggregator.RaiseAggregateFailed(context.Session, e.InnerException, e.Expression, e.Tuple, e.Fact, ref isHandled); if (!isHandled) { throw new RuleExpressionEvaluationException("Failed to evaluate aggregate expression", e.Expression.ToString(), e.InnerException); } ResetAggregator(aggregation, tuple, aggregator); } }
public override void PropagateAssert(IExecutionContext context, List <Tuple> tuples) { var aggregationContext = new AggregationContext(context, NodeInfo); var aggregation = new Aggregation(); using (var counter = PerfCounter.Assert(context, this)) { var joinedSets = JoinedSets(context, tuples); foreach (var set in joinedSets) { IFactAggregator aggregator = CreateFactAggregator(context, set.Tuple); AddToAggregate(aggregationContext, aggregator, aggregation, set.Tuple, set.Facts); } counter.AddInputs(tuples.Count); counter.AddOutputs(aggregation.Count); } PropagateAggregation(context, aggregation); }
public override void PropagateRetract(IExecutionContext context, List <Tuple> tuples) { var aggregation = new Aggregation(); using (var counter = PerfCounter.Retract(context, this)) { foreach (var tuple in tuples) { IFactAggregator aggregator = RemoveFactAggregator(context, tuple); if (aggregator != null) { aggregation.Remove(tuple, aggregator.AggregateFacts); } } counter.AddInputs(tuples.Count); counter.AddOutputs(aggregation.Count); } PropagateAggregation(context, aggregation); }
public override void PropagateRetract(IExecutionContext context, IList <Fact> facts) { var joinedSets = JoinedSets(context, facts); var aggregation = new Aggregation(); foreach (var set in joinedSets) { if (set.Facts.Count == 0) { continue; } var matchingFacts = GetMatchingFacts(context, set); if (matchingFacts.Count > 0) { IFactAggregator aggregator = GetFactAggregator(set.Tuple); if (aggregator != null) { RetractFromAggregate(context, aggregator, aggregation, set.Tuple, set.Facts); } } } PropagateAggregation(context, aggregation); }
private void ResetAggregator(IExecutionContext context, Aggregation aggregation, Tuple tuple, IFactAggregator aggregator) { context.WorkingMemory.RemoveState <IFactAggregator>(this, tuple); aggregation.Remove(tuple, aggregator.AggregateFacts); }
private void ResetAggregator(Aggregation aggregation, Tuple tuple, IFactAggregator aggregator) { tuple.RemoveState <IFactAggregator>(this); aggregation.Remove(tuple, aggregator.AggregateFacts); }