Ejemplo n.º 1
0
        public static Object ValidateAndEvaluateExpr(
            string viewName,
            StatementContext statementContext,
            ExprNode expression,
            StreamTypeService streamTypeService,
            int expressionNumber)
        {
            ExprNode validated = ValidateExpr(
                viewName, statementContext, expression, streamTypeService, expressionNumber);

            try
            {
                return(validated.ExprEvaluator.Evaluate(
                           new EvaluateParams(null, true, new ExprEvaluatorContextStatement(statementContext, false))));
            }
            catch (Exception ex)
            {
                string message = "Failed to evaluate parameter expression " + expressionNumber + GetViewDesc(viewName);
                if (!string.IsNullOrWhiteSpace(ex.Message))
                {
                    message += ": " + ex.Message;
                }
                Log.Error(message, ex);
                throw new ViewParameterException(message, ex);
            }
        }
Ejemplo n.º 2
0
        private static void TryResolveByPropertyName(StreamTypeService service)
        {
            // Test lookup by property name only
            PropertyResolutionDescriptor desc = service.ResolveByPropertyName(
                "Volume", false);

            Assert.AreEqual(3, (desc.StreamNum));
            Assert.AreEqual(typeof(long?), desc.PropertyType);
            Assert.AreEqual("Volume", desc.PropertyName);
            Assert.AreEqual("s4", desc.StreamName);
            Assert.AreEqual(typeof(SupportMarketDataBean),
                            desc.StreamEventType.UnderlyingType);

            try
            {
                service.ResolveByPropertyName("BoolPrimitive", false);
                Assert.Fail();
            }
            catch (DuplicatePropertyException ex)
            {
                // Expected
            }

            try
            {
                service.ResolveByPropertyName("xxxx", false);
                Assert.Fail();
            }
            catch (PropertyNotFoundException ex)
            {
                // Expected
            }
        }
        internal static ExprNode ValidateExprNoAgg(
            ExprNodeOrigin exprNodeOrigin,
            ExprNode exprNode,
            StreamTypeService streamTypeService,
            StatementContext statementContext,
            ExprEvaluatorContext exprEvaluatorContext,
            String errorMsg,
            bool allowTableConsumption)
        {
            var validationContext = new ExprValidationContext(
                streamTypeService,
                statementContext.MethodResolutionService, null,
                statementContext.SchedulingService,
                statementContext.VariableService,
                statementContext.TableService,
                exprEvaluatorContext,
                statementContext.EventAdapterService,
                statementContext.StatementName,
                statementContext.StatementId,
                statementContext.Annotations,
                statementContext.ContextDescriptor,
                statementContext.ScriptingService,
                false, false,
                allowTableConsumption, false,
                null, false);
            var validated = ExprNodeUtility.GetValidatedSubtree(exprNodeOrigin, exprNode, validationContext);

            ValidateNoAggregations(validated, errorMsg);
            return(validated);
        }
Ejemplo n.º 4
0
        internal ExprValidationContext(
            StreamTypeService streamTypeService,
            ViewResourceDelegateExpr viewResourceDelegate,
            ContextCompileTimeDescriptor contextDescriptor,
            bool disablePropertyExpressionEventCollCache,
            bool allowRollupFunctions,
            bool allowBindingConsumption,
            bool allowTableAggReset,
            bool isUnidirectionalJoin,
            string intoTableName,
            bool isFilterExpression,
            ExprValidationMemberName memberName,
            bool aggregationFutureNameAlreadySet,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices compileTimeServices)
        {
            StreamTypeService = streamTypeService;
            ViewResourceDelegate = viewResourceDelegate;
            this.contextDescriptor = contextDescriptor;
            IsDisablePropertyExpressionEventCollCache = disablePropertyExpressionEventCollCache;
            IsAllowRollupFunctions = allowRollupFunctions;
            IsAllowBindingConsumption = allowBindingConsumption;
            IsAllowTableAggReset = allowTableAggReset;
            IsResettingAggregations = isUnidirectionalJoin;
            this.intoTableName = intoTableName;
            IsFilterExpression = isFilterExpression;
            MemberNames = memberName;
            IsAggregationFutureNameAlreadySet = aggregationFutureNameAlreadySet;
            StatementRawInfo = statementRawInfo;
            StatementCompileTimeService = compileTimeServices;

            IsExpressionAudit = AuditEnum.EXPRESSION.GetAudit(statementRawInfo.Annotations) != null;
            IsExpressionNestedAudit = AuditEnum.EXPRESSION_NESTED.GetAudit(statementRawInfo.Annotations) != null;
        }
