예제 #1
0
        public void AppendFilterPlanPath(
            int indexPath,
            StringBuilder stringBuilder)
        {
            stringBuilder
                .Append("  -path #")
                .Append(indexPath)
                .Append(" there are ")
                .Append(Triplets.Length)
                .Append(" triplets")
                .Append(FilterSpecCompiler.NEWLINE);
            
            if (PathNegate != null) {
                stringBuilder
                    .Append("    -path-negate-expression: ")
                    .Append(ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(PathNegate))
                    .Append(FilterSpecCompiler.NEWLINE);
            }

            var indextriplet = 0;
            foreach (var forge in Triplets) {
                forge.AppendFilterPlanTriplet(indextriplet, stringBuilder);
                indextriplet++;
            }
        }
예제 #2
0
        private void AssertRanges(
            object[][] ranges,
            QueryGraphValueForge value)
        {
            Assert.AreEqual(ranges.Length, value.Items.Count);

            var count = -1;
            foreach (var desc in value.Items)
            {
                count++;
                var r = (QueryGraphValueEntryRangeForge) desc.Entry;

                Assert.AreEqual(ranges[count][3], r.Type);
                Assert.AreEqual(ranges[count][4], ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(desc.IndexExprs[0]));

                if (r is QueryGraphValueEntryRangeRelOpForge)
                {
                    var relOp = (QueryGraphValueEntryRangeRelOpForge) r;
                    Assert.AreEqual(ranges[count][0], GetProp(relOp.Expression));
                }
                else
                {
                    var rangeIn = (QueryGraphValueEntryRangeInForge) r;
                    Assert.AreEqual(ranges[count][1], GetProp(rangeIn.ExprStart));
                    Assert.AreEqual(ranges[count][2], GetProp(rangeIn.ExprEnd));
                }
            }
        }
        public SubordTableLookupStrategyFactoryQuadTreeForge GetSubordinateLookupStrategy(
            string operationName,
            IDictionary<int, ExprNode> positionalExpressions,
            bool isNWOnTrigger,
            int numOuterstreams)
        {
            ExprForge x = positionalExpressions.Get(0).Forge;
            ExprForge y = positionalExpressions.Get(1).Forge;
            ExprForge width = positionalExpressions.Get(2).Forge;
            ExprForge height = positionalExpressions.Get(3).Forge;
            string[] expressions = new string[positionalExpressions.Count];
            foreach (KeyValuePair<int, ExprNode> entry in positionalExpressions) {
                expressions[entry.Key] = ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(entry.Value);
            }

            LookupStrategyDesc lookupStrategyDesc = new LookupStrategyDesc(LookupStrategyType.ADVANCED, expressions);
            return new SubordTableLookupStrategyFactoryQuadTreeForge(
                x,
                y,
                width,
                height,
                isNWOnTrigger,
                numOuterstreams,
                lookupStrategyDesc);
        }
예제 #4
0
        public override void ToPrecedenceFreeEPL(TextWriter writer)
        {
            if (OptionalMaxExpressions == null || OptionalMaxExpressions.IsEmpty()) {
                PatternExpressionUtil.ToPrecedenceFreeEPL(writer, "->", ChildNodes, Precedence);
            }
            else {
                ChildNodes[0].ToEPL(writer, PatternExpressionPrecedenceEnum.MINIMUM);
                for (var i = 1; i < ChildNodes.Count; i++) {
                    ExprNode optionalMaxExpression = null;
                    if (OptionalMaxExpressions.Count > i - 1) {
                        optionalMaxExpression = OptionalMaxExpressions[i - 1];
                    }

                    if (optionalMaxExpression == null) {
                        writer.Write(" -> ");
                    }
                    else {
                        writer.Write(" -[");
                        writer.Write(ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(optionalMaxExpression));
                        writer.Write("]> ");
                    }

                    ChildNodes[i].ToEPL(writer, PatternExpressionPrecedenceEnum.MINIMUM);
                }
            }
        }
