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)); }
private EventType HandleVariantType( CreateSchemaDesc spec, StatementCompileTimeServices services) { if (spec.CopyFrom != null && !spec.CopyFrom.IsEmpty()) { throw new ExprValidationException("Copy-from types are not allowed with variant types"); } var eventTypeName = spec.SchemaName; // determine typing var isAny = false; ISet<EventType> types = new LinkedHashSet<EventType>(); foreach (var typeName in spec.Types) { if (typeName.Trim().Equals("*")) { isAny = true; } else { var eventType = services.EventTypeCompileTimeResolver.GetTypeByName(typeName); if (eventType == null) { throw new ExprValidationException( "Event type by name '" + typeName + "' could not be found for use in variant stream by name '" + eventTypeName + "'"); } types.Add(eventType); } } var eventTypes = types.ToArray(); var variantSpec = new VariantSpec(eventTypes, isAny ? TypeVariance.ANY : TypeVariance.PREDEFINED); var visibility = services.ModuleVisibilityRules.GetAccessModifierEventType(@base.StatementRawInfo, spec.SchemaName); var eventBusVisibility = services.ModuleVisibilityRules.GetBusModifierEventType(@base.StatementRawInfo, eventTypeName); EventTypeUtility.ValidateModifiers(spec.SchemaName, eventBusVisibility, visibility); var metadata = new EventTypeMetadata( eventTypeName, @base.ModuleName, EventTypeTypeClass.VARIANT, EventTypeApplicationType.VARIANT, visibility, eventBusVisibility, false, EventTypeIdPair.Unassigned()); var variantEventType = new VariantEventType(metadata, variantSpec); services.EventTypeCompileTimeRegistry.NewType(variantEventType); return variantEventType; }
private EventType HandleCreateSchema( EPServicesContext services, StatementContext statementContext, CreateSchemaDesc spec) { EventType eventType; try { if (spec.AssignedType != AssignedType.VARIANT) { eventType = EventTypeUtility.CreateNonVariantType( false, spec, statementContext.Annotations, services.ConfigSnapshot, services.EventAdapterService, services.EngineImportService); } else { if (spec.CopyFrom != null && !spec.CopyFrom.IsEmpty()) { throw new ExprValidationException("Copy-from types are not allowed with variant types"); } var isAny = false; var config = new ConfigurationVariantStream(); foreach (var typeName in spec.Types) { if (typeName.Trim().Equals("*")) { isAny = true; break; } config.AddEventTypeName(typeName); } if (!isAny) { config.TypeVariance = TypeVarianceEnum.PREDEFINED; } else { config.TypeVariance = TypeVarianceEnum.ANY; } services.ValueAddEventService.AddVariantStream( spec.SchemaName, config, services.EventAdapterService, services.EventTypeIdGenerator); eventType = services.ValueAddEventService.GetValueAddProcessor(spec.SchemaName).ValueAddEventType; } } catch (Exception ex) { throw new ExprValidationException(ex.Message, ex); } return(eventType); }
private EventType HandleCreateSchema( CreateSchemaDesc spec, StatementCompileTimeServices services) { EventType eventType; try { if (spec.AssignedType != AssignedType.VARIANT) { eventType = EventTypeUtility.CreateNonVariantType(false, spec, @base, services); } else { eventType = HandleVariantType(spec, services); } } catch (EPException) { throw; } catch (Exception ex) { throw new ExprValidationException(ex.Message, ex); } return eventType; }
private EventTypeForgeablesPair HandleCreateSchema( CreateSchemaDesc spec, StatementCompileTimeServices services) { EventTypeForgeablesPair pair; try { if (spec.AssignedType != AssignedType.VARIANT) { pair = EventTypeUtility.CreateNonVariantType(false, spec, @base, services); } else { var eventType = HandleVariantType(spec, services); pair = new EventTypeForgeablesPair(eventType, EmptyList<StmtClassForgeableFactory>.Instance); } } catch (EPException) { throw; } catch (Exception ex) { throw new ExprValidationException(ex.Message, ex); } return pair; }