Ejemplo n.º 1
0
        public override EPStatementStartResult StartInternal(
            EPServicesContext services,
            StatementContext statementContext,
            bool isNewStatement,
            bool isRecoveringStatement,
            bool isRecoveringResilient)
        {
            CreateSchemaDesc spec = StatementSpec.CreateSchemaDesc;

            EPLValidationUtil.ValidateTableExists(services.TableService, spec.SchemaName);
            EventType eventType = HandleCreateSchema(services, statementContext, spec);

            // enter a reference
            services.StatementEventTypeRefService.AddReferences(
                statementContext.StatementName, new String[]
            {
                spec.SchemaName
            });

            EventType             allocatedEventType = eventType;
            EPStatementStopMethod stopMethod         = () =>
            {
                services.StatementEventTypeRefService.RemoveReferencesStatement(statementContext.StatementName);
                if (services.StatementEventTypeRefService.GetStatementNamesForType(spec.SchemaName).IsEmpty())
                {
                    services.EventAdapterService.RemoveType(allocatedEventType.Name);
                    services.FilterService.RemoveType(allocatedEventType);
                }
            };

            Viewable viewable = new ViewableDefaultImpl(eventType);

            return(new EPStatementStartResult(viewable, stopMethod, null));
        }
Ejemplo n.º 2
0
 private void CheckTableExists(string eventTypeName)
 {
     try {
         EPLValidationUtil.ValidateTableExists(_tableService, eventTypeName);
     } catch (ExprValidationException ex) {
         throw new ConfigurationException(ex.Message, ex);
     }
 }
Ejemplo n.º 3
0
        public StmtForgeMethodResult Make(
            string @namespace,
            string classPostfix,
            StatementCompileTimeServices services)
        {
            var statementSpec = @base.StatementSpec;

            var spec = statementSpec.Raw.CreateSchemaDesc;

            if (services.EventTypeCompileTimeResolver.GetTypeByName(spec.SchemaName) != null) {
                throw new ExprValidationException(
                    "Event type named '" + spec.SchemaName + "' has already been declared");
            }

            EPLValidationUtil.ValidateTableExists(services.TableCompileTimeResolver, spec.SchemaName);
            var eventType = HandleCreateSchema(spec, services);

            var statementFieldsClassName = CodeGenerationIDGenerator.GenerateClassNameSimple(
                typeof(StatementFields), classPostfix);
            var namespaceScope = new CodegenNamespaceScope(
                @namespace, statementFieldsClassName, services.IsInstrumented);
            var fieldsForgable = new StmtClassForgableStmtFields(statementFieldsClassName, namespaceScope, 0);

            var aiFactoryProviderClassName = CodeGenerationIDGenerator.GenerateClassNameSimple(
                typeof(StatementAIFactoryProvider),
                classPostfix);
            var forge = new StatementAgentInstanceFactoryCreateSchemaForge(eventType);
            var aiFactoryForgable = new StmtClassForgableAIFactoryProviderCreateSchema(
                aiFactoryProviderClassName,
                namespaceScope,
                forge);

            var selectSubscriberDescriptor = new SelectSubscriberDescriptor();
            var informationals = StatementInformationalsUtil.GetInformationals(
                @base,
                new EmptyList<FilterSpecCompiled>(),
                new EmptyList<ScheduleHandleCallbackProvider>(),
                new EmptyList<NamedWindowConsumerStreamSpec>(),
                false,
                selectSubscriberDescriptor,
                namespaceScope,
                services);
            var statementProviderClassName =
                CodeGenerationIDGenerator.GenerateClassNameSimple(typeof(StatementProvider), classPostfix);
            var stmtProvider = new StmtClassForgableStmtProvider(
                aiFactoryProviderClassName,
                statementProviderClassName,
                informationals,
                namespaceScope);

            IList<StmtClassForgable> forgables = new List<StmtClassForgable>();
            forgables.Add(fieldsForgable);
            forgables.Add(aiFactoryForgable);
            forgables.Add(stmtProvider);
            return new StmtForgeMethodResult(
                forgables,
                new EmptyList<FilterSpecCompiled>(),
                new EmptyList<ScheduleHandleCallbackProvider>(),
                new EmptyList<NamedWindowConsumerStreamSpec>(),
                new EmptyList<FilterSpecParamExprNodeForge>());
        }