public void UpdateTable(
            ICollection<EventBean> eventsUnsafeIter,
            TableInstance instance,
            EventBean[] eventsPerStream,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            // copy references to array - as it is allowed to pass an index-originating collection
            // and those same indexes are being changed now
            var events = new EventBean[eventsUnsafeIter.Count];
            var count = 0;
            foreach (var @event in eventsUnsafeIter) {
                events[count++] = @event;
            }

            // remove from affected indexes
            foreach (var affectedIndexName in affectedIndexNames) {
                var index = instance.GetIndex(affectedIndexName);
                index.Remove(events, instance.AgentInstanceContext);
            }

            // update (no-copy unless original values required)
            foreach (var @event in events) {
                eventsPerStream[0] = @event;
                var updatedEvent = (ObjectArrayBackedEventBean) @event;

                // if "initial.property" is part of the assignment expressions, provide initial value event
                if (updateHelper.IsRequiresStream2InitialValueEvent) {
                    var prev = new object[updatedEvent.Properties.Length];
                    Array.Copy(updatedEvent.Properties, 0, prev, 0, prev.Length);
                    eventsPerStream[2] = new ObjectArrayEventBean(prev, updatedEvent.EventType);
                }

                // apply in-place updates
                updateHelper.UpdateNoCopy(updatedEvent, eventsPerStream, exprEvaluatorContext);
                instance.HandleRowUpdated(updatedEvent);
            }

            // add to affected indexes
            foreach (var affectedIndexName in affectedIndexNames) {
                var index = instance.GetIndex(affectedIndexName);
                index.Add(events, instance.AgentInstanceContext);
            }
        }
Esempio n. 2
0
        public void UpdateTable(
            ICollection<EventBean> eventsUnsafeIter,
            TableInstance instance,
            EventBean[] eventsPerStream,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            // update (no-copy unless original values required)
            foreach (EventBean @event in eventsUnsafeIter) {
                eventsPerStream[0] = @event;
                ObjectArrayBackedEventBean updatedEvent = (ObjectArrayBackedEventBean) @event;

                // if "initial.property" is part of the assignment expressions, provide initial value event
                if (updateHelper.IsRequiresStream2InitialValueEvent) {
                    object[] prev = new object[updatedEvent.Properties.Length];
                    Array.Copy(updatedEvent.Properties, 0, prev, 0, prev.Length);
                    eventsPerStream[2] = new ObjectArrayEventBean(prev, updatedEvent.EventType);
                }

                // apply in-place updates
                updateHelper.UpdateNoCopy(updatedEvent, eventsPerStream, exprEvaluatorContext);
                instance.HandleRowUpdated(updatedEvent);
            }
        }