Exemplo n.º 1
0
        public void ProcessView(EventBean[] newData, EventBean[] oldData, bool isGenerateSynthetic)
        {
            GenerateRemoveStreamJustOnce(isGenerateSynthetic, false);

            // apply to aggregates
            var groupKeysPerLevel = new object[_processor.Prototype.GroupByRollupDesc.Levels.Length];

            EventBean[] eventsPerStream;
            if (newData != null)
            {
                foreach (var aNewData in newData)
                {
                    eventsPerStream = new EventBean[] { aNewData };
                    var groupKeyComplete = _processor.GenerateGroupKey(eventsPerStream, true);
                    foreach (var level in _processor.Prototype.GroupByRollupDesc.Levels)
                    {
                        var groupKey = level.ComputeSubkey(groupKeyComplete);
                        groupKeysPerLevel[level.LevelNumber] = groupKey;
                        if (_outputLimitGroupRepsPerLevel[level.LevelNumber].Push(groupKey, eventsPerStream) == null)
                        {
                            if (_processor.Prototype.IsSelectRStream)
                            {
                                _processor.GenerateOutputBatchedMapUnsorted(false, groupKey, level, eventsPerStream, true, isGenerateSynthetic, _groupRepsOutputLastUnordRStream[level.LevelNumber]);
                            }
                        }
                    }
                    _processor.AggregationService.ApplyEnter(eventsPerStream, groupKeysPerLevel, _processor.AgentInstanceContext);
                }
            }
            if (oldData != null)
            {
                foreach (var anOldData in oldData)
                {
                    eventsPerStream = new EventBean[] { anOldData };
                    var groupKeyComplete = _processor.GenerateGroupKey(eventsPerStream, false);
                    foreach (var level in _processor.Prototype.GroupByRollupDesc.Levels)
                    {
                        var groupKey = level.ComputeSubkey(groupKeyComplete);
                        groupKeysPerLevel[level.LevelNumber] = groupKey;
                        if (_outputLimitGroupRepsPerLevel[level.LevelNumber].Push(groupKey, eventsPerStream) == null)
                        {
                            if (_processor.Prototype.IsSelectRStream)
                            {
                                _processor.GenerateOutputBatchedMapUnsorted(true, groupKey, level, eventsPerStream, false, isGenerateSynthetic, _groupRepsOutputLastUnordRStream[level.LevelNumber]);
                            }
                        }
                    }
                    _processor.AggregationService.ApplyLeave(eventsPerStream, groupKeysPerLevel, _processor.AgentInstanceContext);
                }
            }
        }
        public void ProcessView(
            EventBean[] newData,
            EventBean[] oldData,
            bool isGenerateSynthetic)
        {
            // apply to aggregates
            var groupKeysPerLevel = new object[processor.GroupByRollupDesc.Levels.Length];
            EventBean[] eventsPerStream;
            if (newData != null) {
                foreach (var aNewData in newData) {
                    eventsPerStream = new[] {aNewData};
                    var groupKeyComplete = processor.GenerateGroupKeySingle(eventsPerStream, true);
                    foreach (var level in processor.GroupByRollupDesc.Levels) {
                        var groupKey = level.ComputeSubkey(groupKeyComplete);
                        groupKeysPerLevel[level.LevelNumber] = groupKey;

                        outputLimitGroupRepsPerLevel[level.LevelNumber].Put(groupKey, eventsPerStream);
                        if (processor.IsSelectRStream &&
                            !groupRepsOutputLastUnordRStream[level.LevelNumber].ContainsKey(groupKey)) {
                            processor.GenerateOutputBatchedMapUnsorted(
                                false,
                                groupKey,
                                level,
                                eventsPerStream,
                                true,
                                isGenerateSynthetic,
                                groupRepsOutputLastUnordRStream[level.LevelNumber]);
                        }
                    }

                    processor.AggregationService.ApplyEnter(
                        eventsPerStream,
                        groupKeysPerLevel,
                        processor.GetAgentInstanceContext());
                }
            }

            if (oldData != null) {
                foreach (var anOldData in oldData) {
                    eventsPerStream = new[] {anOldData};
                    var groupKeyComplete = processor.GenerateGroupKeySingle(eventsPerStream, false);
                    foreach (var level in processor.GroupByRollupDesc.Levels) {
                        var groupKey = level.ComputeSubkey(groupKeyComplete);
                        groupKeysPerLevel[level.LevelNumber] = groupKey;

                        outputLimitGroupRepsPerLevel[level.LevelNumber].Put(groupKey, eventsPerStream);
                        if (processor.IsSelectRStream &&
                            !groupRepsOutputLastUnordRStream[level.LevelNumber].ContainsKey(groupKey)) {
                            processor.GenerateOutputBatchedMapUnsorted(
                                false,
                                groupKey,
                                level,
                                eventsPerStream,
                                false,
                                isGenerateSynthetic,
                                groupRepsOutputLastUnordRStream[level.LevelNumber]);
                        }
                    }

                    processor.AggregationService.ApplyLeave(
                        eventsPerStream,
                        groupKeysPerLevel,
                        processor.GetAgentInstanceContext());
                }
            }
        }