예제 #5
0
        private static void LogFilterPlans(
            IList<ExprNode> validatedNodes,
            FilterSpecPlanForge plan,
            EventType eventType,
            string optionalStreamName,
            StatementRawInfo statementRawInfo)
        {
            var buf = new StringBuilder();
            buf
                .Append("Filter plan for statement '")
                .Append(statementRawInfo.StatementName)
                .Append("' filtering event type '")
                .Append(eventType.Name + "'");

            if (optionalStreamName != null) {
                buf.Append(" alias '" + optionalStreamName + "'");
            }
            if (validatedNodes.IsEmpty()) {
                buf.Append(" empty");
            } else {
                var andNode = ExprNodeUtilityMake.ConnectExpressionsByLogicalAndWhenNeeded(validatedNodes);
                var expression = ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(andNode);
                buf
                    .Append(" expression '")
                    .Append(expression)
                    .Append("' for ")
                    .Append(plan.Paths.Length)
                    .Append(" paths");
            }
            buf.Append(Environment.NewLine);

            plan.AppendPlan(buf);

            Log.Info(buf.ToString());
        }
        private static void ComparePlan(string[] expectedCSV)
        {
            var plan = SupportGroupRollupPlanHook.GetPlan();
            var levels = plan.RollupDesc.Levels;
            var received = new string[levels.Length][];
            for (var i = 0; i < levels.Length; i++) {
                var level = levels[i];
                if (level.IsAggregationTop) {
                    received[i] = new string[0];
                }
                else {
                    received[i] = new string[level.RollupKeys.Length];
                    for (var j = 0; j < received[i].Length; j++) {
                        var key = level.RollupKeys[j];
                        received[i][j] =
                            ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(plan.Expressions[key]);
                    }
                }
            }

            Assert.AreEqual(expectedCSV.Length, received.Length, "Received: " + ToCSV(received));
            for (var i = 0; i < expectedCSV.Length; i++) {
                var receivedCSV = ToCSV(received[i]);
                Assert.AreEqual(expectedCSV[i], receivedCSV, "Failed at row " + i);
            }
        }
예제 #7
0
        public static ExprNode ValidateSingleIndexExpr(
            IList<ExprNode> indexes,
            Supplier<string> supplier)
        {
            if (indexes.Count != 1) {
                throw new ExprValidationException(
                    "Incorrect number of index expressions for array operation, expected a single expression returning an integer value but received " +
                    indexes.Count +
                    " expressions for " +
                    supplier.Invoke());
            }

            ExprNode node = indexes[0];
            var evaluationType = node.Forge.EvaluationType;
            if (!evaluationType.IsInt32()) {
                throw new ExprValidationException(
                    "Incorrect index expression for array operation, expected an expression returning an integer value but the expression '" +
                    ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(node) +
                    "' returns '" +
                    evaluationType.CleanName() +
                    "' for " +
                    supplier.Invoke());
            }

            return node;
        }
예제 #8
0
        public static IList<ExprNode> ValidateAllowSubquery(
            ExprNodeOrigin exprNodeOrigin,
            IList<ExprNode> exprNodes,
            StreamTypeService streamTypeService,
            IDictionary<string, Pair<EventType, string>> taggedEventTypes,
            IDictionary<string, Pair<EventType, string>> arrayEventTypes,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices services)
        {
            IList<ExprNode> validatedNodes = new List<ExprNode>();

            ExprValidationContext validationContext =
                new ExprValidationContextBuilder(streamTypeService, statementRawInfo, services)
                    .WithAllowBindingConsumption(true)
                    .WithIsFilterExpression(true)
                    .Build();
            foreach (var node in exprNodes) {
                // Determine subselects
                var visitor = new ExprNodeSubselectDeclaredDotVisitor();
                node.Accept(visitor);

                // Compile subselects
                if (!visitor.Subselects.IsEmpty()) {
                    // The outer event type is the filtered-type itself
                    foreach (var subselect in visitor.Subselects) {
                        try {
                            SubSelectHelperFilters.HandleSubselectSelectClauses(
                                subselect,
                                streamTypeService.EventTypes[0],
                                streamTypeService.StreamNames[0],
                                streamTypeService.StreamNames[0],
                                taggedEventTypes,
                                arrayEventTypes,
                                statementRawInfo,
                                services);
                        }
                        catch (ExprValidationException ex) {
                            throw new ExprValidationException(
                                "Failed to validate " +
                                ExprNodeUtilityMake.GetSubqueryInfoText(subselect) +
                                ": " +
                                ex.Message,
                                ex);
                        }
                    }
                }

                var validated = ExprNodeUtilityValidate.GetValidatedSubtree(exprNodeOrigin, node, validationContext);
                validatedNodes.Add(validated);

                if (validated.Forge.EvaluationType != typeof(bool?) && validated.Forge.EvaluationType != typeof(bool)) {
                    throw new ExprValidationException(
                        "Filter expression not returning a boolean value: '" +
                        ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(validated) +
                        "'");
                }
            }

            return validatedNodes;
        }
