示例#1
0
        public override void ApplyEnter(EventBean[] eventsPerStream, Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QAggregationGroupedApplyEnterLeave(true, Aggregators.Length, AccessAggregations.Length, groupByKey);
            }
            AggregationRowPair groupAggregators = AggregatorsPerGroup.Get(groupByKey);

            // The aggregators for this group do not exist, need to create them from the prototypes
            AggregationState[] states;

            if (groupAggregators == null)
            {
                AggregationMethod[] methods = _methodResolutionService.NewAggregators(Aggregators, exprEvaluatorContext.AgentInstanceId, groupByKey, GroupKeyBinding, null);
                states           = _methodResolutionService.NewAccesses(exprEvaluatorContext.AgentInstanceId, IsJoin, AccessAggregations, groupByKey, GroupKeyBinding, null);
                groupAggregators = new AggregationRowPair(methods, states);
                AggregatorsPerGroup.Put(groupByKey, groupAggregators);
            }

            var evaluateParams = new EvaluateParams(eventsPerStream, true, exprEvaluatorContext);

            // For this row, evaluate sub-expressions, enter result
            _currentAggregatorRow = groupAggregators;
            AggregationMethod[] groupAggMethods = groupAggregators.Methods;
            for (int i = 0; i < Evaluators.Length; i++)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QAggNoAccessEnterLeave(true, i, groupAggMethods[i], Aggregators[i].AggregationExpression);
                }
                Object columnResult = Evaluators[i].Evaluate(evaluateParams);
                groupAggMethods[i].Enter(columnResult);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AAggNoAccessEnterLeave(true, i, groupAggMethods[i]);
                }
            }

            states = _currentAggregatorRow.States;
            for (int i = 0; i < states.Length; i++)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QAggAccessEnterLeave(true, i, states[i], AccessAggregations[i].AggregationExpression);
                }
                states[i].ApplyEnter(eventsPerStream, exprEvaluatorContext);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AAggAccessEnterLeave(true, i, states[i]);
                }
            }

            InternalHandleUpdated(groupByKey, groupAggregators);
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AAggregationGroupedApplyEnterLeave(true);
            }
        }
        public override void ApplyEnter(EventBean[] eventsPerStream, Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QAggregationGroupedApplyEnterLeave(true, Aggregators.Length, 0, groupByKey);
            }
            HandleRemovedKeys();

            // The aggregators for this group do not exist, need to create them from the prototypes
            AggregationMethodRow row;

            AggregationMethod[] groupAggregators;
            if (!_aggregatorsPerGroup.TryGetValue(groupByKey, out row))
            {
                groupAggregators = _methodResolutionService.NewAggregators(Aggregators, exprEvaluatorContext.AgentInstanceId, groupByKey, GroupKeyBinding, null);
                row = new AggregationMethodRow(_methodResolutionService.GetCurrentRowCount(groupAggregators, null) + 1, groupAggregators);
                _aggregatorsPerGroup[groupByKey] = row;
            }
            else
            {
                groupAggregators = row.Methods;
                row.IncreaseRefcount();
            }

            var evaluateParams = new EvaluateParams(eventsPerStream, true, exprEvaluatorContext);

            // For this row, evaluate sub-expressions, enter result
            _currentAggregatorRow = groupAggregators;

            var evaluators       = Evaluators;
            var evaluatorsLength = evaluators.Length;

            for (var ii = 0; ii < evaluatorsLength; ii++)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QAggNoAccessEnterLeave(true, ii, groupAggregators[ii], Aggregators[ii].AggregationExpression);
                }
                groupAggregators[ii].Enter(evaluators[ii].Evaluate(evaluateParams));
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AAggNoAccessEnterLeave(true, ii, groupAggregators[ii]);
                }
            }
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AAggregationGroupedApplyEnterLeave(true);
            }
        }
 public override AggregationService MakeService(AgentInstanceContext agentInstanceContext, MethodResolutionService methodResolutionService)
 {
     AggregationState[]  topStates  = methodResolutionService.NewAccesses(agentInstanceContext.AgentInstanceId, isJoin, accessAggregations);
     AggregationMethod[] topMethods = methodResolutionService.NewAggregators(base.Aggregators, agentInstanceContext.AgentInstanceId);
     return(new AggSvcGroupByRefcountedWAccessRollupImpl(
                Evaluators, Aggregators, GroupKeyBinding, methodResolutionService, accessors, accessAggregations, isJoin, groupByRollupDesc, topMethods, topStates));
 }
 public override AggregationService MakeService(
     AgentInstanceContext agentInstanceContext,
     MethodResolutionService methodResolutionService)
 {
     AggregationMethod[] aggregatorsAgentInstance = methodResolutionService.NewAggregators(
         base.Aggregators, agentInstanceContext.AgentInstanceId);
     return(new AggSvcGroupAllNoAccessImpl(Evaluators, aggregatorsAgentInstance, Aggregators));
 }
        public void ApplyEnter(EventBean[] eventsPerStream, object groupByKeyProvided, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QAggregationGroupedApplyEnterLeave(true, localGroupByPlan.NumMethods, localGroupByPlan.NumAccess, groupByKeyProvided);
            }
            HandleRemovedKeys();

            if (localGroupByPlan.OptionalLevelTop != null)
            {
                if (AggregatorsTopLevel == null)
                {
                    AggregatorsTopLevel = methodResolutionService.NewAggregators(localGroupByPlan.OptionalLevelTop.MethodFactories, exprEvaluatorContext.AgentInstanceId, null, null, null);
                    StatesTopLevel      = methodResolutionService.NewAccesses(exprEvaluatorContext.AgentInstanceId, isJoin, localGroupByPlan.OptionalLevelTop.StateFactories, null, null, null);
                }
                AggregateIntoEnter(localGroupByPlan.OptionalLevelTop, AggregatorsTopLevel, StatesTopLevel, eventsPerStream, exprEvaluatorContext);
                InternalHandleUpdatedTop();
            }

            for (var levelNum = 0; levelNum < localGroupByPlan.AllLevels.Length; levelNum++)
            {
                var level         = localGroupByPlan.AllLevels[levelNum];
                var partitionEval = level.PartitionEvaluators;
                var groupByKey    = ComputeGroupKey(level, groupByKeyProvided, partitionEval, eventsPerStream, true, exprEvaluatorContext);
                var row           = AggregatorsPerLevelAndGroup[levelNum].Get(groupByKey);
                if (row == null)
                {
                    var rowAggregators = methodResolutionService.NewAggregators(level.MethodFactories, exprEvaluatorContext.AgentInstanceId, groupByKey, null, null);
                    var rowStates      = methodResolutionService.NewAccesses(exprEvaluatorContext.AgentInstanceId, isJoin, level.StateFactories, groupByKey, null, null);
                    row = new AggregationMethodPairRow(methodResolutionService.GetCurrentRowCount(rowAggregators, rowStates) + 1, rowAggregators, rowStates);
                    AggregatorsPerLevelAndGroup[levelNum].Put(groupByKey, row);
                }
                else
                {
                    row.IncreaseRefcount();
                }

                AggregateIntoEnter(level, row.Methods, row.States, eventsPerStream, exprEvaluatorContext);
                InternalHandleUpdatedGroup(levelNum, groupByKey, row);
            }
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AAggregationGroupedApplyEnterLeave(true);
            }
        }
 public override AggregationService MakeService(
     AgentInstanceContext agentInstanceContext,
     MethodResolutionService methodResolutionService)
 {
     AggregationState[] states = methodResolutionService.NewAccesses(
         agentInstanceContext.AgentInstanceId, IsJoin, AccessAggregations);
     AggregationMethod[] aggregatorsAgentInstance = methodResolutionService.NewAggregators(
         base.Aggregators, agentInstanceContext.AgentInstanceId);
     return(new AggSvcGroupAllMixedAccessImpl(
                Evaluators, aggregatorsAgentInstance, Accessors, states, base.Aggregators, AccessAggregations));
 }