Ejemplo n.º 5
0
        internal static Pair<PropertyResolutionDescriptor, string> GetTypeFromStreamExplicitProperties(
            StreamTypeService streamTypeService,
            string unresolvedPropertyName,
            string streamOrPropertyName,
            bool obtainFragment)
        {
            PropertyResolutionDescriptor propertyInfo;

            // no stream/property name supplied
            if (streamOrPropertyName == null)
            {
                try
                {
                    propertyInfo = streamTypeService.ResolveByPropertyNameExplicitProps(
                        unresolvedPropertyName, obtainFragment);
                }
                catch (StreamTypesException ex)
                {
                    throw GetSuggestionException(ex);
                }
                catch (PropertyAccessException ex)
                {
                    throw new ExprValidationPropertyException(ex.Message);
                }

                // resolves without a stream name, return descriptor and null stream name
                return new Pair<PropertyResolutionDescriptor, string>(propertyInfo, propertyInfo.StreamName);
            }

            // try to resolve the property name and stream name as it is (ie. stream name as a stream name)
            StreamTypesException typeExceptionOne;
            try
            {
                propertyInfo = streamTypeService.ResolveByStreamAndPropNameExplicitProps(
                    streamOrPropertyName, unresolvedPropertyName, obtainFragment);
                // resolves with a stream name, return descriptor and stream name
                return new Pair<PropertyResolutionDescriptor, string>(propertyInfo, streamOrPropertyName);
            }
            catch (StreamTypesException ex)
            {
                typeExceptionOne = ex;
            }

            // try to resolve the property name to a nested property 's0.p0'
            StreamTypesException typeExceptionTwo;
            var propertyNameCandidate = streamOrPropertyName + '.' + unresolvedPropertyName;
            try
            {
                propertyInfo = streamTypeService.ResolveByPropertyNameExplicitProps(
                    propertyNameCandidate, obtainFragment);
                // resolves without a stream name, return null for stream name
                return new Pair<PropertyResolutionDescriptor, string>(propertyInfo, null);
            }
            catch (StreamTypesException ex)
            {
                typeExceptionTwo = ex;
            }

            throw GetSuggestionExceptionSecondStep(propertyNameCandidate, typeExceptionOne, typeExceptionTwo);
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
0
        public override EnumForge GetEnumForge(StreamTypeService streamTypeService,
            string enumMethodUsedName,
            IList<ExprDotEvalParam> bodiesAndParameters,
            EventType inputEventType,
            Type collectionComponentType,
            int numStreamsIncoming,
            bool disablePropertyExpressionEventCollCache,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices services)
        {
            var max = EnumMethodEnum == EnumMethodEnum.MAX;

            if (bodiesAndParameters.IsEmpty()) {
                var returnTypeX = Boxing.GetBoxedType(collectionComponentType);
                TypeInfo = EPTypeHelper.SingleValue(returnTypeX);
                return new EnumMinMaxScalarForge(numStreamsIncoming, max, TypeInfo);
            }

            var first = (ExprDotEvalParamLambda) bodiesAndParameters[0];
            var returnType = Boxing.GetBoxedType(first.BodyForge.EvaluationType);
            TypeInfo = EPTypeHelper.SingleValue(returnType);

            if (inputEventType == null) {
                return new EnumMinMaxScalarLambdaForge(
                    first.BodyForge,
                    first.StreamCountIncoming,
                    max,
                    (ObjectArrayEventType) first.GoesToTypes[0]);
            }

            return new EnumMinMaxEventsForge(first.BodyForge, first.StreamCountIncoming, max);
        }
Ejemplo n.º 8
0
 public static void CheckWildcardNotJoinOrSubquery(StreamTypeService streamTypeService, string aggFuncName)
 {
     if (streamTypeService.StreamNames.Length > 1)
     {
         throw new ExprValidationException(GetErrorPrefix(aggFuncName) + " requires that in joins or subqueries the stream-wildcard (stream-alias.*) syntax is used instead");
     }
 }
Ejemplo n.º 9
0
 private static void CheckWildcardHasStream(StreamTypeService streamTypeService, string aggFuncName)
 {
     if (streamTypeService.StreamNames.Length == 0)      // could be the case for
     {
         throw new ExprValidationException(GetErrorPrefix(aggFuncName) + " requires that at least one stream is provided");
     }
 }
Ejemplo n.º 10
0
        public override EnumForge GetEnumForge(StreamTypeService streamTypeService,
            string enumMethodUsedName,
            IList<ExprDotEvalParam> bodiesAndParameters,
            EventType inputEventType,
            Type collectionComponentType,
            int numStreamsIncoming,
            bool disablePropertyExpressionEventCollCache,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices services)
        {
            var isDescending = EnumMethodEnum == EnumMethodEnum.ORDERBYDESC;

            if (bodiesAndParameters.IsEmpty()) {
                TypeInfo = EPTypeHelper.CollectionOfSingleValue(collectionComponentType, null);
                return new EnumOrderByAscDescScalarForge(numStreamsIncoming, isDescending);
            }

            var first = (ExprDotEvalParamLambda) bodiesAndParameters[0];
            if (inputEventType == null) {
                TypeInfo = EPTypeHelper.CollectionOfSingleValue(collectionComponentType, null);
                return new EnumOrderByAscDescScalarLambdaForge(
                    first.BodyForge,
                    first.StreamCountIncoming,
                    isDescending,
                    (ObjectArrayEventType) first.GoesToTypes[0]);
            }

            TypeInfo = EPTypeHelper.CollectionOfEvents(inputEventType);
            return new EnumOrderByAscDescEventsForge(first.BodyForge, first.StreamCountIncoming, isDescending);
        }
Ejemplo n.º 11
0
        public override EnumEval GetEnumEval(
            MethodResolutionService methodResolutionService,
            EventAdapterService eventAdapterService,
            StreamTypeService streamTypeService,
            String statementId,
            String enumMethodUsedName,
            IList <ExprDotEvalParam> bodiesAndParameters,
            EventType inputEventType,
            Type collectionComponentType,
            int numStreamsIncoming,
            bool disablePropertyExpressionEventCollCache)
        {
            var first = (ExprDotEvalParamLambda)bodiesAndParameters[0];

            TypeInfo = EPTypeHelper.SingleValue(typeof(bool));
            if (inputEventType != null)
            {
                if (EnumMethodEnum == EnumMethodEnum.ALLOF)
                {
                    return(new EnumEvalAllOfEvents(first.BodyEvaluator, first.StreamCountIncoming));
                }
                return(new EnumEvalAnyOfEvents(first.BodyEvaluator, first.StreamCountIncoming));
            }

            if (EnumMethodEnum == EnumMethodEnum.ALLOF)
            {
                return(new EnumEvalAllOfScalar(
                           first.BodyEvaluator, first.StreamCountIncoming, (ObjectArrayEventType)first.GoesToTypes[0]));
            }
            return(new EnumEvalAnyOfScalar(
                       first.BodyEvaluator, first.StreamCountIncoming, (ObjectArrayEventType)first.GoesToTypes[0]));
        }
Ejemplo n.º 12
0
        public override EnumEval GetEnumEval(
            MethodResolutionService methodResolutionService,
            EventAdapterService eventAdapterService,
            StreamTypeService streamTypeService,
            String statementId,
            String enumMethodUsedName,
            IList <ExprDotEvalParam> bodiesAndParameters,
            EventType inputEventType,
            Type collectionComponentType,
            int numStreamsIncoming,
            bool disablePropertyExpressionEventCollCache)
        {
            bool isDescending = EnumMethodEnum == EnumMethodEnum.ORDERBYDESC;

            if (bodiesAndParameters.IsEmpty())
            {
                base.TypeInfo = EPTypeHelper.CollectionOfSingleValue(collectionComponentType);
                return(new EnumEvalOrderByAscDescScalar(numStreamsIncoming, isDescending));
            }

            var first = (ExprDotEvalParamLambda)bodiesAndParameters[0];

            if (inputEventType == null)
            {
                base.TypeInfo = EPTypeHelper.CollectionOfSingleValue(collectionComponentType);
                return(new EnumEvalOrderByAscDescScalarLambda(
                           first.BodyEvaluator, first.StreamCountIncoming, isDescending,
                           (ObjectArrayEventType)first.GoesToTypes[0]));
            }
            base.TypeInfo = EPTypeHelper.CollectionOfEvents(inputEventType);
            return(new EnumEvalOrderByAscDescEvents(first.BodyEvaluator, first.StreamCountIncoming, isDescending));
        }
Ejemplo n.º 13
0
        public override EnumForge GetEnumForge(StreamTypeService streamTypeService,
            string enumMethodUsedName,
            IList<ExprDotEvalParam> bodiesAndParameters,
            EventType inputEventType,
            Type collectionComponentType,
            int numStreamsIncoming,
            bool disablePropertyExpressionEventCollCache,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices services)
        {
            var first = (ExprDotEvalParamLambda) bodiesAndParameters[0];

            TypeInfo = EPTypeHelper.SingleValue(typeof(bool?));
            if (inputEventType != null) {
                if (EnumMethodEnum == EnumMethodEnum.ALLOF) {
                    return new EnumAllOfEventsForge(first.BodyForge, first.StreamCountIncoming);
                }

                return new EnumAnyOfEventsForge(first.BodyForge, first.StreamCountIncoming);
            }

            if (EnumMethodEnum == EnumMethodEnum.ALLOF) {
                return new EnumAllOfScalarForge(
                    first.BodyForge,
                    first.StreamCountIncoming,
                    (ObjectArrayEventType) first.GoesToTypes[0]);
            }

            return new EnumAnyOfScalarForge(
                first.BodyForge,
                first.StreamCountIncoming,
                (ObjectArrayEventType) first.GoesToTypes[0]);
        }
Ejemplo n.º 14
0
        public override EnumEval GetEnumEval(
            MethodResolutionService methodResolutionService,
            EventAdapterService eventAdapterService,
            StreamTypeService streamTypeService,
            String statementId,
            String enumMethodUsedName,
            IList <ExprDotEvalParam> bodiesAndParameters,
            EventType inputEventType,
            Type collectionComponentType,
            int numStreamsIncoming,
            bool disablePropertyExpressionEventCollCache)
        {
            ExprEvaluator sizeEval = bodiesAndParameters[0].BodyEvaluator;

            if (inputEventType != null)
            {
                base.TypeInfo = EPTypeHelper.CollectionOfEvents(inputEventType);
            }
            else
            {
                base.TypeInfo = EPTypeHelper.CollectionOfSingleValue(collectionComponentType);
            }

            if (EnumMethodEnum == EnumMethodEnum.TAKE)
            {
                return(new EnumEvalTake(sizeEval, numStreamsIncoming));
            }
            else
            {
                return(new EnumEvalTakeLast(sizeEval, numStreamsIncoming));
            }
        }
Ejemplo n.º 15
0
        public static object ValidateAndEvaluateExpr(
            string viewName,
            ExprNode expression,
            StreamTypeService streamTypeService,
            ViewForgeEnv viewForgeEnv,
            int expressionNumber,
            int streamNumber)
        {
            var validated = ValidateExpr(
                viewName,
                expression,
                streamTypeService,
                viewForgeEnv,
                expressionNumber,
                streamNumber);

            try {
                return validated.Forge.ExprEvaluator.Evaluate(null, true, null);
            }
            catch (EPException) {
                throw;
            }
            catch (Exception ex) {
                var message = "Failed to evaluate parameter expression " + expressionNumber + GetViewDesc(viewName);
                if (ex.Message != null) {
                    message += ": " + ex.Message;
                }

                throw new ViewParameterException(message, ex);
            }
        }
Ejemplo n.º 16
0
        public ExprTableIdentNode GetTableIdentNode(StreamTypeService streamTypeService, string unresolvedPropertyName, string streamOrPropertyName)
        {
            var propertyPrefixed = unresolvedPropertyName;

            if (streamOrPropertyName != null)
            {
                propertyPrefixed = streamOrPropertyName + "." + unresolvedPropertyName;
            }
            var col = FindTableColumnMayByPrefixed(streamTypeService, propertyPrefixed);

            if (col == null)
            {
                return(null);
            }
            var pair = col.Pair;

            if (pair.Column is TableMetadataColumnAggregation)
            {
                var agg  = (TableMetadataColumnAggregation)pair.Column;
                var node = new ExprTableIdentNode(streamOrPropertyName, unresolvedPropertyName);
                var eval = ExprTableEvalStrategyFactory.GetTableAccessEvalStrategy(node, pair.TableMetadata.TableName, pair.StreamNum, agg);
                node.Eval = eval;
                return(node);
            }
            return(null);
        }
Ejemplo n.º 17
0
        public override void Initialize(
            DotMethodFP footprint,
            EnumMethodEnum enumMethod,
            string enumMethodUsedName,
            EventType inputEventType,
            Type collectionComponentType,
            IList<ExprNode> parameters,
            StreamTypeService streamTypeService,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices services)
        {
            // validate
            var ctx = new EnumMethodValidateContext(
                footprint,
                inputEventType,
                collectionComponentType,
                streamTypeService,
                enumMethod,
                parameters,
                statementRawInfo);
            var enumMethodMode = _forgeFactory.Validate(ctx);
            if (!(enumMethodMode is EnumMethodModeStaticMethod)) {
                throw new ExprValidationException("Unexpected EnumMethodMode implementation, expected a provided implementation");
            }

            Mode = (EnumMethodModeStaticMethod) enumMethodMode;
        }
Ejemplo n.º 18
0
        private StreamTableColPair FindTableColumnAcrossStreams(StreamTypeService streamTypeService, string columnName)

        {
            StreamTableColPair found = null;

            for (var i = 0; i < streamTypeService.EventTypes.Length; i++)
            {
                var type = streamTypeService.EventTypes[i];
                var pair = FindTableColumnForType(i, type, columnName);
                if (pair == null)
                {
                    continue;
                }
                if (found != null)
                {
                    if (streamTypeService.IsStreamZeroUnambigous && found.StreamNum == 0)
                    {
                        continue;
                    }
                    throw new ExprValidationException("Ambiguous table column '" + columnName + "' should be prefixed by a stream name");
                }
                found = pair;
            }
            return(found);
        }
Ejemplo n.º 19
0
 public static FilterSpecCompiled MakeFilterSpec(
     EventType eventType,
     string eventTypeName,
     IList<ExprNode> filterExpessions,
     PropertyEvalSpec optionalPropertyEvalSpec,
     IDictionary<string, Pair<EventType, string>> taggedEventTypes,
     IDictionary<string, Pair<EventType, string>> arrayEventTypes,
     StreamTypeService streamTypeService,
     string optionalStreamName,
     StatementRawInfo statementRawInfo,
     StatementCompileTimeServices services)
 {
     // Validate all nodes, make sure each returns a boolean and types are good;
     // Also decompose all AND super nodes into individual expressions
     var validatedNodes = ValidateAllowSubquery(
         ExprNodeOrigin.FILTER,
         filterExpessions,
         streamTypeService,
         taggedEventTypes,
         arrayEventTypes,
         statementRawInfo,
         services);
     return Build(
         validatedNodes,
         eventType,
         eventTypeName,
         optionalPropertyEvalSpec,
         taggedEventTypes,
         arrayEventTypes,
         streamTypeService,
         optionalStreamName,
         statementRawInfo,
         services);
 }
Ejemplo n.º 20
0
        public static ExprTableIdentNode GetTableIdentNode(
            StreamTypeService streamTypeService,
            string unresolvedPropertyName,
            string streamOrPropertyName,
            TableCompileTimeResolver resolver)
        {
            var propertyPrefixed = unresolvedPropertyName;

            if (streamOrPropertyName != null)
            {
                propertyPrefixed = streamOrPropertyName + "." + unresolvedPropertyName;
            }

            var col = FindTableColumnMayByPrefixed(streamTypeService, propertyPrefixed, resolver);

            var pair = col?.Pair;

            if (pair?.Column is TableMetadataColumnAggregation)
            {
                var agg        = (TableMetadataColumnAggregation)pair.Column;
                var resultType = pair.TableMetadata.PublicEventType.GetPropertyType(agg.ColumnName);
                return(new ExprTableIdentNode(
                           pair.TableMetadata,
                           streamOrPropertyName,
                           unresolvedPropertyName,
                           resultType,
                           pair.StreamNum,
                           agg.ColumnName,
                           agg.Column));
            }

            return(null);
        }
Ejemplo n.º 21
0
        public static FilterSpecCompiled Build(
            IList <ExprNode> validatedNodes,
            EventType eventType,
            string eventTypeName,
            PropertyEvalSpec optionalPropertyEvalSpec,
            IDictionary <string, Pair <EventType, string> > taggedEventTypes,
            IDictionary <string, Pair <EventType, string> > arrayEventTypes,
            StreamTypeService streamTypeService,
            string optionalStreamName,
            StatementContext stmtContext,
            ICollection <int> assignedTypeNumberStack)
        {
            var evaluatorContextStmt = new ExprEvaluatorContextStatement(stmtContext, false);

            return(BuildNoStmtCtx(validatedNodes, eventType, eventTypeName, optionalPropertyEvalSpec, taggedEventTypes, arrayEventTypes, streamTypeService,
                                  optionalStreamName, assignedTypeNumberStack,
                                  evaluatorContextStmt,
                                  stmtContext.StatementId,
                                  stmtContext.StatementName,
                                  stmtContext.Annotations,
                                  stmtContext.ContextDescriptor,
                                  stmtContext.MethodResolutionService,
                                  stmtContext.EventAdapterService,
                                  stmtContext.TimeProvider,
                                  stmtContext.VariableService,
                                  stmtContext.ScriptingService,
                                  stmtContext.TableService,
                                  stmtContext.ConfigSnapshot,
                                  stmtContext.NamedWindowService));
        }
Ejemplo n.º 22
0
        private static StreamTableColWStreamName FindTableColumnMayByPrefixed(
            StreamTypeService streamTypeService,
            string streamAndPropName,
            TableCompileTimeResolver resolver)
        {
            var indexDot = streamAndPropName.IndexOf('.');

            if (indexDot == -1)
            {
                var pair = FindTableColumnAcrossStreams(streamTypeService, streamAndPropName, resolver);
                if (pair != null)
                {
                    return(new StreamTableColWStreamName(pair, null));
                }
            }
            else
            {
                var streamName = streamAndPropName.Substring(0, indexDot);
                var colName    = streamAndPropName.Substring(indexDot + 1);
                var streamNum  = streamTypeService.GetStreamNumForStreamName(streamName);
                if (streamNum == -1)
                {
                    return(null);
                }

                var pair = FindTableColumnForType(streamNum, streamTypeService.EventTypes[streamNum], colName, resolver);
                if (pair != null)
                {
                    return(new StreamTableColWStreamName(pair, streamName));
                }
            }

            return(null);
        }
Ejemplo n.º 23
0
        public override EnumEval GetEnumEval(
            MethodResolutionService methodResolutionService,
            EventAdapterService eventAdapterService,
            StreamTypeService streamTypeService,
            String statementId,
            String enumMethodUsedName,
            IList <ExprDotEvalParam> bodiesAndParameters,
            EventType inputEventType,
            Type collectionComponentType,
            int numStreamsIncoming,
            bool disablePropertyExpressionEventCollCache)
        {
            if (bodiesAndParameters.IsEmpty())
            {
                var aggMethodFactoryX = GetAggregatorFactory(collectionComponentType);
                TypeInfo = EPTypeHelper.SingleValue(aggMethodFactoryX.ValueType.GetBoxedType());
                return(new EnumEvalSumScalar(numStreamsIncoming, aggMethodFactoryX));
            }

            var first            = (ExprDotEvalParamLambda)bodiesAndParameters[0];
            var aggMethodFactory = GetAggregatorFactory(first.BodyEvaluator.ReturnType);
            var returnType       = aggMethodFactory.ValueType.GetBoxedType();

            TypeInfo = EPTypeHelper.SingleValue(returnType);
            if (inputEventType == null)
            {
                return(new EnumEvalSumScalarLambda(
                           first.BodyEvaluator, first.StreamCountIncoming, aggMethodFactory,
                           (ObjectArrayEventType)first.GoesToTypes[0]));
            }
            return(new EnumEvalSumEvents(first.BodyEvaluator, first.StreamCountIncoming, aggMethodFactory));
        }
Ejemplo n.º 24
0
        private ExprNode ValidateMeasureClause(ExprNode measureNode, StreamTypeService typeServiceMeasure, ISet <string> variablesMultiple, ISet <string> variablesSingle, StatementContext statementContext)

        {
            try
            {
                var exprEvaluatorContext = new ExprEvaluatorContextStatement(statementContext, false);
                var validationContext    = new ExprValidationContext(
                    typeServiceMeasure, statementContext.MethodResolutionService, null, statementContext.SchedulingService,
                    statementContext.VariableService, statementContext.TableService, exprEvaluatorContext,
                    statementContext.EventAdapterService, statementContext.StatementName, statementContext.StatementId,
                    statementContext.Annotations, statementContext.ContextDescriptor, statementContext.ScriptingService,
                    false, false, true, false, null, false);
                return(ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.MATCHRECOGMEASURE, measureNode, validationContext));
            }
            catch (ExprValidationPropertyException e)
            {
                var grouped = CollectionUtil.ToString(variablesMultiple);
                var single  = CollectionUtil.ToString(variablesSingle);
                var message = e.Message;
                if (!variablesMultiple.IsEmpty())
                {
                    message += ", ensure that grouped variables (variables " + grouped + ") are accessed via index (i.e. variable[0].property) or appear within an aggregation";
                }
                if (!variablesSingle.IsEmpty())
                {
                    message += ", ensure that singleton variables (variables " + single + ") are not accessed via index";
                }
                throw new ExprValidationPropertyException(message, e);
            }
        }
