Exemple #1
0
        public string[][] GetUniqueIndexes(NamedWindowProcessorInstance processorInstance)
        {
            IList <string[]> unique = null;

            if (processorInstance != null)
            {
                var indexDescriptors = processorInstance.IndexDescriptors;
                foreach (var index in indexDescriptors)
                {
                    if (!index.IsUnique)
                    {
                        continue;
                    }
                    var uniqueKeys = IndexedPropDesc.GetIndexProperties(index.HashIndexedProps);
                    if (unique == null)
                    {
                        unique = new List <string[]>();
                    }
                    unique.Add(uniqueKeys);
                }
            }
            if (_optionalUniqueKeyProps != null)
            {
                if (unique == null)
                {
                    unique = new List <string[]>();
                }
                unique.Add(_optionalUniqueKeyProps.ToArray());
            }
            if (unique == null)
            {
                return(null);
            }
            return(unique.ToArray());
        }
        public NamedWindowConsumerView AddConsumer(NamedWindowConsumerDesc consumerDesc, bool isSubselect)
        {
            var consumerCallback = new ProxyNamedWindowConsumerCallback()
            {
                ProcGetEnumerator = () => {
                    NamedWindowProcessorInstance instance = _namedWindowProcessor.GetProcessorInstance(_agentInstanceContext);
                    if (instance == null)
                    {
                        // this can happen on context-partition "output when terminated"
                        return(GetEnumerator());
                    }
                    return(instance.TailViewInstance.GetEnumerator());
                },
                ProcStopped = (namedWindowConsumerView) => {
                    RemoveConsumer(namedWindowConsumerView);
                }
            };

            // Construct consumer view, allow a callback to this view to remove the consumer
            bool audit        = AuditEnum.STREAM.GetAudit(consumerDesc.AgentInstanceContext.StatementContext.Annotations) != null;
            var  consumerView = new NamedWindowConsumerView(ExprNodeUtility.GetEvaluators(consumerDesc.FilterList), consumerDesc.OptPropertyEvaluator, _tailView.EventType, consumerCallback, consumerDesc.AgentInstanceContext, audit);

            // indicate to virtual data window that a consumer was added
            VirtualDWView virtualDWView = _rootViewInstance.VirtualDataWindow;

            if (virtualDWView != null)
            {
                virtualDWView.VirtualDataWindow.HandleEvent(
                    new VirtualDataWindowEventConsumerAdd(_tailView.EventType.Name, consumerView, consumerDesc.AgentInstanceContext.StatementName, consumerDesc.AgentInstanceContext.AgentInstanceId, ExprNodeUtility.ToArray(consumerDesc.FilterList), _agentInstanceContext));
            }

            // Keep a list of consumer views per statement to accommodate joins and subqueries
            var viewsPerStatements = _consumersInContext.Get(consumerDesc.AgentInstanceContext.EpStatementAgentInstanceHandle);

            if (viewsPerStatements == null)
            {
                viewsPerStatements = new CopyOnWriteList <NamedWindowConsumerView>();

                // avoid concurrent modification as a thread may currently iterate over consumers as its dispatching
                // without the engine lock
                var newConsumers = NamedWindowUtil.CreateConsumerMap(_tailView.IsPrioritized);
                newConsumers.PutAll(_consumersInContext);
                newConsumers.Put(consumerDesc.AgentInstanceContext.EpStatementAgentInstanceHandle, viewsPerStatements);
                _consumersInContext = newConsumers;
            }
            if (isSubselect)
            {
                viewsPerStatements.Insert(0, consumerView);
            }
            else
            {
                viewsPerStatements.Add(consumerView);
            }

            return(consumerView);
        }
Exemple #3
0
        public void ClearProcessorInstances()
        {
            if (_contextName == null)
            {
                NamedWindowProcessorInstance instance = ProcessorInstanceNoContext;
                if (instance != null)
                {
                    instance.Dispose();
                }
                return;
            }
            var cpids = ProcessorInstancesAll;

            foreach (int cpid in cpids)
            {
                NamedWindowProcessorInstance instance = GetProcessorInstance(cpid);
                if (instance != null)
                {
                    instance.Dispose();
                }
                return;
            }
        }