示例#7
0
        public override void ApplyEnter(
            EventBean[] eventsPerStream,
            Object groupByKey,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QAggregationGroupedApplyEnterLeave(true, Aggregators.Length, 0, groupByKey);
            }
            var groupAggregators = _aggregatorsPerGroup.Get(groupByKey);

            // The aggregators for this group do not exist, need to create them from the prototypes
            if (groupAggregators == null)
            {
                groupAggregators = _methodResolutionService.NewAggregators(
                    Aggregators, exprEvaluatorContext.AgentInstanceId, groupByKey, GroupKeyBinding, null);
                _aggregatorsPerGroup.Put(groupByKey, groupAggregators);
            }

            var evaluateParams = new EvaluateParams(eventsPerStream, true, exprEvaluatorContext);

            // For this row, evaluate sub-expressions, enter result
            _currentAggregatorRow = groupAggregators;
            for (var i = 0; i < Evaluators.Length; i++)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QAggNoAccessEnterLeave(true, i, groupAggregators[i], Aggregators[i].AggregationExpression);
                }
                var columnResult = Evaluators[i].Evaluate(evaluateParams);
                groupAggregators[i].Enter(columnResult);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AAggNoAccessEnterLeave(true, i, groupAggregators[i]);
                }
            }
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AAggregationGroupedApplyEnterLeave(true);
            }
        }