Ejemplo n.º 25
0
        public override EnumForge GetEnumForge(StreamTypeService streamTypeService,
            string enumMethodUsedName,
            IList<ExprDotEvalParam> bodiesAndParameters,
            EventType inputEventType,
            Type collectionComponentType,
            int numStreamsIncoming,
            bool disablePropertyExpressionEventCollCache,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices services)
        {
            var initValueParam = bodiesAndParameters[0];
            var initValueEval = initValueParam.BodyForge;
            TypeInfo = EPTypeHelper.SingleValue(initValueEval.EvaluationType.GetBoxedType());

            var resultAndAdd = (ExprDotEvalParamLambda) bodiesAndParameters[1];

            if (inputEventType != null) {
                return new EnumAggregateEventsForge(
                    initValueEval,
                    resultAndAdd.BodyForge,
                    resultAndAdd.StreamCountIncoming,
                    (ObjectArrayEventType) resultAndAdd.GoesToTypes[0]);
            }

            return new EnumAggregateScalarForge(
                initValueEval,
                resultAndAdd.BodyForge,
                resultAndAdd.StreamCountIncoming,
                (ObjectArrayEventType) resultAndAdd.GoesToTypes[0],
                (ObjectArrayEventType) resultAndAdd.GoesToTypes[1]);
        }
