public Object Evaluate(
            EventBean[] eventsPerStream,
            bool isNewData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            AggregationService aggregationServiceAnyPartition)
        {
            if (matchingEvents == null || matchingEvents.Count == 0)
            {
                return(false);
            }
            var aggregationService =
                aggregationServiceAnyPartition.GetContextPartitionAggregationService(
                    exprEvaluatorContext.AgentInstanceId);
            var groupKeys      = aggregationService.GetGroupKeys(exprEvaluatorContext);
            var events         = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var evaluateParams = new EvaluateParams(events, true, exprEvaluatorContext);

            foreach (var groupKey in groupKeys)
            {
                aggregationService.SetCurrentAccess(groupKey, exprEvaluatorContext.AgentInstanceId, null);

                var pass = _havingEval.Evaluate(evaluateParams);
                if ((pass == null) || (false.Equals(pass)))
                {
                    continue;
                }
                return(true);
            }
            return(false);
        }
示例#2
0
        protected override Object EvaluateInternal(
            Object leftResult,
            EventBean[] events,
            bool isNewData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            AggregationService aggregationServiceAnyPartition)
        {
            var aggregationService =
                aggregationServiceAnyPartition.GetContextPartitionAggregationService(
                    exprEvaluatorContext.AgentInstanceId);
            var groupKeys  = aggregationService.GetGroupKeys(exprEvaluatorContext);
            var hasNullRow = false;

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

            foreach (var groupKey in groupKeys)
            {
                if (leftResult == null)
                {
                    return(null);
                }
                aggregationService.SetCurrentAccess(groupKey, exprEvaluatorContext.AgentInstanceId, null);

                if (_havingEval != null)
                {
                    var pass = _havingEval.Evaluate(evaluateParams);
                    if ((pass == null) || (false.Equals(pass)))
                    {
                        continue;
                    }
                }

                Object rightResult;
                if (SelectEval != null)
                {
                    rightResult = SelectEval.Evaluate(evaluateParams);
                }
                else
                {
                    rightResult = events[0].Underlying;
                }

                if (rightResult != null)
                {
                    if (Coercer == null)
                    {
                        var eq = leftResult.Equals(rightResult);
                        if ((IsNot && !eq) || (!IsNot && eq))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        var left  = Coercer.Invoke(leftResult);
                        var right = Coercer.Invoke(rightResult);
                        var eq    = left.Equals(right);
                        if ((IsNot && !eq) || (!IsNot && eq))
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    hasNullRow = true;
                }
            }

            if (hasNullRow)
            {
                return(null);
            }
            return(false);
        }
        protected override Object EvaluateInternal(
            Object leftResult,
            EventBean[] events,
            bool isNewData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            AggregationService aggregationServiceAnyPartition)
        {
            AggregationService aggregationService =
                aggregationServiceAnyPartition.GetContextPartitionAggregationService(
                    exprEvaluatorContext.AgentInstanceId);
            ICollection <Object> groupKeys = aggregationService.GetGroupKeys(exprEvaluatorContext);
            bool hasRows    = false;
            bool hasNullRow = false;

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

            foreach (Object groupKey in groupKeys)
            {
                aggregationService.SetCurrentAccess(groupKey, exprEvaluatorContext.AgentInstanceId, null);
                if (_havingEval != null)
                {
                    var pass = _havingEval.Evaluate(evaluateParams);
                    if ((pass == null) || (false.Equals(pass)))
                    {
                        continue;
                    }
                }
                hasRows = true;

                Object valueRight;
                if (SelectEval != null)
                {
                    valueRight = SelectEval.Evaluate(evaluateParams);
                }
                else
                {
                    valueRight = events[0].Underlying;
                }

                if (valueRight == null)
                {
                    hasNullRow = true;
                }
                else
                {
                    if (leftResult != null)
                    {
                        if (!Computer.Invoke(leftResult, valueRight))
                        {
                            return(false);
                        }
                    }
                }
            }

            if (!hasRows)
            {
                return(true);
            }
            if (leftResult == null)
            {
                return(null);
            }
            if (hasNullRow)
            {
                return(null);
            }
            return(true);
        }