Exemple #1
0
        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);
        }
Exemple #2
0
        private void PropagateAggregation(IExecutionContext context, Aggregation aggregation)
        {
            foreach (var aggregateList in aggregation.AggregateLists)
            {
                if (aggregateList.Count == 0)
                {
                    continue;
                }

                switch (aggregateList.Action)
                {
                case AggregationAction.Added:
                    MemoryNode.PropagateAssert(context, aggregateList);
                    break;

                case AggregationAction.Modified:
                    MemoryNode.PropagateUpdate(context, aggregateList);
                    break;

                case AggregationAction.Removed:
                    MemoryNode.PropagateRetract(context, aggregateList);
                    break;
                }
            }
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 private void PropagateAggregateUpdate(IExecutionContext context, Tuple tuple, Fact aggregateFact)
 {
     if (aggregateFact != null)
     {
         MemoryNode.PropagateUpdate(context, tuple, aggregateFact);
     }
 }
Exemple #5
0
        public void PropagateUpdate(IExecutionContext context, List <Fact> facts)
        {
            var toUpdate  = new List <Fact>();
            var toRetract = new List <Fact>();

            foreach (var fact in facts)
            {
                if (IsSatisfiedBy(context, fact))
                {
                    toUpdate.Add(fact);
                }
                else
                {
                    toRetract.Add(fact);
                }
            }

            if (toUpdate.Count > 0)
            {
                foreach (var childNode in ChildNodes)
                {
                    childNode.PropagateUpdate(context, toUpdate);
                }
                MemoryNode?.PropagateUpdate(context, toUpdate);
            }
            if (toRetract.Count > 0)
            {
                UnsatisfiedFactUpdate(context, toRetract);
            }
        }
Exemple #6
0
        public override void PropagateUpdate(IExecutionContext context, List <Tuple> tuples)
        {
            var toAssert  = new TupleFactList();
            var toUpdate  = new TupleFactList();
            var toRetract = new TupleFactList();

            using (var counter = PerfCounter.Update(context, this))
            {
                foreach (var tuple in tuples)
                {
                    var fact = context.WorkingMemory.GetState <Fact>(this, tuple);
                    if (fact != null)
                    {
                        UpdateBinding(context, tuple, fact, toUpdate, toRetract);
                    }
                    else
                    {
                        AssertBinding(context, tuple, toAssert);
                    }
                }

                counter.AddItems(tuples.Count);
            }
            MemoryNode.PropagateRetract(context, toRetract);
            MemoryNode.PropagateUpdate(context, toUpdate);
            MemoryNode.PropagateAssert(context, toAssert);
        }
Exemple #7
0
 protected void PropagateUpdateInternal(IExecutionContext context, List <Fact> facts)
 {
     if (facts.Count == 0)
     {
         return;
     }
     foreach (var childNode in ChildNodes)
     {
         childNode.PropagateUpdate(context, facts);
     }
     MemoryNode?.PropagateUpdate(context, facts);
 }
Exemple #8
0
        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);
        }
Exemple #9
0
        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);
            }
        }
Exemple #10
0
        public override void PropagateUpdate(IExecutionContext context, Tuple tuple)
        {
            IEnumerable <Fact> facts = RightSource.GetFacts(context);

            foreach (Fact fact in facts)
            {
                if (MatchesConditions(context, tuple, fact))
                {
                    MemoryNode.PropagateUpdate(context, tuple, fact);
                }
                else
                {
                    MemoryNode.PropagateRetract(context, tuple, fact);
                }
            }
        }
Exemple #11
0
        public override void PropagateUpdate(IExecutionContext context, Fact fact)
        {
            IEnumerable <Tuple> tuples = LeftSource.GetTuples(context);

            foreach (Tuple tuple in tuples)
            {
                if (MatchesConditions(context, tuple, fact))
                {
                    MemoryNode.PropagateUpdate(context, tuple, fact);
                }
                else
                {
                    MemoryNode.PropagateRetract(context, tuple, fact);
                }
            }
        }
Exemple #12
0
 public void PropagateUpdate(IExecutionContext context, Fact fact)
 {
     if (IsSatisfiedBy(fact))
     {
         foreach (var childNode in ChildNodes)
         {
             childNode.PropagateUpdate(context, fact);
         }
         if (MemoryNode != null)
         {
             MemoryNode.PropagateUpdate(context, fact);
         }
     }
     else
     {
         UnsatisfiedFactUpdate(context, fact);
     }
 }
Exemple #13
0
        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);
        }
Exemple #14
0
        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);
        }
Exemple #15
0
        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);
        }
Exemple #16
0
        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);
        }
Exemple #17
0
        public override void PropagateUpdate(IExecutionContext context, List <Tuple> tuples)
        {
            var toAssert  = new TupleFactList();
            var toUpdate  = new TupleFactList();
            var toRetract = new TupleFactList();

            foreach (var tuple in tuples)
            {
                var fact = tuple.GetState <Fact>(this);
                if (fact != null)
                {
                    UpdateBinding(context, tuple, fact, toUpdate, toRetract);
                }
                else
                {
                    AssertBinding(context, tuple, toAssert);
                }
            }
            MemoryNode.PropagateRetract(context, toRetract);
            MemoryNode.PropagateUpdate(context, toUpdate);
            MemoryNode.PropagateAssert(context, toAssert);
        }
Exemple #18
0
 private void UpdateTuple(IExecutionContext context, Tuple tuple)
 {
     MemoryNode.PropagateUpdate(context, tuple, null);
 }