예제 #9
0
 public static void ValidateFilterWQueryGraphSafe(
     QueryGraphForge queryGraph,
     ExprNode filterExpression,
     StreamTypeServiceImpl typeService,
     StatementRawInfo statementRawInfo,
     StatementCompileTimeServices services)
 {
     try {
         var validationContext = new ExprValidationContextBuilder(typeService, statementRawInfo, services)
             .WithAllowBindingConsumption(true)
             .WithIsFilterExpression(true)
             .Build();
         var validated = ExprNodeUtilityValidate.GetValidatedSubtree(
             ExprNodeOrigin.FILTER,
             filterExpression,
             validationContext);
         FilterExprAnalyzer.Analyze(validated, queryGraph, false);
     }
     catch (Exception ex) {
         Log.Warn(
             "Unexpected exception analyzing filterable expression '" +
             ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(filterExpression) +
             "': " +
             ex.Message,
             ex);
     }
 }
        private static FilterSpecParamFilterForEvalDoubleForge ResolveFilterIndexDoubleEval(
            string indexName,
            ExprNode indexExpression,
            IDictionary<string, Pair<EventType, string>> arrayEventTypes,
            string statementName)
        {
            FilterSpecParamFilterForEvalDoubleForge resolved = null;
            if (indexExpression is ExprIdentNode) {
                resolved = GetIdentNodeDoubleEval((ExprIdentNode) indexExpression, arrayEventTypes, statementName);
            }
            else if (indexExpression is ExprContextPropertyNode) {
                var node = (ExprContextPropertyNode) indexExpression;
                resolved = new FilterForEvalContextPropDoubleForge(node.Getter, node.PropertyName);
            }
            else if (indexExpression.Forge.ForgeConstantType.IsCompileTimeConstant) {
                double d = indexExpression.Forge.ExprEvaluator.Evaluate(null, true, null).AsDouble();
                resolved = new FilterForEvalConstantDoubleForge(d);
            }
            else if (indexExpression.Forge.ForgeConstantType.IsConstant) {
                resolved = new FilterForEvalConstRuntimeExprForge(indexExpression);
            }

            if (resolved != null) {
                return resolved;
            }

            throw new ExprValidationException(
                "Invalid filter-indexable expression '" +
                ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(indexExpression) +
                "' in respect to index '" +
                indexName +
                "': expected either a constant, context-builtin or property from a previous pattern match");
        }
예제 #11
0
 public void TestToExpressionString()
 {
     Assert.AreEqual("{}", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(arrayNodes[0]));
     Assert.AreEqual("{2,3}", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(arrayNodes[1]));
     Assert.AreEqual("{1.5d,1}", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(arrayNodes[2]));
     Assert.AreEqual("{\"a\",1}", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(arrayNodes[3]));
 }
예제 #12
0
        public void TestToExpressionString()
        {
            andNode.AddChildNode(new SupportExprNode(true));
            andNode.AddChildNode(new SupportExprNode(false));

            Assert.AreEqual("true and false", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(andNode));
        }
예제 #13
0
        public CodegenExpression Make(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(
                typeof(SubordInKeywordSingleTableLookupStrategyFactory),
                GetType(),
                classScope);

            var expressions = new string[exprNodes.Count];
            method.Block.DeclareVar<ExprEvaluator[]>(
                "evals",
                NewArrayByLength(typeof(ExprEvaluator), Constant(exprNodes.Count)));
            for (var i = 0; i < exprNodes.Count; i++) {
                CodegenExpression eval = ExprNodeUtilityCodegen.CodegenEvaluatorNoCoerce(
                    exprNodes[i].Forge,
                    method,
                    GetType(),
                    classScope);
                method.Block.AssignArrayElement(Ref("evals"), Constant(i), eval);
                expressions[i] = ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(exprNodes[i]);
            }

            method.Block.MethodReturn(
                NewInstance<SubordInKeywordSingleTableLookupStrategyFactory>(
                    Constant(_isNwOnTrigger),
                    Constant(_streamCountOuter),
                    Ref("evals"),
                    Constant(expressions)));
            return LocalMethod(method);
        }