示例#8
0
 public override AggregationService MakeService(
     AgentInstanceContext agentInstanceContext,
     MethodResolutionService methodResolutionService,
     bool isSubquery,
     int?subqueryNumber)
 {
     AggregationState[] topStates = methodResolutionService.NewAccesses(
         agentInstanceContext.AgentInstanceId, IsJoin, AccessAggregations, null);
     AggregationMethod[] topMethods = methodResolutionService.NewAggregators(
         base.Aggregators, agentInstanceContext.AgentInstanceId);
     return(new AggSvcGroupByRefcountedWAccessRollupImpl(
                Evaluators, Aggregators, GroupKeyBinding, methodResolutionService, Accessors, AccessAggregations, IsJoin,
                GroupByRollupDesc, topMethods, topStates));
 }
示例#9
0
        public override void SetCurrentAccess(object groupByKey, int agentInstanceId, AggregationGroupByRollupLevel rollupLevel)
        {
            if (!LocalGroupByPlan.AllLevels[0].IsDefaultLevel)
            {
                return;
            }
            var row = AggregatorsPerLevelAndGroup[0].Get(groupByKey);

            if (row != null)
            {
                _currentAggregatorMethods = row.Methods;
                _currentAggregatorStates  = row.States;
            }
            else
            {
                _currentAggregatorMethods = null;
            }

            if (_currentAggregatorMethods == null)
            {
                _currentAggregatorMethods = MethodResolutionService.NewAggregators(LocalGroupByPlan.AllLevels[0].MethodFactories, agentInstanceId, groupByKey, null, null);
                _currentAggregatorStates  = MethodResolutionService.NewAccesses(agentInstanceId, IsJoin, LocalGroupByPlan.AllLevels[0].StateFactories, groupByKey, null, null, null);
            }
        }
示例#10
0
 public AggregationRowPair MakeAggs(int agentInstanceId, object groupByKey, object groupKeyBinding, AggregationServicePassThru passThru)
 {
     AggregationMethod[] methods = _methodResolutionService.NewAggregators(_methodFactories, agentInstanceId, groupByKey, groupKeyBinding, null);
     AggregationState[]  states  = _methodResolutionService.NewAccesses(agentInstanceId, false, _stateFactories, groupByKey, groupKeyBinding, null, passThru);
     return(new AggregationRowPair(methods, states));
 }