Ejemplo n.º 26
0
        public override EnumForge GetEnumForge(
            StreamTypeService streamTypeService,
            string enumMethodUsedName,
            IList<ExprDotEvalParam> bodiesAndParameters,
            EventType inputEventType,
            Type collectionComponentType,
            int numStreamsIncoming,
            bool disablePropertyExpressionEventCollCache,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices services)
        {
            if (bodiesAndParameters.IsEmpty()) {
                var aggMethodFactoryInner = GetAggregatorFactory(collectionComponentType);
                TypeInfo = EPTypeHelper.SingleValue(aggMethodFactoryInner.ValueType.GetBoxedType());
                return new EnumSumScalarForge(numStreamsIncoming, aggMethodFactoryInner);
            }

            var first = (ExprDotEvalParamLambda) bodiesAndParameters[0];
            var aggMethodFactory = GetAggregatorFactory(first.BodyForge.EvaluationType);
            var returnType = aggMethodFactory.ValueType.GetBoxedType();
            TypeInfo = EPTypeHelper.SingleValue(returnType);
            if (inputEventType == null) {
                return new EnumSumScalarLambdaForge(
                    first.BodyForge,
                    first.StreamCountIncoming,
                    aggMethodFactory,
                    (ObjectArrayEventType) first.GoesToTypes[0]);
            }

            return new EnumSumEventsForge(first.BodyForge, first.StreamCountIncoming, aggMethodFactory);
        }
