Ejemplo n.º 1
0
 private static Object WalkValue(
     EsperEPL2GrammarParser.ElementValueEnumContext ctx,
     EngineImportService engineImportService)
 {
     if (ctx.elementValueArrayEnum() != null)
     {
         return(WalkArray(ctx.elementValueArrayEnum(), engineImportService));
     }
     if (ctx.annotationEnum() != null)
     {
         return(Walk(ctx.annotationEnum(), engineImportService));
     }
     else if (ctx.v != null)
     {
         return(ctx.v.Text);
     }
     else if (ctx.classIdentifier() != null)
     {
         return(WalkClassIdent(ctx.classIdentifier(), engineImportService));
     }
     else
     {
         return(ASTConstantHelper.Parse(ctx.constant()));
     }
 }
Ejemplo n.º 2
0
        private static Object WalkClassIdent(
            EsperEPL2GrammarParser.ClassIdentifierContext ctx,
            EngineImportService engineImportService)
        {
            string enumValueText = ctx.GetText();
            Object enumValue;

            try
            {
                enumValue = TypeHelper.ResolveIdentAsEnumConst(enumValueText, engineImportService, true);
            }
            catch (ExprValidationException)
            {
                throw ASTWalkException.From(
                          "Annotation value '" + enumValueText +
                          "' is not recognized as an enumeration value, please check imports or use a primitive or string type");
            }
            if (enumValue != null)
            {
                return(enumValue);
            }
            throw ASTWalkException.From(
                      "Annotation enumeration value '" + enumValueText +
                      "' not recognized as an enumeration class, please check imports or type used");
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="engineImportService">is the engine imports</param>
 /// <param name="timeProvider">returns time</param>
 public MethodResolutionServiceImpl(
     EngineImportService engineImportService,
     TimeProvider timeProvider)
 {
     _engineImportService = engineImportService;
     _timeProvider        = timeProvider;
 }
Ejemplo n.º 4
0
        public ExprValidationContext(StreamTypeService streamTypeService, EngineImportService engineImportService, StatementExtensionSvcContext statementExtensionSvcContext, ViewResourceDelegateUnverified viewResourceDelegate, TimeProvider timeProvider, VariableService variableService, TableService tableService, ExprEvaluatorContext exprEvaluatorContext, EventAdapterService eventAdapterService, string statementName, int statementId, Attribute[] annotations, ContextDescriptor contextDescriptor, ScriptingService scriptingService, bool disablePropertyExpressionEventCollCache, bool allowRollupFunctions, bool allowBindingConsumption, bool isUnidirectionalJoin, string intoTableName, bool isFilterExpression)
        {
            StreamTypeService            = streamTypeService;
            EngineImportService          = engineImportService;
            StatementExtensionSvcContext = statementExtensionSvcContext;
            ViewResourceDelegate         = viewResourceDelegate;
            TimeProvider         = timeProvider;
            VariableService      = variableService;
            TableService         = tableService;
            ExprEvaluatorContext = exprEvaluatorContext;
            EventAdapterService  = eventAdapterService;
            StatementName        = statementName;
            StatementId          = statementId;
            Annotations          = annotations;
            ContextDescriptor    = contextDescriptor;
            ScriptingService     = scriptingService;
            IsDisablePropertyExpressionEventCollCache = disablePropertyExpressionEventCollCache;
            IsAllowRollupFunctions    = allowRollupFunctions;
            IsAllowBindingConsumption = allowBindingConsumption;
            IsResettingAggregations   = isUnidirectionalJoin;
            IntoTableName             = intoTableName;
            IsFilterExpression        = isFilterExpression;

            IsExpressionAudit       = AuditEnum.EXPRESSION.GetAudit(annotations) != null;
            IsExpressionNestedAudit = AuditEnum.EXPRESSION_NESTED.GetAudit(annotations) != null;
        }
Ejemplo n.º 5
0
        private Type[] GetKeyTypes(IList <CreateTableColumn> columns, EngineImportService engineImportService)
        {
            IList <Type> keys = new List <Type>();

            foreach (var col in columns)
            {
                if (col.PrimaryKey == null || !col.PrimaryKey.Value)
                {
                    continue;
                }
                var msg = "Column '" + col.ColumnName + "' may not be tagged as primary key";
                if (col.OptExpression != null)
                {
                    throw new ExprValidationException(msg + ", an expression cannot become a primary key column");
                }
                if (col.OptTypeIsArray != null && col.OptTypeIsArray.Value)
                {
                    throw new ExprValidationException(msg + ", an array-typed column cannot become a primary key column");
                }
                var type = EventTypeUtility.BuildType(new ColumnDesc(col.ColumnName, col.OptTypeName, false, false), engineImportService);
                if (!(type is Type))
                {
                    throw new ExprValidationException(msg + ", received unexpected event type '" + type + "'");
                }
                keys.Add((Type)type);
            }
            return(keys.ToArray());
        }
Ejemplo n.º 6
0
        public override EnumEval GetEnumEval(EngineImportService engineImportService, EventAdapterService eventAdapterService, StreamTypeService streamTypeService, int statementId, string enumMethodUsedName, IList <ExprDotEvalParam> bodiesAndParameters, EventType inputEventType, Type collectionComponentType, int numStreamsIncoming, bool disablePropertyExpressionEventCollCache)
        {
            bool max = this.EnumMethodEnum == EnumMethodEnum.MAX;

            Type returnType;

            if (bodiesAndParameters.IsEmpty())
            {
                returnType    = collectionComponentType.GetBoxedType();
                base.TypeInfo = EPTypeHelper.SingleValue(returnType);
                return(new EnumEvalMinMaxScalar(numStreamsIncoming, max));
            }

            var first = (ExprDotEvalParamLambda)bodiesAndParameters[0];

            returnType    = first.BodyEvaluator.ReturnType.GetBoxedType();
            base.TypeInfo = EPTypeHelper.SingleValue(returnType);

            if (inputEventType == null)
            {
                return(new EnumEvalMinMaxScalarLambda(
                           first.BodyEvaluator, first.StreamCountIncoming, max,
                           (ObjectArrayEventType)first.GoesToTypes[0]));
            }
            return(new EnumEvalMinMaxEvents(first.BodyEvaluator, first.StreamCountIncoming, max));
        }
Ejemplo n.º 7
0
 private static SignalHandler GetSignalHandler(
     int producerNum,
     Object target,
     LogicalChannelBindingMethodDesc consumingSignalBindingDesc,
     EngineImportService engineImportService)
 {
     if (consumingSignalBindingDesc == null)
     {
         return(SignalHandlerDefault.INSTANCE);
     }
     else
     {
         if (consumingSignalBindingDesc.BindingType is LogicalChannelBindingTypePassAlong)
         {
             return(new SignalHandlerDefaultWInvoke(
                        target, consumingSignalBindingDesc.Method, engineImportService));
         }
         else if (consumingSignalBindingDesc.BindingType is LogicalChannelBindingTypePassAlongWStream)
         {
             var streamInfo = (LogicalChannelBindingTypePassAlongWStream)consumingSignalBindingDesc.BindingType;
             return(new SignalHandlerDefaultWInvokeStream(
                        target, consumingSignalBindingDesc.Method, engineImportService, streamInfo.StreamNum));
         }
         else
         {
             throw new IllegalStateException(
                       "Unrecognized signal binding: " + consumingSignalBindingDesc.BindingType);
         }
     }
 }
Ejemplo n.º 8
0
        private static EPDataFlowEmitter GenerateRuntimeContext(
            string engineURI,
            string statementName,
            bool audit,
            string dataflowName,
            int producerOpNum,
            string operatorPrettyPrint,
            DataFlowSignalManager dataFlowSignalManager,
            IList <ObjectBindingPair>[] targetsPerStream,
            EPDataFlowInstantiationOptions options,
            EngineImportService engineImportService)
        {
            // handle no targets
            if (targetsPerStream == null)
            {
                return(new EPDataFlowEmitterNoTarget(producerOpNum, dataFlowSignalManager));
            }

            // handle single-stream case
            if (targetsPerStream.Length == 1)
            {
                var targets = targetsPerStream[0];

                // handle single-stream single target case
                if (targets.Count == 1)
                {
                    var target = targets[0];
                    return(GetSubmitHandler(
                               engineURI, statementName, audit, dataflowName, producerOpNum, operatorPrettyPrint,
                               dataFlowSignalManager, target, options.GetExceptionHandler(), engineImportService));
                }

                var handlers = new SubmitHandler[targets.Count];
                for (var i = 0; i < handlers.Length; i++)
                {
                    handlers[i] = GetSubmitHandler(
                        engineURI, statementName, audit, dataflowName, producerOpNum, operatorPrettyPrint,
                        dataFlowSignalManager, targets[i], options.GetExceptionHandler(), engineImportService);
                }
                return(new EPDataFlowEmitter1StreamNTarget(producerOpNum, dataFlowSignalManager, handlers));
            }
            else
            {
                // handle multi-stream case
                var handlersPerStream = new SubmitHandler[targetsPerStream.Length][];
                for (var streamNum = 0; streamNum < targetsPerStream.Length; streamNum++)
                {
                    var handlers = new SubmitHandler[targetsPerStream[streamNum].Count];
                    handlersPerStream[streamNum] = handlers;
                    for (var i = 0; i < handlers.Length; i++)
                    {
                        handlers[i] = GetSubmitHandler(
                            engineURI, statementName, audit, dataflowName, producerOpNum, operatorPrettyPrint,
                            dataFlowSignalManager, targetsPerStream[streamNum][i], options.GetExceptionHandler(),
                            engineImportService);
                    }
                }
                return(new EPDataFlowEmitterNStreamNTarget(producerOpNum, dataFlowSignalManager, handlersPerStream));
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="engineImportService">engine imports</param>
 /// <param name="variableService">variable names</param>
 /// <param name="configuration">the configuration</param>
 /// <param name="schedulingService">The scheduling service.</param>
 /// <param name="engineURI">The engine URI.</param>
 /// <param name="patternNodeFactory">The pattern node factory.</param>
 /// <param name="namedWindowMgmtService">The named window service.</param>
 /// <param name="contextManagementService">The context management service.</param>
 /// <param name="exprDeclaredService">The expr declared service.</param>
 /// <param name="contextDescriptor">optional context description</param>
 /// <param name="tableService">The table service.</param>
 public StatementSpecMapContext(
     IContainer container,
     EngineImportService engineImportService,
     VariableService variableService,
     ConfigurationInformation configuration,
     SchedulingService schedulingService,
     string engineURI,
     PatternNodeFactory patternNodeFactory,
     NamedWindowMgmtService namedWindowMgmtService,
     ContextManagementService contextManagementService,
     ExprDeclaredService exprDeclaredService,
     ContextDescriptor contextDescriptor,
     TableService tableService)
 {
     Container                = container;
     PlugInAggregations       = new LazyAllocatedMap <ConfigurationPlugInAggregationMultiFunction, PlugInAggregationMultiFunctionFactory>();
     TableExpressions         = new HashSet <ExprTableAccessNode>();
     EngineImportService      = engineImportService;
     VariableService          = variableService;
     Configuration            = configuration;
     VariableNames            = new HashSet <string>();
     SchedulingService        = schedulingService;
     EngineURI                = engineURI;
     PatternNodeFactory       = patternNodeFactory;
     NamedWindowMgmtService   = namedWindowMgmtService;
     ContextManagementService = contextManagementService;
     ExprDeclaredService      = exprDeclaredService;
     ContextDescriptor        = contextDescriptor;
     TableService             = tableService;
 }
 /// <summary>
 /// Adds configured variables to the variable service.
 /// </summary>
 /// <param name="variableService">service to add to</param>
 /// <param name="variables">configured variables</param>
 /// <param name="engineImportService">engine imports</param>
 internal static void InitVariables(
     VariableService variableService,
     IDictionary <string, ConfigurationVariable> variables,
     EngineImportService engineImportService)
 {
     foreach (var entry in variables)
     {
         try
         {
             var arrayType = TypeHelper.IsGetArrayType(entry.Value.VariableType);
             variableService.CreateNewVariable(
                 null, entry.Key, arrayType.First, entry.Value.IsConstant, arrayType.Second, false,
                 entry.Value.InitializationValue, engineImportService);
             variableService.AllocateVariableState(
                 entry.Key, EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID, null, false);
         }
         catch (VariableExistsException e)
         {
             throw new ConfigurationException("Error configuring variables: " + e.Message, e);
         }
         catch (VariableTypeException e)
         {
             throw new ConfigurationException("Error configuring variables: " + e.Message, e);
         }
     }
 }
Ejemplo n.º 11
0
 public void SetUp()
 {
     _engineImportService = new EngineImportServiceImpl(
         false, false, false, false, null, TimeZoneInfo.Local,
         ConfigurationEngineDefaults.ThreadingProfile.NORMAL,
         AggregationFactoryFactoryDefault.INSTANCE);
 }
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="eventAdapterService">is the event wrapper and type service</param>
 /// <param name="eventTypeIdGenerator">The event type id generator.</param>
 /// <param name="engineImportService">for imported aggregation functions and static functions</param>
 /// <param name="variableService">provides access to variable values</param>
 /// <param name="engineSettingsService">some engine settings are writable</param>
 /// <param name="valueAddEventService">Update event handling</param>
 /// <param name="metricReportingService">for metric reporting</param>
 /// <param name="statementEventTypeRef">statement to event type reference holding</param>
 /// <param name="statementVariableRef">statement to variable reference holding</param>
 /// <param name="plugInViews">The plug in views.</param>
 /// <param name="filterService">The filter service.</param>
 /// <param name="patternSubexpressionPoolSvc">The pattern subexpression pool SVC.</param>
 /// <param name="tableService">The table service.</param>
 public ConfigurationOperationsImpl(
     EventAdapterService eventAdapterService,
     EventTypeIdGenerator eventTypeIdGenerator,
     EngineImportService engineImportService,
     VariableService variableService,
     EngineSettingsService engineSettingsService,
     ValueAddEventService valueAddEventService,
     MetricReportingService metricReportingService,
     StatementEventTypeRef statementEventTypeRef,
     StatementVariableRef statementVariableRef,
     PluggableObjectCollection plugInViews,
     FilterService filterService,
     PatternSubexpressionPoolEngineSvc patternSubexpressionPoolSvc,
     MatchRecognizeStatePoolEngineSvc matchRecognizeStatePoolEngineSvc,
     TableService tableService)
 {
     _eventAdapterService              = eventAdapterService;
     _eventTypeIdGenerator             = eventTypeIdGenerator;
     _engineImportService              = engineImportService;
     _variableService                  = variableService;
     _engineSettingsService            = engineSettingsService;
     _valueAddEventService             = valueAddEventService;
     _metricReportingService           = metricReportingService;
     _statementEventTypeRef            = statementEventTypeRef;
     _statementVariableRef             = statementVariableRef;
     _plugInViews                      = plugInViews;
     _filterService                    = filterService;
     _patternSubexpressionPoolSvc      = patternSubexpressionPoolSvc;
     _matchRecognizeStatePoolEngineSvc = matchRecognizeStatePoolEngineSvc;
     _tableService                     = tableService;
 }
Ejemplo n.º 13
0
        public override EnumEval GetEnumEval(EngineImportService engineImportService, EventAdapterService eventAdapterService, StreamTypeService streamTypeService, int statementId, string enumMethodUsedName, IList <ExprDotEvalParam> bodiesAndParameters, EventType inputEventType, Type collectionComponentType, int numStreamsIncoming, bool disablePropertyExpressionEventCollCache)
        {
            ExprDotEvalParam initValueParam = bodiesAndParameters[0];
            ExprEvaluator    initValueEval  = initValueParam.BodyEvaluator;

            base.TypeInfo = EPTypeHelper.SingleValue(initValueEval.ReturnType.GetBoxedType());

            var resultAndAdd = (ExprDotEvalParamLambda)bodiesAndParameters[1];

            if (inputEventType != null)
            {
                return(new EnumEvalAggregateEvents(
                           initValueEval,
                           resultAndAdd.BodyEvaluator, resultAndAdd.StreamCountIncoming,
                           (ObjectArrayEventType)resultAndAdd.GoesToTypes[0]));
            }
            else
            {
                return(new EnumEvalAggregateScalar(
                           initValueEval,
                           resultAndAdd.BodyEvaluator, resultAndAdd.StreamCountIncoming,
                           (ObjectArrayEventType)resultAndAdd.GoesToTypes[0],
                           (ObjectArrayEventType)resultAndAdd.GoesToTypes[1]));
            }
        }
Ejemplo n.º 14
0
 public EPDataFlowInstanceImpl(
     String engineURI,
     String statementName,
     bool audit,
     String dataFlowName,
     Object userObject,
     String instanceId,
     EPDataFlowState state,
     IList <GraphSourceRunnable> sourceRunnables,
     IDictionary <int, Object> operators,
     ICollection <int> operatorBuildOrder,
     EPDataFlowInstanceStatistics statisticsProvider,
     IDictionary <String, Object> parameters,
     EngineImportService engineImportService)
 {
     _engineUri       = engineURI;
     _statementName   = statementName;
     _audit           = audit;
     _dataFlowName    = dataFlowName;
     _userObject      = userObject;
     _instanceId      = instanceId;
     _sourceRunnables = sourceRunnables;
     _operators       = new OrderedDictionary <int, Pair <object, bool> >();
     foreach (var entry in operators)
     {
         _operators.Put(entry.Key, new Pair <Object, Boolean>(entry.Value, false));
     }
     _operatorBuildOrder = operatorBuildOrder;
     _statisticsProvider = statisticsProvider;
     SetState(state);
     _parameters          = parameters;
     _engineImportService = engineImportService;
 }
Ejemplo n.º 15
0
        public static StatementSpecRaw CompileEPL(
            string eplStatement,
            string eplStatementForErrorMsg,
            bool addPleaseCheck,
            string statementName,
            SelectClauseStreamSelectorEnum defaultStreamSelector,
            EngineImportService engineImportService,
            VariableService variableService,
            SchedulingService schedulingService,
            string engineURI,
            ConfigurationInformation configSnapshot,
            PatternNodeFactory patternNodeFactory,
            ContextManagementService contextManagementService,
            ExprDeclaredService exprDeclaredService,
            TableService tableService)
        {
            if (Log.IsDebugEnabled)
            {
                Log.Debug(".createEPLStmt statementName=" + statementName + " eplStatement=" + eplStatement);
            }

            ParseResult parseResult = ParseHelper.Parse(
                eplStatement, eplStatementForErrorMsg, addPleaseCheck, EPLParseRule, true);
            ITree ast = parseResult.Tree;

            var walker = new EPLTreeWalkerListener(
                parseResult.TokenStream, engineImportService, variableService, schedulingService, defaultStreamSelector,
                engineURI, configSnapshot, patternNodeFactory, contextManagementService, parseResult.Scripts,
                exprDeclaredService, tableService);

            try
            {
                ParseHelper.Walk(ast, walker, eplStatement, eplStatementForErrorMsg);
            }
            catch (ASTWalkException ex)
            {
                Log.Error(".createEPL Error validating expression", ex);
                throw new EPStatementException(ex.Message, ex, eplStatementForErrorMsg);
            }
            catch (EPStatementSyntaxException ex)
            {
                throw;
            }
            catch (Exception ex)
            {
                string message = "Error in expression";
                Log.Debug(message, ex);
                throw new EPStatementException(GetNullableErrortext(message, ex.Message), ex, eplStatementForErrorMsg);
            }

            if (Log.IsDebugEnabled)
            {
                ASTUtil.DumpAST(ast);
            }

            StatementSpecRaw raw = walker.StatementSpec;

            raw.ExpressionNoAnnotations = parseResult.ExpressionWithoutAnnotations;
            return(raw);
        }
Ejemplo n.º 16
0
        private ICollection <Type> GetClassSet(string[] classIdentifiers, EngineImportService engineImportService)
        {
            var classList = new HashSet <Type>();

            foreach (String className in classIdentifiers)
            {
                // try the primitive names including "string"
                var clazz = TypeHelper.GetPrimitiveTypeForName(className.Trim());
                if (clazz != null)
                {
                    classList.Add(clazz);
                    classList.Add(clazz.GetBoxedType());
                    continue;
                }

                // try to look up the class, not a primitive type name
                try
                {
                    clazz = TypeHelper.GetClassForName(className.Trim(), engineImportService.GetClassForNameProvider());
                }
                catch (TypeLoadException e)
                {
                    throw new ExprValidationException("Class as listed in is function by name '" + className + "' cannot be loaded", e);
                }

                // Add primitive and boxed types, or type itself if not built-in
                classList.Add(clazz.GetPrimitiveType());
                classList.Add(clazz.GetBoxedType());
            }
            return(classList);
        }
Ejemplo n.º 17
0
        public ContextControllerHashedGetterSingleRow(
            string statementName,
            string functionName,
            Pair <Type, EngineImportSingleRowDesc> func,
            IList <ExprNode> parameters,
            int granularity,
            EngineImportService engineImportService,
            EventType eventType,
            EventAdapterService eventAdapterService,
            int statementId,
            TableService tableService,
            string engineURI)
        {
            ExprNodeUtilMethodDesc staticMethodDesc = ExprNodeUtility.ResolveMethodAllowWildcardAndStream(
                func.First.Name, null,
                func.Second.MethodName,
                parameters,
                engineImportService,
                eventAdapterService,
                statementId, true,
                eventType,
                new ExprNodeUtilResolveExceptionHandlerDefault(func.Second.MethodName, true),
                func.Second.MethodName,
                tableService, engineURI);

            _statementName = statementName;
            _evaluators    = staticMethodDesc.ChildEvals;
            _granularity   = granularity;
            _fastMethod    = staticMethodDesc.FastMethod;
        }
Ejemplo n.º 18
0
        public static void Validate3Stream(ExprNode topNode)
        {
            var streamTypeService = new SupportStreamTypeSvc3Stream();

            var factoriesPerStream = new ViewFactoryChain[3];

            for (var i = 0; i < factoriesPerStream.Length; i++)
            {
                var factories = new List <ViewFactory>();
                factories.Add(new LengthWindowViewFactory());
                factoriesPerStream[i] = new ViewFactoryChain(streamTypeService.EventTypes[i], factories);
            }
            var viewResources = new ViewResourceDelegateUnverified();

            EngineImportService engineImportService = SupportEngineImportServiceFactory.Make();

            VariableService variableService = new VariableServiceImpl(0, new SchedulingServiceImpl(new TimeSourceServiceImpl()), SupportEventAdapterService.Service, null);

            variableService.CreateNewVariable(null, "IntPrimitive", typeof(int?).FullName, false, false, false, 10, engineImportService);
            variableService.AllocateVariableState("IntPrimitive", EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID, null, false);
            variableService.CreateNewVariable(null, "var1", typeof(string).FullName, false, false, false, "my_variable_value", engineImportService);
            variableService.AllocateVariableState("var1", EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID, null, false);

            ExprNodeUtility.GetValidatedSubtree(
                ExprNodeOrigin.SELECT, topNode, new ExprValidationContext(
                    streamTypeService, SupportEngineImportServiceFactory.Make(),
                    null, viewResources,
                    null, variableService, null,
                    new SupportExprEvaluatorContext(null),
                    null, null, 1, null, null, null,
                    false, false, false, false, null, false));
        }
        private static Type ResolveClassForTypeName(string type, EngineImportService engineImportService)
        {
            var isArray = false;

            if (type != null && EventTypeUtility.IsPropertyArray(type))
            {
                isArray = true;
                type    = EventTypeUtility.GetPropertyRemoveArray(type);
            }

            if (type == null)
            {
                throw new ConfigurationException("A null value has been provided for the type");
            }
            Type clazz = TypeHelper.GetTypeForSimpleName(type);

            if (clazz == null)
            {
                throw new ConfigurationException("The type '" + type + "' is not a recognized type");
            }

            if (isArray)
            {
                clazz = Array.CreateInstance(clazz, 0).GetType();
            }
            return(clazz);
        }
Ejemplo n.º 20
0
        public override EnumEval GetEnumEval(EngineImportService engineImportService, EventAdapterService eventAdapterService, StreamTypeService streamTypeService, int statementId, string enumMethodUsedName, IList <ExprDotEvalParam> bodiesAndParameters, EventType inputEventType, Type collectionComponentType, int numStreamsIncoming, bool disablePropertyExpressionEventCollCache)
        {
            var first = (ExprDotEvalParamLambda)bodiesAndParameters[0];

            if (inputEventType != null)
            {
                TypeInfo = EPTypeHelper.CollectionOfEvents(inputEventType);
                if (first.GoesToNames.Count == 1)
                {
                    return(new EnumEvalWhereEvents(first.BodyEvaluator, first.StreamCountIncoming));
                }
                return(new EnumEvalWhereIndexEvents(
                           first.BodyEvaluator, first.StreamCountIncoming, (ObjectArrayEventType)first.GoesToTypes[1]));
            }

            TypeInfo = EPTypeHelper.CollectionOfSingleValue(collectionComponentType);
            if (first.GoesToNames.Count == 1)
            {
                return(new EnumEvalWhereScalar(
                           first.BodyEvaluator, first.StreamCountIncoming, (ObjectArrayEventType)first.GoesToTypes[0]));
            }
            return(new EnumEvalWhereScalarIndex(
                       first.BodyEvaluator, first.StreamCountIncoming, (ObjectArrayEventType)first.GoesToTypes[0],
                       (ObjectArrayEventType)first.GoesToTypes[1]));
        }
Ejemplo n.º 21
0
        public override EnumEval GetEnumEval(EngineImportService engineImportService, EventAdapterService eventAdapterService, StreamTypeService streamTypeService, int statementId, string enumMethodUsedName, IList <ExprDotEvalParam> bodiesAndParameters, EventType inputEventType, Type collectionComponentType, int numStreamsIncoming, bool disablePropertyExpressionEventCollCache)
        {
            base.TypeInfo = EPTypeHelper.SingleValue(typeof(Boolean));
            ExprEvaluator body = bodiesAndParameters[0].BodyEvaluator;

            return(new EnumEvalSequenceEqual(body, numStreamsIncoming));
        }
Ejemplo n.º 22
0
        public override EnumEval GetEnumEval(EngineImportService engineImportService, EventAdapterService eventAdapterService, StreamTypeService streamTypeService, int statementId, string enumMethodUsedName, IList <ExprDotEvalParam> bodiesAndParameters, EventType inputEventType, Type collectionComponentType, int numStreamsIncoming, bool disablePropertyExpressionEventCollCache)
        {
            base.TypeInfo = EPTypeHelper.SingleValue(typeof(GroupMap));
            var first = (ExprDotEvalParamLambda)bodiesAndParameters[0];

            if (bodiesAndParameters.Count == 2)
            {
                var second = (ExprDotEvalParamLambda)bodiesAndParameters[1];
                if (inputEventType == null)
                {
                    return(new EnumEvalGroupByKeyValueSelectorScalarLambda(
                               first.BodyEvaluator, first.StreamCountIncoming, second.BodyEvaluator,
                               (ObjectArrayEventType)first.GoesToTypes[0]));
                }
                return(new EnumEvalGroupByKeyValueSelectorEvents(
                           first.BodyEvaluator, first.StreamCountIncoming, second.BodyEvaluator));
            }
            if (inputEventType == null)
            {
                return(new EnumEvalGroupByKeySelectorScalarLambda(
                           first.BodyEvaluator, first.StreamCountIncoming,
                           (ObjectArrayEventType)first.GoesToTypes[0]));
            }
            return(new EnumEvalGroupByKeySelectorEvents(first.BodyEvaluator, first.StreamCountIncoming));
        }
Ejemplo n.º 23
0
 public StatementContextEngineServices(
     IContainer container,
     String engineURI,
     EventAdapterService eventAdapterService,
     NamedWindowMgmtService namedWindowMgmtService,
     VariableService variableService,
     TableService tableService,
     EngineSettingsService engineSettingsService,
     ValueAddEventService valueAddEventService,
     ConfigurationInformation configSnapshot,
     MetricReportingServiceSPI metricReportingService,
     ViewService viewService,
     ExceptionHandlingService exceptionHandlingService,
     ExpressionResultCacheService expressionResultCacheService,
     StatementEventTypeRef statementEventTypeRef,
     TableExprEvaluatorContext tableExprEvaluatorContext,
     EngineLevelExtensionServicesContext engineLevelExtensionServicesContext,
     RegexHandlerFactory regexHandlerFactory,
     StatementLockFactory statementLockFactory,
     ContextManagementService contextManagementService,
     ViewServicePreviousFactory viewServicePreviousFactory,
     EventTableIndexService eventTableIndexService,
     PatternNodeFactory patternNodeFactory,
     FilterBooleanExpressionFactory filterBooleanExpressionFactory,
     TimeSourceService timeSourceService,
     EngineImportService engineImportService,
     AggregationFactoryFactory aggregationFactoryFactory,
     SchedulingService schedulingService,
     ExprDeclaredService exprDeclaredService)
 {
     Container                           = container;
     EngineURI                           = engineURI;
     EventAdapterService                 = eventAdapterService;
     NamedWindowMgmtService              = namedWindowMgmtService;
     VariableService                     = variableService;
     TableService                        = tableService;
     EngineSettingsService               = engineSettingsService;
     ValueAddEventService                = valueAddEventService;
     ConfigSnapshot                      = configSnapshot;
     MetricReportingService              = metricReportingService;
     ViewService                         = viewService;
     ExceptionHandlingService            = exceptionHandlingService;
     ExpressionResultCacheService        = expressionResultCacheService;
     StatementEventTypeRef               = statementEventTypeRef;
     TableExprEvaluatorContext           = tableExprEvaluatorContext;
     EngineLevelExtensionServicesContext = engineLevelExtensionServicesContext;
     RegexHandlerFactory                 = regexHandlerFactory;
     StatementLockFactory                = statementLockFactory;
     ContextManagementService            = contextManagementService;
     ViewServicePreviousFactory          = viewServicePreviousFactory;
     EventTableIndexService              = eventTableIndexService;
     PatternNodeFactory                  = patternNodeFactory;
     FilterBooleanExpressionFactory      = filterBooleanExpressionFactory;
     TimeSourceService                   = timeSourceService;
     EngineImportService                 = engineImportService;
     AggregationFactoryFactory           = aggregationFactoryFactory;
     SchedulingService                   = schedulingService;
     ExprDeclaredService                 = exprDeclaredService;
 }
Ejemplo n.º 24
0
        public static BeanInstantiator MakeInstantiator(BeanEventType beanEventType, EngineImportService engineImportService)
        {
            // see if we use a factory method
            if (beanEventType.FactoryMethodName != null)
            {
                return(ResolveFactoryMethod(beanEventType, engineImportService));
            }

            // find public ctor
            EngineImportException ctorNotFoundEx;

            try
            {
                engineImportService.ResolveCtor(beanEventType.UnderlyingType, new Type[0]);
                if (beanEventType.FastClass != null)
                {
                    return(new BeanInstantiatorByNewInstanceFastClass(beanEventType.FastClass));
                }
                else
                {
                    return(new BeanInstantiatorByNewInstanceReflection(beanEventType.UnderlyingType));
                }
            }
            catch (EngineImportException ex)
            {
                ctorNotFoundEx = ex;
            }

            // not found ctor, see if FastClass can handle
            if (beanEventType.FastClass != null)
            {
                var fastClass = beanEventType.FastClass;
                try
                {
                    fastClass.NewInstance();
                    return(new BeanInstantiatorByNewInstanceFastClass(beanEventType.FastClass));
                }
                catch (TargetInvocationException e)
                {
                    string message = string.Format(
                        "Failed to instantiate class '{0}', define a factory method if the class has no suitable constructors: {1}",
                        fastClass.TargetType.FullName,
                        (e.InnerException ?? e).Message);
                    Log.Debug(message, e);
                }
                catch (ArgumentException e)
                {
                    string message =
                        string.Format(
                            "Failed to instantiate class '{0}', define a factory method if the class has no suitable constructors",
                            fastClass.TargetType.FullName);
                    Log.Debug(message, e);
                }
            }

            throw new EventBeanManufactureException(
                      "Failed to find no-arg constructor and no factory method has been configured and cannot use reflection to instantiate object of type " +
                      beanEventType.UnderlyingType.Name, ctorNotFoundEx);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Add a plug-in view.
 /// </summary>
 /// <param name="configurationPlugInViews">is a list of configured plug-in view objects.</param>
 /// <param name="configurationPlugInVirtualDW">The configuration plug in virtual DW.</param>
 /// <param name="engineImportService">The engine import service.</param>
 /// <throws>ConfigurationException if the configured views don't resolve</throws>
 public void AddViews(
     IList <ConfigurationPlugInView> configurationPlugInViews,
     IList <ConfigurationPlugInVirtualDataWindow> configurationPlugInVirtualDW,
     EngineImportService engineImportService)
 {
     InitViews(configurationPlugInViews, engineImportService);
     InitVirtualDW(configurationPlugInVirtualDW, engineImportService);
 }
Ejemplo n.º 26
0
 public override AggregationService MakeService(
     AgentInstanceContext agentInstanceContext,
     EngineImportService engineImportService,
     bool isSubquery,
     int?subqueryNumber)
 {
     return(new AggSvcGroupByNoAccessImpl(Evaluators, Aggregators));
 }
Ejemplo n.º 27
0
        public SignalHandlerDefaultWInvoke(Object target, MethodInfo method, EngineImportService engineImportService)
        {
            Target = target;

            FastClass fastClass = FastClass.Create(target.GetType());

            FastMethod = fastClass.GetMethod(method);
        }
Ejemplo n.º 28
0
        private static Pair <string, Object> WalkValuePair(
            EsperEPL2GrammarParser.ElementValuePairEnumContext ctx,
            EngineImportService engineImportService)
        {
            string name  = ctx.keywordAllowedIdent().GetText();
            Object value = WalkValue(ctx.elementValueEnum(), engineImportService);

            return(new Pair <string, Object>(name, value));
        }
Ejemplo n.º 29
0
 public ExprDotMethodEvalDuck(string statementName, EngineImportService engineImportService, string methodName, Type[] parameterTypes, ExprEvaluator[] parameters)
 {
     _statementName       = statementName;
     _engineImportService = engineImportService;
     _methodName          = methodName;
     _parameterTypes      = parameterTypes;
     _parameters          = parameters;
     _cache = new Dictionary <Type, FastMethod>();
 }
Ejemplo n.º 30
0
        private static BeanInstantiator ResolveFactoryMethod(BeanEventType beanEventType,
                                                             EngineImportService engineImportService)
        {
            string factoryMethodName = beanEventType.FactoryMethodName;

            int lastDotIndex = factoryMethodName.LastIndexOf('.');

            if (lastDotIndex == -1)
            {
                try
                {
                    MethodInfo method = engineImportService.ResolveMethod(
                        beanEventType.UnderlyingType, factoryMethodName, new Type[0], new bool[0], new bool[0]);
                    if (beanEventType.FastClass != null)
                    {
                        return(new BeanInstantiatorByFactoryFastClass(beanEventType.FastClass.GetMethod(method)));
                    }
                    else
                    {
                        return(new BeanInstantiatorByFactoryReflection(method));
                    }
                }
                catch (EngineImportException e)
                {
                    string message =
                        string.Format(
                            "Failed to resolve configured factory method '{0}' expected to exist for class '{1}'",
                            factoryMethodName, beanEventType.UnderlyingType);
                    Log.Info(message, e);
                    throw new EventBeanManufactureException(message, e);
                }
            }

            string className  = factoryMethodName.Substring(0, lastDotIndex);
            string methodName = factoryMethodName.Substring(lastDotIndex + 1);

            try
            {
                MethodInfo method = engineImportService.ResolveMethod(className, methodName, new Type[0], new bool[0], new bool[0]);
                if (beanEventType.FastClass != null)
                {
                    FastClass fastClassFactory = FastClass.Create(method.DeclaringType);
                    return(new BeanInstantiatorByFactoryFastClass(fastClassFactory.GetMethod(method)));
                }
                else
                {
                    return(new BeanInstantiatorByFactoryReflection(method));
                }
            }
            catch (EngineImportException e)
            {
                String message = "Failed to resolve configured factory method '" + methodName +
                                 "' expected to exist for class '" + className + "'";
                Log.Info(message, e);
                throw new EventBeanManufactureException(message, e);
            }
        }