public ExprDeclaredNodeImpl( ExpressionDeclItem prototype, IList<ExprNode> chainParameters, ContextCompileTimeDescriptor contextDescriptor, ExprNode expressionBodyCopy) { PrototypeWVisibility = prototype; ChainParameters = chainParameters; ExpressionBodyCopy = expressionBodyCopy; // replace context-properties where they are currently identifiers if (contextDescriptor == null) { return; } var visitorWParent = new ExprNodeIdentVisitorWParent(); expressionBodyCopy.Accept(visitorWParent); foreach (var pair in visitorWParent.IdentNodes) { var streamOrProp = pair.Second.StreamOrPropertyName; if (streamOrProp != null && contextDescriptor.ContextPropertyRegistry.IsContextPropertyPrefix(streamOrProp)) { var context = new ExprContextPropertyNodeImpl(pair.Second.UnresolvedPropertyName); if (pair.First == null) { ExpressionBodyCopy = context; } else { ExprNodeUtilityModify.ReplaceChildNode(pair.First, pair.Second, context); } } } }
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; }
public SelectProcessorArgs( SelectClauseElementCompiled[] selectionList, GroupByRollupInfo groupByRollupInfo, bool isUsingWildcard, EventType optionalInsertIntoEventType, ForClauseSpec forClauseSpec, StreamTypeService typeService, ContextCompileTimeDescriptor contextDescriptor, bool isFireAndForget, Attribute[] annotations, StatementRawInfo statementRawInfo, StatementCompileTimeServices compileTimeServices) { SelectionList = selectionList; GroupByRollupInfo = groupByRollupInfo; IsUsingWildcard = isUsingWildcard; OptionalInsertIntoEventType = optionalInsertIntoEventType; ForClauseSpec = forClauseSpec; TypeService = typeService; ContextDescriptor = contextDescriptor; IsFireAndForget = isFireAndForget; Annotations = annotations; StatementRawInfo = statementRawInfo; CompileTimeServices = compileTimeServices; }
public StatementSpecMapContext( ContextCompileTimeDescriptor contextCompileTimeDescriptor, StatementSpecMapEnv mapEnv) { VariableNames = new HashSet<string>(); MapEnv = mapEnv; ContextCompileTimeDescriptor = contextCompileTimeDescriptor; }
public StatementSpecMapContext( ContextCompileTimeDescriptor contextCompileTimeDescriptor, StatementSpecMapEnv mapEnv) : this( contextCompileTimeDescriptor, mapEnv, new LazyAllocatedMap<HashableMultiKey, AggregationMultiFunctionForge>(), new List<ExpressionScriptProvided>(1)) { }
public ExpressionCopier( StatementSpecRaw statementSpecRaw, ContextCompileTimeDescriptor contextCompileTimeDescriptor, StatementCompileTimeServices services, ExprNodeSubselectDeclaredDotVisitor visitor) { this.statementSpecRaw = statementSpecRaw; this.contextCompileTimeDescriptor = contextCompileTimeDescriptor; this.services = services; this.visitor = visitor; }
public StatementSpecMapContext( ContextCompileTimeDescriptor contextCompileTimeDescriptor, StatementSpecMapEnv mapEnv, LazyAllocatedMap<HashableMultiKey, AggregationMultiFunctionForge> plugInAggregations, IList<ExpressionScriptProvided> scriptExpressions) { VariableNames = new HashSet<string>(); MapEnv = mapEnv; ContextCompileTimeDescriptor = contextCompileTimeDescriptor; this.PlugInAggregations = plugInAggregations; Scripts = scriptExpressions; }
public ExprEnumerationForgeDesc GetEnumerationForge( StreamTypeService streamTypeService, ContextCompileTimeDescriptor contextDescriptor) { var eventType = (EventTypeSPI) contextDescriptor.ContextPropertyRegistry.ContextEventType; var fragmentEventType = eventType?.GetFragmentType(PropertyName); if (fragmentEventType == null || fragmentEventType.IsIndexed) { return null; } var forge = new ExprContextPropertyNodeFragmentEnumerationForge( PropertyName, fragmentEventType.FragmentType, getter); return new ExprEnumerationForgeDesc(forge, true, -1); }
private static Pair<ExprNode, StatementSpecMapContext> GetExprDeclaredNode( Expression expression, ICollection<ExpressionDeclItem> stmtLocalExpressions, ContextCompileTimeDescriptor contextCompileTimeDescriptor, StatementSpecMapEnv mapEnv) { var mapContext = new StatementSpecMapContext(contextCompileTimeDescriptor, mapEnv); foreach (var item in stmtLocalExpressions) { mapContext.AddExpressionDeclarations(item); } var body = StatementSpecMapper.MapExpression(expression, mapContext); return new Pair<ExprNode, StatementSpecMapContext>(body, mapContext); }
public FilterSpecCompilerArgs( IDictionary<string, Pair<EventType, string>> taggedEventTypes, IDictionary<string, Pair<EventType, string>> arrayEventTypes, StreamTypeService streamTypeService, ContextCompileTimeDescriptor contextDescriptor, StatementRawInfo statementRawInfo, StatementCompileTimeServices compileTimeServices) { this.taggedEventTypes = taggedEventTypes; this.arrayEventTypes = arrayEventTypes; this.streamTypeService = streamTypeService; this.contextDescriptor = contextDescriptor; this.statementRawInfo = statementRawInfo; this.compileTimeServices = compileTimeServices; }
private static Pair<ExprNode, StatementSpecMapContext> GetExprDeclaredNode( Expression expression, ICollection<ExpressionDeclItem> stmtLocalExpressions, ContextCompileTimeDescriptor contextCompileTimeDescriptor, StatementSpecMapEnv mapEnv, LazyAllocatedMap<HashableMultiKey, AggregationMultiFunctionForge> plugInAggregations, IList<ExpressionScriptProvided> scripts) { var mapContext = new StatementSpecMapContext(contextCompileTimeDescriptor, mapEnv, plugInAggregations, scripts); foreach (var item in stmtLocalExpressions) { mapContext.AddExpressionDeclaration(item); } var body = StatementSpecMapper.MapExpression(expression, mapContext); return new Pair<ExprNode, StatementSpecMapContext>(body, mapContext); }
public static Pair<ExprDeclaredNodeImpl, StatementSpecMapContext> GetExistsDeclaredExpr( string name, IList<ExprNode> parameters, ICollection<ExpressionDeclItem> stmtLocalExpressions, ContextCompileTimeDescriptor contextCompileTimeDescriptor, StatementSpecMapEnv mapEnv, LazyAllocatedMap<HashableMultiKey, AggregationMultiFunctionForge> plugInAggregations, IList<ExpressionScriptProvided> scripts) { // Find among local expressions if (!stmtLocalExpressions.IsEmpty()) { foreach (var declNode in stmtLocalExpressions) { if (declNode.Name.Equals(name)) { var pair = GetExprDeclaredNode( declNode.OptionalSoda, stmtLocalExpressions, contextCompileTimeDescriptor, mapEnv, plugInAggregations, scripts); var declared = new ExprDeclaredNodeImpl( declNode, parameters, contextCompileTimeDescriptor, pair.First); return new Pair<ExprDeclaredNodeImpl, StatementSpecMapContext>(declared, pair.Second); } } } // find among global expressions var found = mapEnv.ExprDeclaredCompileTimeResolver.Resolve(name); if (found != null) { var expression = found.OptionalSoda; if (expression == null) { var bytes = found.OptionalSodaBytes.Invoke(); expression = (Expression) SerializerUtil.ByteArrToObject(bytes); } var pair = GetExprDeclaredNode(expression, stmtLocalExpressions, contextCompileTimeDescriptor, mapEnv, plugInAggregations, scripts); var declared = new ExprDeclaredNodeImpl(found, parameters, contextCompileTimeDescriptor, pair.First); return new Pair<ExprDeclaredNodeImpl, StatementSpecMapContext>(declared, pair.Second); } return null; }
public ExprEnumerationForgeDesc GetEnumerationForge( StreamTypeService streamTypeService, ContextCompileTimeDescriptor contextDescriptor) { if (_eventType == null) { return null; } if (streamTypeService.EventTypes.Length > 1) { return null; } return new ExprEnumerationForgeDesc( new ExprStreamUnderlyingNodeEnumerationForge("*", 0, _eventType), streamTypeService.IStreamOnly[0], 0); }
public StatementRawInfo( int statementNumber, string statementName, Attribute[] annotations, StatementType statementType, ContextCompileTimeDescriptor optionalContextDescriptor, string intoTableName, Compilable compilable, string moduleName) { StatementNumber = statementNumber; StatementName = statementName; Annotations = annotations; StatementType = statementType; OptionalContextDescriptor = optionalContextDescriptor; IntoTableName = intoTableName; Compilable = compilable; ModuleName = moduleName; }
public static void ProcessChainable( EsperEPL2GrammarParser.ChainableContext ctx, IDictionary <ITree, ExprNode> astExprNodeMap, ContextCompileTimeDescriptor contextCompileTimeDescriptor, StatementSpecMapEnv mapEnv, StatementSpecRaw statementSpec, ExpressionDeclDesc expressionDeclarations, LazyAllocatedMap <HashableMultiKey, AggregationMultiFunctionForge> plugInAggregations, IList <ExpressionScriptProvided> scriptExpressions) { // we first convert the event property into chain spec IList <Chainable> chain = ASTChainSpecHelper.GetChainables(ctx, astExprNodeMap); // process chain StatementSpecMapContext mapContext = new StatementSpecMapContext(contextCompileTimeDescriptor, mapEnv, plugInAggregations, scriptExpressions); mapContext.AddExpressionDeclarations(expressionDeclarations); ExprNode node = ChainableWalkHelper.ProcessDot(false, true, chain, mapContext); astExprNodeMap.Put(ctx, node); mapContext.AddTo(statementSpec); }
public ExprEnumerationForgeDesc GetEnumerationForge(StreamTypeService streamTypeService, ContextCompileTimeDescriptor contextDescriptor) { return new ExprEnumerationForgeDesc( new ExprStreamUnderlyingNodeEnumerationForge(StreamName, streamNum, eventType), streamTypeService.IStreamOnly[StreamId], StreamId); }
public static CompilableItem CompileItem( Compilable compilable, string optionalModuleName, string moduleIdentPostfix, int statementNumber, ISet<string> statementNames, ModuleCompileTimeServices moduleCompileTimeServices, CompilerOptions compilerOptions, out Assembly assembly) { var compileTimeServices = new StatementCompileTimeServices(statementNumber, moduleCompileTimeServices); // Stage 0 - parse and compile-inline-classes and walk statement var walked = ParseCompileInlinedClassesWalk(compilable, compileTimeServices); var raw = walked.StatementSpecRaw; string classNameCreateClass = null; if (raw.CreateClassProvided != null) { classNameCreateClass = DetermineClassNameCreateClass(walked.ClassesInlined); } try { // Stage 2(a) - precompile: compile annotations var annotations = AnnotationUtil.CompileAnnotations( raw.Annotations, compileTimeServices.ImportServiceCompileTime, compilable); // Stage 2(b) - walk subselects, alias expressions, declared expressions, dot-expressions ExprNodeSubselectDeclaredDotVisitor visitor; try { visitor = StatementSpecRawWalkerSubselectAndDeclaredDot.WalkSubselectAndDeclaredDotExpr(raw); } catch (ExprValidationException ex) { throw new StatementSpecCompileException(ex.Message, compilable.ToEPL()); } var subselectNodes = visitor.Subselects; // Determine a statement name var statementNameProvided = GetNameFromAnnotation(annotations); if (compilerOptions.StatementName != null) { var assignedName = compilerOptions.StatementName.Invoke( new StatementNameContext( () => compilable.ToEPL(), statementNameProvided, optionalModuleName, annotations, statementNumber)); if (assignedName != null) { statementNameProvided = assignedName; } } var statementName = statementNameProvided ?? Convert.ToString(statementNumber); if (statementNames.Contains(statementName)) { var count = 1; var newStatementName = statementName + "-" + count; while (statementNames.Contains(newStatementName)) { count++; newStatementName = statementName + "-" + count; } statementName = newStatementName; } statementName = statementName.Trim(); statementNames.Add(statementName); // Determine table access nodes var tableAccessNodes = DetermineTableAccessNodes(raw.TableExpressions, visitor); // compile scripts once in this central place, may also compile later in expression ScriptValidationPrecompileUtil.ValidateScripts( raw.ScriptExpressions, raw.ExpressionDeclDesc, compileTimeServices); // Determine subselects for compilation, and lambda-expression shortcut syntax for named windows if (!visitor.ChainedExpressionsDot.IsEmpty()) { RewriteNamedWindowSubselect( visitor.ChainedExpressionsDot, subselectNodes, compileTimeServices.NamedWindowCompileTimeResolver); } // Stage 2(c) compile context descriptor ContextCompileTimeDescriptor contextDescriptor = null; var optionalContextName = raw.OptionalContextName; if (optionalContextName != null) { var detail = compileTimeServices.ContextCompileTimeResolver.GetContextInfo(optionalContextName); if (detail == null) { throw new StatementSpecCompileException( "Context by name '" + optionalContextName + "' could not be found", compilable.ToEPL()); } contextDescriptor = new ContextCompileTimeDescriptor( optionalContextName, detail.ContextModuleName, detail.ContextVisibility, new ContextPropertyRegistry(detail), detail.ValidationInfos); } // Stage 2(d) compile raw statement spec var statementType = StatementTypeUtil.GetStatementType(raw).Value; var statementRawInfo = new StatementRawInfo( statementNumber, statementName, annotations, statementType, contextDescriptor, raw.IntoTableSpec?.Name, compilable, optionalModuleName); var compiledDesc = StatementRawCompiler.Compile( raw, compilable, false, false, annotations, subselectNodes, tableAccessNodes, statementRawInfo, compileTimeServices); var specCompiled = compiledDesc.Compiled; var statementIdentPostfix = IdentifierUtil.GetIdentifierMayStartNumeric(statementName); // get compile-time user object object userObjectCompileTime = null; if (compilerOptions.StatementUserObject != null) { userObjectCompileTime = compilerOptions.StatementUserObject.Invoke( new StatementUserObjectContext( () => compilable.ToEPL(), statementName, optionalModuleName, annotations, statementNumber)); } // handle hooks HandleStatementCompileHook(annotations, compileTimeServices, specCompiled); // Stage 3(a) - statement-type-specific forge building var @base = new StatementBaseInfo( compilable, specCompiled, userObjectCompileTime, statementRawInfo, optionalModuleName); StmtForgeMethod forgeMethod; if (raw.UpdateDesc != null) { forgeMethod = new StmtForgeMethodUpdate(@base); } else if (raw.OnTriggerDesc != null) { forgeMethod = new StmtForgeMethodOnTrigger(@base); } else if (raw.CreateIndexDesc != null) { forgeMethod = new StmtForgeMethodCreateIndex(@base); } else if (raw.CreateVariableDesc != null) { forgeMethod = new StmtForgeMethodCreateVariable(@base); } else if (raw.CreateDataFlowDesc != null) { forgeMethod = new StmtForgeMethodCreateDataflow(@base); } else if (raw.CreateTableDesc != null) { forgeMethod = new StmtForgeMethodCreateTable(@base); } else if (raw.CreateExpressionDesc != null) { forgeMethod = new StmtForgeMethodCreateExpression(@base); } else if (raw.CreateClassProvided != null) { forgeMethod = new StmtForgeMethodCreateClass(@base, walked.ClassesInlined, classNameCreateClass); } else if (raw.CreateWindowDesc != null) { forgeMethod = new StmtForgeMethodCreateWindow(@base); } else if (raw.CreateContextDesc != null) { forgeMethod = new StmtForgeMethodCreateContext(@base); } else if (raw.CreateSchemaDesc != null) { forgeMethod = new StmtForgeMethodCreateSchema(@base); } else { forgeMethod = new StmtForgeMethodSelect(@base); } // check context-validity conditions for this statement if (contextDescriptor != null) { try { foreach (var validator in contextDescriptor.ValidationInfos) { validator.ValidateStatement( contextDescriptor.ContextName, specCompiled, compileTimeServices); } } catch (ExprValidationException ex) { throw new StatementSpecCompileException(ex.Message, ex, compilable.ToEPL()); } } // Stage 3(b) - forge-factory-to-forge var classPostfix = moduleIdentPostfix + "_" + statementIdentPostfix; var forgeables = new List<StmtClassForgeable>(); // add forgeables from filter-related processing i.e. multikeys foreach (var additional in compiledDesc.AdditionalForgeables) { var namespaceScope = new CodegenNamespaceScope(compileTimeServices.Namespace, null, false); forgeables.Add(additional.Make(namespaceScope, classPostfix)); } var filterSpecCompileds = new List<FilterSpecCompiled>(); var scheduleHandleCallbackProviders = new List<ScheduleHandleCallbackProvider>(); var namedWindowConsumers = new List<NamedWindowConsumerStreamSpec>(); var filterBooleanExpressions = new List<FilterSpecParamExprNodeForge>(); var result = forgeMethod.Make(compileTimeServices.Namespace, classPostfix, compileTimeServices); forgeables.AddAll(result.Forgeables); VerifyForgeables(forgeables); filterSpecCompileds.AddAll(result.Filtereds); scheduleHandleCallbackProviders.AddAll(result.Scheduleds); namedWindowConsumers.AddAll(result.NamedWindowConsumers); filterBooleanExpressions.AddAll(result.FilterBooleanExpressions); // Stage 3(c) - filter assignments: assign filter callback ids and filter-path-num for boolean expressions var filterId = -1; foreach (var provider in filterSpecCompileds) { var assigned = ++filterId; provider.FilterCallbackId = assigned; } // Stage 3(d) - schedule assignments: assign schedule callback ids var scheduleId = 0; foreach (var provider in scheduleHandleCallbackProviders) { provider.ScheduleCallbackId = scheduleId++; } // Stage 3(e) - named window consumers: assign consumer id var namedWindowConsumerId = 0; foreach (var provider in namedWindowConsumers) { provider.NamedWindowConsumerId = namedWindowConsumerId++; } // Stage 3(f) - filter boolean expression id assignment var filterBooleanExprNum = 0; foreach (var expr in filterBooleanExpressions) { expr.FilterBoolExprId = filterBooleanExprNum++; } // Stage 3(f) - verify substitution parameters VerifySubstitutionParams(raw.SubstitutionParameters); // Stage 4 - forge-to-class (forge with statement-fields last) var classes = forgeables .Select(forgeable => forgeable.Forge(true, false)) .ToList(); // Stage 5 - refactor methods to make sure the constant pool does not grow too large for any given class CompilerHelperRefactorToStaticMethods.RefactorMethods( classes, compileTimeServices.Configuration.Compiler.ByteCode.MaxMethodsPerClass); // Stage 6 - sort to make the "fields" class first and all the rest later var sorted = classes .OrderBy(c => c.ClassType.GetSortCode()) .ToList(); // We are making sure JsonEventType receives the underlying class itself CompilableItemPostCompileLatch postCompile = CompilableItemPostCompileLatchDefault.INSTANCE; foreach (var eventType in compileTimeServices.EventTypeCompileTimeRegistry.NewTypesAdded) { if (eventType is JsonEventType) { postCompile = new CompilableItemPostCompileLatchJson( compileTimeServices.EventTypeCompileTimeRegistry.NewTypesAdded, compileTimeServices.ParentClassLoader); break; } } var container = compileTimeServices.Container; var compiler = container .RoslynCompiler() .WithCodeLogging(compileTimeServices.Configuration.Compiler.Logging.IsEnableCode) .WithCodeAuditDirectory(compileTimeServices.Configuration.Compiler.Logging.AuditDirectory) .WithCodegenClasses(sorted); assembly = compiler.Compile(); string statementProviderClassName = CodeGenerationIDGenerator.GenerateClassNameWithNamespace( compileTimeServices.Namespace, typeof(StatementProvider), classPostfix); var additionalClasses = new HashSet<Type>(); additionalClasses.AddAll(walked.ClassesInlined.Classes); compileTimeServices.ClassProvidedCompileTimeResolver.AddTo(additionalClasses); compileTimeServices.ClassProvidedCompileTimeRegistry.AddTo(additionalClasses); return new CompilableItem( statementProviderClassName, classes, postCompile, additionalClasses); } catch (StatementSpecCompileException) { throw; } catch (ExprValidationException ex) { throw new StatementSpecCompileException(ex.Message, ex, compilable.ToEPL()); } catch (EPException ex) { throw new StatementSpecCompileException(ex.Message, ex, compilable.ToEPL()); } catch (Exception ex) { var text = ex.Message ?? ex.GetType().FullName; throw new StatementSpecCompileException(text, ex, compilable.ToEPL()); } }
public static EPCompiled Compile( Compilable compilable, ModuleCompileTimeServices services, CompilerArguments args) { var compileTimeServices = new StatementCompileTimeServices(0, services); var walkResult = CompilerHelperSingleEPL.ParseCompileInlinedClassesWalk(compilable, compileTimeServices); var raw = walkResult.StatementSpecRaw; var statementType = StatementTypeUtil.GetStatementType(raw); if (statementType != StatementType.SELECT) { // the fire-and-forget spec is null for "select" and populated for I/U/D throw new StatementSpecCompileException( "Provided EPL expression is a continuous query expression (not an on-demand query)", compilable.ToEPL()); } var annotations = AnnotationUtil.CompileAnnotations( raw.Annotations, services.ImportServiceCompileTime, compilable); // walk subselects, alias expressions, declared expressions, dot-expressions var visitor = StatementSpecRawWalkerSubselectAndDeclaredDot.WalkSubselectAndDeclaredDotExpr(raw); // compile context descriptor ContextCompileTimeDescriptor contextDescriptor = null; var optionalContextName = raw.OptionalContextName; if (optionalContextName != null) { var detail = services.ContextCompileTimeResolver.GetContextInfo(optionalContextName); if (detail == null) { throw new StatementSpecCompileException( "Context by name '" + optionalContextName + "' could not be found", compilable.ToEPL()); } contextDescriptor = new ContextCompileTimeDescriptor( optionalContextName, detail.ContextModuleName, detail.ContextVisibility, new ContextPropertyRegistry(detail), detail.ValidationInfos); } var statementNameFromAnnotation = GetNameFromAnnotation(annotations); var statementName = statementNameFromAnnotation == null ? GetDefaultStatementName() : statementNameFromAnnotation.Trim(); var statementRawInfo = new StatementRawInfo( 0, statementName, annotations, statementType.Value, contextDescriptor, null, compilable, null); StatementSpecCompiledDesc compiledDesc = StatementRawCompiler.Compile( raw, compilable, false, true, annotations, visitor.Subselects, new List<ExprTableAccessNode>(raw.TableExpressions), statementRawInfo, compileTimeServices); StatementSpecCompiled specCompiled = compiledDesc.Compiled; var fafSpec = specCompiled.Raw.FireAndForgetSpec; //var @namespace = "generated"; var classPostfix = IdentifierUtil.GetIdentifierMayStartNumeric(statementName); EPCompiledManifest manifest; Assembly assembly; FAFQueryMethodForge query; if (specCompiled.Raw.InsertIntoDesc != null) { query = new FAFQueryMethodIUDInsertIntoForge( specCompiled, compilable, statementRawInfo, compileTimeServices); } else if (fafSpec == null) { // null indicates a select-statement, same as continuous query var desc = new FAFQueryMethodSelectDesc( specCompiled, compilable, statementRawInfo, compileTimeServices); var classNameResultSetProcessor = CodeGenerationIDGenerator.GenerateClassNameSimple( typeof(ResultSetProcessorFactoryProvider), classPostfix); query = new FAFQueryMethodSelectForge(desc, classNameResultSetProcessor, statementRawInfo); } else if (fafSpec is FireAndForgetSpecDelete) { query = new FAFQueryMethodIUDDeleteForge( specCompiled, compilable, statementRawInfo, compileTimeServices); } else if (fafSpec is FireAndForgetSpecUpdate) { query = new FAFQueryMethodIUDUpdateForge( specCompiled, compilable, statementRawInfo, compileTimeServices); } else { throw new IllegalStateException("Unrecognized FAF code " + fafSpec); } // verify substitution parameters VerifySubstitutionParams(raw.SubstitutionParameters); try { manifest = CompileToAssembly(query, classPostfix, args.Options, services, out assembly); } catch (EPCompileException) { throw; } catch (Exception ex) { throw new EPCompileException( "Unexpected exception compiling module: " + ex.Message, ex, new EmptyList<EPCompileExceptionItem>()); } return new EPCompiled(new [] { assembly }, manifest); }
public static StatementInformationalsCompileTime GetInformationals( StatementBaseInfo @base, IList<FilterSpecCompiled> filterSpecCompileds, IList<ScheduleHandleCallbackProvider> schedules, IList<NamedWindowConsumerStreamSpec> namedWindowConsumers, bool allowContext, SelectSubscriberDescriptor selectSubscriberDescriptor, CodegenNamespaceScope namespaceScope, StatementCompileTimeServices services) { var specCompiled = @base.StatementSpec; bool alwaysSynthesizeOutputEvents = specCompiled.Raw.InsertIntoDesc != null || specCompiled.Raw.ForClauseSpec != null || specCompiled.SelectClauseCompiled.IsDistinct || specCompiled.Raw.CreateDataFlowDesc != null; var needDedup = IsNeedDedup(filterSpecCompileds); bool hasSubquery = [email protected](); var canSelfJoin = StatementSpecWalkUtil.IsPotentialSelfJoin(specCompiled) || needDedup; // Determine stateless statement var stateless = DetermineStatelessSelect( @base.StatementRawInfo.StatementType, @base.StatementSpec.Raw, [email protected]()); string contextName = null; string contextModuleName = null; NameAccessModifier? contextVisibility = null; if (allowContext) { ContextCompileTimeDescriptor descriptor = @base.StatementRawInfo.OptionalContextDescriptor; if (descriptor != null) { contextName = descriptor.ContextName; contextModuleName = descriptor.ContextModuleName; contextVisibility = descriptor.ContextVisibility; } } var annotationData = AnnotationAnalysisResult.AnalyzeAnnotations(@base.StatementSpec.Annotations); // Hint annotations are often driven by variables var hasHint = false; if (@base.StatementSpec.Raw.Annotations != null) { foreach (Attribute annotation in @base.StatementRawInfo.Annotations) { if (annotation is HintAttribute) { hasHint = true; } } } var hasVariables = hasHint || [email protected]() || @base.StatementSpec.Raw.CreateContextDesc != null; var writesToTables = StatementLifecycleSvcUtil.IsWritesToTables( @base.StatementSpec.Raw, services.TableCompileTimeResolver); bool hasTableAccess = StatementLifecycleSvcUtil.DetermineHasTableAccess( @base.StatementSpec.SubselectNodes, @base.StatementSpec.Raw, services.TableCompileTimeResolver); IDictionary<StatementProperty, object> properties = new Dictionary<StatementProperty, object>(); if (services.Configuration.Compiler.ByteCode.IsAttachEPL) { properties.Put(StatementProperty.EPL, @base.Compilable.ToEPL()); } string insertIntoLatchName = null; if (@base.StatementSpec.Raw.InsertIntoDesc != null || @base.StatementSpec.Raw.OnTriggerDesc is OnTriggerMergeDesc) { if (@base.StatementSpec.Raw.InsertIntoDesc != null) { insertIntoLatchName = @base.StatementSpec.Raw.InsertIntoDesc.EventTypeName; } else { insertIntoLatchName = "merge"; } } bool allowSubscriber = services.Configuration.Compiler.ByteCode.IsAllowSubscriber; return new StatementInformationalsCompileTime( @base.StatementName, alwaysSynthesizeOutputEvents, contextName, contextModuleName, contextVisibility, canSelfJoin, hasSubquery, needDedup, specCompiled.Annotations, stateless, @base.UserObjectCompileTime, filterSpecCompileds.Count, schedules.Count, namedWindowConsumers.Count, @base.StatementRawInfo.StatementType, annotationData.Priority, annotationData.IsPremptive, hasVariables, writesToTables, hasTableAccess, selectSubscriberDescriptor.SelectClauseTypes, selectSubscriberDescriptor.SelectClauseColumnNames, selectSubscriberDescriptor.IsForClauseDelivery, selectSubscriberDescriptor.GroupDelivery, properties, @base.StatementSpec.Raw.MatchRecognizeSpec != null, services.IsInstrumented, namespaceScope, insertIntoLatchName, allowSubscriber); }
public ExprValidationContextBuilder WithContextDescriptor(ContextCompileTimeDescriptor contextDescriptor) { _contextDescriptor = contextDescriptor; return this; }