示例#11
0
        public override void ApplyEnter(EventBean[] eventsPerStream, Object compositeGroupKey, ExprEvaluatorContext exprEvaluatorContext)
        {
            HandleRemovedKeys();

            var evaluateParams = new EvaluateParams(eventsPerStream, true, exprEvaluatorContext);

            for (var i = 0; i < Evaluators.Length; i++)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QAggregationGroupedRollupEvalParam(true, _methodParameterValues.Length);
                }
                _methodParameterValues[i] = Evaluators[i].Evaluate(evaluateParams);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AAggregationGroupedRollupEvalParam(_methodParameterValues[i]);
                }
            }

            var groupKeyPerLevel = (Object[])compositeGroupKey;

            for (var i = 0; i < groupKeyPerLevel.Length; i++)
            {
                var level    = _rollupLevelDesc.Levels[i];
                var groupKey = groupKeyPerLevel[i];

                AggregationMethodPairRow row;
                if (!level.IsAggregationTop)
                {
                    row = _aggregatorsPerGroup[level.AggregationOffset].Get(groupKey);
                }
                else
                {
                    row = _aggregatorTopGroup;
                }

                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QAggregationGroupedApplyEnterLeave(true, Aggregators.Length, _accessAggregations.Length, groupKey);
                }

                // The aggregators for this group do not exist, need to create them from the prototypes
                AggregationMethod[] groupAggregators;
                AggregationState[]  groupStates;
                if (row == null)
                {
                    groupAggregators = _methodResolutionService.NewAggregators(Aggregators, exprEvaluatorContext.AgentInstanceId, groupKey, GroupKeyBinding, level);
                    groupStates      = _methodResolutionService.NewAccesses(exprEvaluatorContext.AgentInstanceId, _isJoin, _accessAggregations, groupKey, GroupKeyBinding, level);
                    row = new AggregationMethodPairRow(_methodResolutionService.GetCurrentRowCount(groupAggregators, groupStates) + 1, groupAggregators, groupStates);
                    if (!level.IsAggregationTop)
                    {
                        _aggregatorsPerGroup[level.AggregationOffset].Put(groupKey, row);
                    }
                }
                else
                {
                    groupAggregators = row.Methods;
                    groupStates      = row.States;
                    row.IncreaseRefcount();
                }

                // For this row, evaluate sub-expressions, enter result
                _currentAggregatorMethods = groupAggregators;
                _currentAggregatorStates  = groupStates;
                for (var j = 0; j < Evaluators.Length; j++)
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QAggNoAccessEnterLeave(true, j, groupAggregators[j], Aggregators[j].AggregationExpression);
                    }
                    groupAggregators[j].Enter(_methodParameterValues[j]);
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AAggNoAccessEnterLeave(true, j, groupAggregators[j]);
                    }
                }

                for (var j = 0; j < _currentAggregatorStates.Length; j++)
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QAggAccessEnterLeave(true, j, _currentAggregatorStates[j], _accessAggregations[j].AggregationExpression);
                    }
                    _currentAggregatorStates[j].ApplyEnter(eventsPerStream, exprEvaluatorContext);
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AAggAccessEnterLeave(true, j, _currentAggregatorStates[j]);
                    }
                }

                InternalHandleGroupUpdate(groupKey, row, level);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AAggregationGroupedApplyEnterLeave(true);
                }
            }
        }