예제 #14
0
        private static void ValidateIntoTableCompatible(
            string tableName,
            string columnName,
            TableMetadataColumnAggregation columnMetadata,
            AggregationServiceAggExpressionDesc aggDesc)
        {
            var factoryProvided = aggDesc.Factory.AggregationPortableValidation;
            var factoryRequired = columnMetadata.AggregationPortableValidation;

            try {
                factoryRequired.ValidateIntoTableCompatible(
                    columnMetadata.AggregationExpression,
                    factoryProvided,
                    ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(aggDesc.AggregationNode),
                    aggDesc.Factory);
            }
            catch (ExprValidationException ex) {
                var text = GetMessage(
                    tableName,
                    columnName,
                    columnMetadata.AggregationExpression,
                    aggDesc.Factory.AggregationExpression);
                throw new ExprValidationException(text + ": " + ex.Message, ex);
            }
        }
예제 #15
0
 public void TestToExpressionString()
 {
     log.Debug(".testToExpressionString");
     _bitWiseNode = new ExprBitWiseNode(BitWiseOpEnum.BAND);
     _bitWiseNode.AddChildNode(new SupportExprNode(4));
     _bitWiseNode.AddChildNode(new SupportExprNode(2));
     Assert.AreEqual("4&2", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(_bitWiseNode));
 }
예제 #16
0
 public override void ValueExprToString(
     StringBuilder @out,
     int i)
 {
     @out.Append("expression '")
         .Append(ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(ExprNode))
         .Append("'");
 }
예제 #17
0
 public void TestToExpressionString()
 {
     Assert.AreEqual("s0.TheString like \"%abc__\"", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(likeNodeNormal));
     Assert.AreEqual("s0.TheString not like \"%abc__\"", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(likeNodeNot));
     Assert.AreEqual(
         "s0.TheString like \"%abc__\" escape \"!\"",
         ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(likeNodeNormalEscaped));
 }
예제 #18
0
 public void TestToExpressionString()
 {
     minMaxNode.AddChildNode(new SupportExprNode(9d));
     minMaxNode.AddChildNode(new SupportExprNode(6));
     Assert.AreEqual("max(9.0d,6)", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(minMaxNode));
     minMaxNode.AddChildNode(new SupportExprNode(0.5d));
     Assert.AreEqual("max(9.0d,6,0.5d)", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(minMaxNode));
 }
예제 #19
0
        public override void ToPrecedenceFreeEPL(TextWriter writer)
        {
            if (ChildNodes.Length != 0) {
                writer.Write(ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(ChildNodes[0]));
            }

            ExprNodeUtilityPrint.ToExpressionString(ChainSpec, writer, ChildNodes.Length != 0, null);
        }
예제 #20
0
 public void TestToExpressionString()
 {
     concatNode = new ExprConcatNode();
     concatNode.AddChildNode(new SupportExprNode("a"));
     concatNode.AddChildNode(new SupportExprNode("b"));
     Assert.AreEqual("\"a\"||\"b\"", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(concatNode));
     concatNode.AddChildNode(new SupportExprNode("c"));
     Assert.AreEqual("\"a\"||\"b\"||\"c\"", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(concatNode));
 }
예제 #21
0
 private static void AssertExpressionOpt(
     string expected,
     ExprNode expression)
 {
     if (expected == null) {
         Assert.IsNull(expression);
     }
     else {
         Assert.AreEqual(expected, ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(expression));
     }
 }
예제 #22
0
 private static void LogFilterPlanExpr(
     StringBuilder buf,
     string name,
     ExprNode exprNode)
 {
     buf.Append("  -")
         .Append(name)
         .Append(": ")
         .Append(ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(exprNode))
         .Append(FilterSpecCompiler.NEWLINE);
 }