Ejemplo n.º 27
0
        private static void TryResolveByStreamAndPropNameBoth(StreamTypeService service)
        {
            // Test lookup by stream name and prop name
            PropertyResolutionDescriptor desc = service.ResolveByStreamAndPropName(
                "s4", "Volume", false);

            Assert.AreEqual(3, desc.StreamNum);
            Assert.AreEqual(typeof(long?), desc.PropertyType);
            Assert.AreEqual("Volume", desc.PropertyName);
            Assert.AreEqual("s4", desc.StreamName);
            Assert.AreEqual(typeof(SupportMarketDataBean),
                            desc.StreamEventType.UnderlyingType);

            try
            {
                service.ResolveByStreamAndPropName("xxx", "Volume", false);
                Assert.Fail();
            }
            catch (StreamNotFoundException ex)
            {
                // Expected
            }

            try
            {
                service.ResolveByStreamAndPropName("s4", "xxxx", false);
                Assert.Fail();
            }
            catch (PropertyNotFoundException ex)
            {
                // Expected
            }
        }
Ejemplo n.º 28
0
        public static ExprNode ValidateExpr(
            string viewName,
            ExprNode expression,
            StreamTypeService streamTypeService,
            ViewForgeEnv viewForgeEnv,
            int expressionNumber,
            int streamNumber)
        {
            ExprNode validated;
            try {
                var names = new ExprValidationMemberNameQualifiedView(streamNumber);
                var validationContext = new ExprValidationContextBuilder(
                        streamTypeService,
                        viewForgeEnv.StatementRawInfo,
                        viewForgeEnv.StatementCompileTimeServices)
                    .WithMemberName(names)
                    .Build();
                validated = ExprNodeUtilityValidate.GetValidatedSubtree(
                    ExprNodeOrigin.VIEWPARAMETER,
                    expression,
                    validationContext);
            }
            catch (ExprValidationException ex) {
                var message = "Invalid parameter expression " + expressionNumber + GetViewDesc(viewName);
                if (ex.Message != null) {
                    message += ": " + ex.Message;
                }

                throw new ViewParameterException(message, ex);
            }

            return validated;
        }
 public StatementAgentInstanceFactorySelect(
     int numStreams,
     ViewableActivator[] eventStreamParentViewableActivators,
     StatementContext statementContext,
     StatementSpecCompiled statementSpec,
     EPServicesContext services,
     StreamTypeService typeService,
     ViewFactoryChain[] unmaterializedViewChain,
     ResultSetProcessorFactoryDesc resultSetProcessorFactoryDesc,
     StreamJoinAnalysisResult joinAnalysisResult,
     bool recoveringResilient,
     JoinSetComposerPrototype joinSetComposerPrototype,
     SubSelectStrategyCollection subSelectStrategyCollection,
     ViewResourceDelegateVerified viewResourceDelegate,
     OutputProcessViewFactory outputProcessViewFactory) :
     base(statementSpec.Annotations)
 {
     _numStreams = numStreams;
     _eventStreamParentViewableActivators = eventStreamParentViewableActivators;
     _statementContext              = statementContext;
     _statementSpec                 = statementSpec;
     _services                      = services;
     _typeService                   = typeService;
     _unmaterializedViewChain       = unmaterializedViewChain;
     _resultSetProcessorFactoryDesc = resultSetProcessorFactoryDesc;
     _joinAnalysisResult            = joinAnalysisResult;
     _joinSetComposerPrototype      = joinSetComposerPrototype;
     _subSelectStrategyCollection   = subSelectStrategyCollection;
     _viewResourceDelegate          = viewResourceDelegate;
     _outputProcessViewFactory      = outputProcessViewFactory;
 }