示例#12
0
        public override void ApplyEnter(EventBean[] eventsPerStream, Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QAggregationGroupedApplyEnterLeave(true, Aggregators.Length, _accessAggregations.Length, groupByKey);
            }
            long currentTime = exprEvaluatorContext.TimeProvider.Time;

            if ((_nextSweepTime == null) || (_nextSweepTime <= currentTime))
            {
                _currentMaxAge           = GetMaxAge(_currentMaxAge);
                _currentReclaimFrequency = GetReclaimFrequency(_currentReclaimFrequency);
                if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
                {
                    Log.Debug("Reclaiming groups older then " + _currentMaxAge + " msec and every " + _currentReclaimFrequency + "msec in frequency");
                }
                _nextSweepTime = currentTime + _currentReclaimFrequency;
                Sweep(currentTime, _currentMaxAge);
            }

            HandleRemovedKeys(); // we collect removed keys lazily on the next enter to reduce the chance of empty-group queries creating empty aggregators temporarily

            AggregationMethodRowAged row = _aggregatorsPerGroup.Get(groupByKey);

            // The aggregators for this group do not exist, need to create them from the prototypes
            AggregationMethod[] groupAggregators;
            AggregationState[]  groupStates;
            if (row == null)
            {
                groupAggregators = _methodResolutionService.NewAggregators(Aggregators, exprEvaluatorContext.AgentInstanceId, groupByKey, GroupKeyBinding, null);
                groupStates      = _methodResolutionService.NewAccesses(exprEvaluatorContext.AgentInstanceId, _isJoin, _accessAggregations, groupByKey, GroupKeyBinding, null);
                row = new AggregationMethodRowAged(_methodResolutionService.GetCurrentRowCount(groupAggregators, groupStates) + 1, currentTime, groupAggregators, groupStates);
                _aggregatorsPerGroup.Put(groupByKey, row);
            }
            else
            {
                groupAggregators = row.Methods;
                groupStates      = row.States;
                row.IncreaseRefcount();
                row.LastUpdateTime = currentTime;
            }

            var evaluateParams = new EvaluateParams(eventsPerStream, true, exprEvaluatorContext);

            // For this row, evaluate sub-expressions, enter result
            _currentAggregatorMethods = groupAggregators;
            _currentAggregatorStates  = groupStates;
            for (int i = 0; i < Evaluators.Length; i++)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QAggNoAccessEnterLeave(true, i, _currentAggregatorMethods[i], Aggregators[i].AggregationExpression);
                }
                Object columnResult = Evaluators[i].Evaluate(evaluateParams);
                groupAggregators[i].Enter(columnResult);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AAggNoAccessEnterLeave(true, i, _currentAggregatorMethods[i]);
                }
            }

            for (int i = 0; i < _currentAggregatorStates.Length; i++)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QAggAccessEnterLeave(true, i, _currentAggregatorStates[i], _accessAggregations[i].AggregationExpression);
                }
                _currentAggregatorStates[i].ApplyEnter(eventsPerStream, exprEvaluatorContext);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AAggAccessEnterLeave(true, i, _currentAggregatorStates[i]);
                }
            }

            InternalHandleUpdated(groupByKey, row);
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AAggregationGroupedApplyEnterLeave(true);
            }
        }
示例#13
0
        public override void ApplyEnter(EventBean[] eventsPerStream, Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QAggregationGroupedApplyEnterLeave(true, Aggregators.Length, AccessAggregations.Length, groupByKey);
            }
            HandleRemovedKeys();

            var row = AggregatorsPerGroup.Get(groupByKey);

            // The aggregators for this group do not exist, need to create them from the prototypes
            AggregationMethod[] groupAggregators;
            AggregationState[]  groupStates;
            if (row == null)
            {
                groupAggregators = _methodResolutionService.NewAggregators(Aggregators, exprEvaluatorContext.AgentInstanceId, groupByKey, GroupKeyBinding, null);
                groupStates      = _methodResolutionService.NewAccesses(exprEvaluatorContext.AgentInstanceId, IsJoin, AccessAggregations, groupByKey, GroupKeyBinding, null, null);
                row = new AggregationMethodPairRow(_methodResolutionService.GetCurrentRowCount(groupAggregators, groupStates) + 1, groupAggregators, groupStates);
                AggregatorsPerGroup.Put(groupByKey, row);
            }
            else
            {
                groupAggregators = row.Methods;
                groupStates      = row.States;
                row.IncreaseRefcount();
            }

            var evaluateParams = new EvaluateParams(eventsPerStream, true, exprEvaluatorContext);

            // For this row, evaluate sub-expressions, enter result
            _currentAggregatorMethods = groupAggregators;
            _currentAggregatorStates  = groupStates;
            for (var j = 0; j < Evaluators.Length; j++)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QAggNoAccessEnterLeave(true, j, groupAggregators[j], Aggregators[j].AggregationExpression);
                }
                var columnResult = Evaluators[j].Evaluate(evaluateParams);
                groupAggregators[j].Enter(columnResult);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AAggNoAccessEnterLeave(true, j, groupAggregators[j]);
                }
            }

            for (var i = 0; i < _currentAggregatorStates.Length; i++)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QAggAccessEnterLeave(true, i, _currentAggregatorStates[i], AccessAggregations[i].AggregationExpression);
                }
                _currentAggregatorStates[i].ApplyEnter(eventsPerStream, exprEvaluatorContext);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AAggAccessEnterLeave(true, i, _currentAggregatorStates[i]);
                }
            }

            InternalHandleGroupUpdate(groupByKey, row);
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AAggregationGroupedApplyEnterLeave(true);
            }
        }