예제 #23
0
        private static void ValidateBuiltin(
            CreateIndexItem columnDesc,
            EventType eventType,
            IList<IndexedPropDesc> hashProps,
            IList<IndexedPropDesc> btreeProps,
            ISet<string> indexedColumns)
        {
            if (columnDesc.Expressions.IsEmpty()) {
                throw new ExprValidationException("Invalid empty list of index expressions");
            }

            if (columnDesc.Expressions.Count > 1) {
                throw new ExprValidationException(
                    "Invalid multiple index expressions for index type '" + columnDesc.IndexType + "'");
            }

            ExprNode expression = columnDesc.Expressions[0];
            if (!(expression is ExprIdentNode)) {
                throw new ExprValidationException(
                    "Invalid index expression '" +
                    ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(expression) +
                    "'");
            }

            var identNode = (ExprIdentNode) expression;
            if (identNode.FullUnresolvedName.Contains(".")) {
                throw new ExprValidationException(
                    "Invalid index expression '" +
                    ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(expression) +
                    "'");
            }

            var columnName = identNode.FullUnresolvedName;
            Type type = Boxing.GetBoxedType(eventType.GetPropertyType(columnName));
            if (type == null) {
                throw new ExprValidationException("Property named '" + columnName + "' not found");
            }

            if (!indexedColumns.Add(columnName)) {
                throw new ExprValidationException(
                    "Property named '" + columnName + "' has been declared more then once");
            }

            var desc = new IndexedPropDesc(columnName, type);
            string indexType = columnDesc.IndexType;
            if (indexType.Equals(CreateIndexType.HASH.GetName(), StringComparison.InvariantCultureIgnoreCase)) {
                hashProps.Add(desc);
            }
            else {
                btreeProps.Add(desc);
            }
        }
예제 #24
0
        public static StatViewAdditionalPropsForge Make(
            ExprNode[] validated,
            int startIndex,
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            if (validated.Length <= startIndex) {
                return null;
            }

            IList<string> additionalProps = new List<string>();
            IList<ExprNode> lastValueForges = new List<ExprNode>();
            IList<Type> lastValueTypes = new List<Type>();
            IList<DataInputOutputSerdeForge> lastSerdes = new List<DataInputOutputSerdeForge>();

            var copyAllProperties = false;

            for (var i = startIndex; i < validated.Length; i++) {
                if (validated[i] is ExprWildcard) {
                    copyAllProperties = true;
                }
                else {
                    additionalProps.Add(ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(validated[i]));
                    var evalType = validated[i].Forge.EvaluationType;
                    lastValueTypes.Add(evalType);
                    lastValueForges.Add(validated[i]);
                    lastSerdes.Add(viewForgeEnv.SerdeResolver.SerdeForDerivedViewAddProp(evalType, viewForgeEnv.StatementRawInfo));
                }
            }

            if (copyAllProperties) {
                foreach (var propertyDescriptor in parentEventType.PropertyDescriptors) {
                    if (propertyDescriptor.IsFragment) {
                        continue;
                    }

                    additionalProps.Add(propertyDescriptor.PropertyName);
                    var type = propertyDescriptor.PropertyType;
                    lastValueForges.Add(
                        new ExprIdentNodeImpl(parentEventType, propertyDescriptor.PropertyName, streamNumber));
                    lastValueTypes.Add(type);
                    lastSerdes.Add(viewForgeEnv.SerdeResolver.SerdeForDerivedViewAddProp(type, viewForgeEnv.StatementRawInfo));
                }
            }

            var addPropsArr = additionalProps.ToArray();
            var valueExprArr = lastValueForges.ToArray();
            var typeArr = lastValueTypes.ToArray();
            var additionalForges = lastSerdes.ToArray();
            return new StatViewAdditionalPropsForge(addPropsArr, valueExprArr, typeArr, additionalForges);
        }
예제 #25
0
        private ExprStreamUnderlyingNode CheckStreamUnd(ExprNode childNode)
        {
            if (!(childNode is ExprStreamUnderlyingNode))
            {
                throw new ExprValidationException(
                          NAME +
                          " requires a parameter that resolves to an event but received '" +
                          ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(childNode) +
                          "'");
            }

            return((ExprStreamUnderlyingNode)childNode);
        }