Ejemplo n.º 30
0
 public FilterSpecCompilerArgs(
     IDictionary<string, Pair<EventType, string>> taggedEventTypes,
     IDictionary<string, Pair<EventType, string>> arrayEventTypes,
     ExprEvaluatorContext exprEvaluatorContext,
     string statementName,
     string statementId,
     StreamTypeService streamTypeService,
     MethodResolutionService methodResolutionService,
     TimeProvider timeProvider,
     VariableService variableService,
     TableService tableService,
     EventAdapterService eventAdapterService,
     ScriptingService scriptingService,
     Attribute[] annotations,
     ContextDescriptor contextDescriptor,
     ConfigurationInformation configurationInformation)
 {
     TaggedEventTypes = taggedEventTypes;
     ArrayEventTypes = arrayEventTypes;
     ExprEvaluatorContext = exprEvaluatorContext;
     StatementName = statementName;
     StatementId = statementId;
     StreamTypeService = streamTypeService;
     MethodResolutionService = methodResolutionService;
     TimeProvider = timeProvider;
     VariableService = variableService;
     TableService = tableService;
     EventAdapterService = eventAdapterService;
     ScriptingService = scriptingService;
     Annotations = annotations;
     ContextDescriptor = contextDescriptor;
     ConfigurationInformation = configurationInformation;
 }