コード例 #1
0
        public static ExcludePlanHint GetHint(
            string[] streamNames,
            StatementRawInfo rawInfo,
            StatementCompileTimeServices services)
        {
            IList<string> hints = HintEnum.EXCLUDE_PLAN.GetHintAssignedValues(rawInfo.Annotations);
            if (hints == null) {
                return null;
            }

            IList<ExprEvaluator> filters = new List<ExprEvaluator>();
            foreach (string hint in hints) {
                if (string.IsNullOrWhiteSpace(hint)) {
                    continue;
                }

                ExprForge forge = ExcludePlanHintExprUtil.ToExpression(hint, rawInfo, services);
                if (Boxing.GetBoxedType(forge.EvaluationType) != typeof(bool?)) {
                    throw new ExprValidationException(
                        "Expression provided for hint " + HintEnum.EXCLUDE_PLAN + " must return a boolean value");
                }

                filters.Add(forge.ExprEvaluator);
            }

            return new ExcludePlanHint(streamNames, filters, services);
        }
コード例 #2
0
        public bool Filter(
            int streamLookup,
            int streamIndexed,
            ExcludePlanFilterOperatorType opType,
            params ExprNode[] exprNodes)
        {
            EventBean @event = ExcludePlanHintExprUtil.ToEvent(
                streamLookup,
                streamIndexed,
                streamNames[streamLookup],
                streamNames[streamIndexed],
                opType.GetName().ToLowerInvariant(),
                exprNodes);
            if (queryPlanLogging && QUERY_PLAN_LOG.IsInfoEnabled) {
                QUERY_PLAN_LOG.Info("Exclude-plan-hint combination " + EventBeanUtility.PrintEvent(@event));
            }

            EventBean[] eventsPerStream = new EventBean[] {@event};

            foreach (ExprEvaluator evaluator in evaluators) {
                var pass = evaluator.Evaluate(eventsPerStream, true, null);
                if (pass != null && true.Equals(pass)) {
                    if (queryPlanLogging && QUERY_PLAN_LOG.IsInfoEnabled) {
                        QUERY_PLAN_LOG.Info("Exclude-plan-hint combination : true");
                    }

                    return true;
                }
            }

            if (queryPlanLogging && QUERY_PLAN_LOG.IsInfoEnabled) {
                QUERY_PLAN_LOG.Info("Exclude-plan-hint combination : false");
            }

            return false;
        }