예제 #26
0
        public void TestToExpressionString()
        {
            var _caseNode = supportExprNodeFactory.MakeCaseSyntax1Node();

            Assert.AreEqual(
                "case when s0.IntPrimitive=1 then \"a\" when s0.IntPrimitive=2 then \"b\" else \"c\" end",
                ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(_caseNode));

            _caseNode = supportExprNodeFactory.MakeCaseSyntax2Node();
            Assert.AreEqual(
                "case s0.IntPrimitive when 1 then \"a\" when 2 then \"b\" else \"c\" end",
                ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(_caseNode));
        }
예제 #27
0
        private static IList<NamedWindowSelectedProps> CompileLimitedSelect(
            SelectFromInfo selectFromInfo,
            StatementBaseInfo @base,
            StatementCompileTimeServices compileTimeServices)
        {
            IList<NamedWindowSelectedProps> selectProps = new List<NamedWindowSelectedProps>();
            StreamTypeService streams = new StreamTypeServiceImpl(
                new[] {selectFromInfo.EventType},
                new[] {"stream_0"},
                new[] {false},
                false,
                false);

            var validationContext =
                new ExprValidationContextBuilder(streams, @base.StatementRawInfo, compileTimeServices).Build();
            foreach (var item in @base.StatementSpec.SelectClauseCompiled.SelectExprList) {
                if (!(item is SelectClauseExprCompiledSpec)) {
                    continue;
                }

                var exprSpec = (SelectClauseExprCompiledSpec) item;
                var validatedExpression = ExprNodeUtilityValidate.GetValidatedSubtree(
                    ExprNodeOrigin.SELECT,
                    exprSpec.SelectExpression,
                    validationContext);

                // determine an element name if none assigned
                var asName = exprSpec.ProvidedName;
                if (asName == null) {
                    asName = ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(validatedExpression);
                }

                // check for fragments
                EventType fragmentType = null;
                if (validatedExpression is ExprIdentNode && !(selectFromInfo.EventType is NativeEventType)) {
                    var identNode = (ExprIdentNode) validatedExpression;
                    var fragmentEventType = selectFromInfo.EventType.GetFragmentType(identNode.FullUnresolvedName);
                    if (fragmentEventType != null && !fragmentEventType.IsNative) {
                        fragmentType = fragmentEventType.FragmentType;
                    }
                }

                var validatedElement = new NamedWindowSelectedProps(
                    validatedExpression.Forge.EvaluationType,
                    asName,
                    fragmentType);
                selectProps.Add(validatedElement);
            }

            return selectProps;
        }
예제 #28
0
        public void TestToExpressionString()
        {
            // Build (5*(4-2)), not the same as 5*4-2
            var arithNodeChild = new ExprMathNode(MathArithTypeEnum.SUBTRACT, false, false);

            arithNodeChild.AddChildNode(new SupportExprNode(4));
            arithNodeChild.AddChildNode(new SupportExprNode(2));

            arithNode = new ExprMathNode(MathArithTypeEnum.MULTIPLY, false, false);
            arithNode.AddChildNode(new SupportExprNode(5));
            arithNode.AddChildNode(arithNodeChild);

            Assert.AreEqual("5*(4-2)", ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(arithNode));
        }
        private static EventPropertyGetterSPI ResolveFilterIndexRequiredGetter(
            string indexName,
            ExprNode keyExpression)
        {
            if (!(keyExpression is ExprIdentNode)) {
                throw new ExprValidationException(
                    "Invalid filter-index lookup expression '" +
                    ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(keyExpression) +
                    "' in respect to index '" +
                    indexName +
                    "': expected an event property name");
            }

            return ((ExprIdentNode) keyExpression).ExprEvaluatorIdent.Getter;
        }
예제 #30
0
        protected internal static CodegenExpression[] GetInstrumentationQParams(
            ExprDeclaredNodeImpl parent,
            CodegenClassScope codegenClassScope)
        {
            string expressionText = null;
            if (codegenClassScope.IsInstrumented) {
                expressionText = ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(parent.ExpressionBodyCopy);
            }

            return new[] {
                Constant(parent.Prototype.Name),
                Constant(expressionText),
                Constant(parent.Prototype.ParametersNames)
            };
        }