internal static FilterSpecParamForge HandleBooleanLimited( ExprNode constituent, IDictionary<string, Pair<EventType, string>> taggedEventTypes, IDictionary<string, Pair<EventType, string>> arrayEventTypes, ISet<string> allTagNamesOrdered, StreamTypeService streamTypeService, StatementRawInfo raw, StatementCompileTimeServices services) { if (!HasLevelOrHint(FilterSpecCompilerIndexPlannerHint.BOOLCOMPOSITE, raw, services)) { return null; } // prequalify var prequalified = Prequalify(constituent); if (!prequalified) { return null; } // determine rewrite var desc = FindRewrite(constituent); if (desc == null) { return null; } // there is no value expression, i.e. "select * from SupportBean(theString = intPrimitive)" if (desc is RewriteDescriptorNoValueExpr) { var reboolExpression = ExprNodeUtilityPrint.ToExpressionStringMinPrecedence(constituent, new ExprNodeRenderableFlags(false)); var lookupable = new ExprFilterSpecLookupableForge(reboolExpression, null, constituent.Forge, null, true, null); return new FilterSpecParamValueNullForge(lookupable, FilterOperator.REBOOL); } // there is no value expression, i.e. "select * from SupportBean(theString regexp 'abc')" var withValueExpr = (RewriteDescriptorWithValueExpr) desc; ExprNode valueExpression = withValueExpr.ValueExpression; var valueExpressionType = valueExpression.Forge.EvaluationType; var replacement = new ExprFilterReboolValueNode(valueExpressionType); ExprNodeUtilityModify.ReplaceChildNode(withValueExpr.ValueExpressionParent, valueExpression, replacement); var validationContext = new ExprValidationContextBuilder(streamTypeService, raw, services).WithIsFilterExpression(true).Build(); var rebool = ExprNodeUtilityValidate.GetValidatedSubtree(ExprNodeOrigin.FILTER, constituent, validationContext); DataInputOutputSerdeForge serde = services.SerdeResolver.SerdeForFilter(valueExpressionType, raw); var convertor = GetMatchEventConvertor(valueExpression, taggedEventTypes, arrayEventTypes, allTagNamesOrdered); var reboolExpressionX = ExprNodeUtilityPrint.ToExpressionStringMinPrecedence(constituent, new ExprNodeRenderableFlags(false)); var lookupableX = new ExprFilterSpecLookupableForge(reboolExpressionX, null, rebool.Forge, valueExpressionType, true, serde); return new FilterSpecParamValueLimitedExprForge(lookupableX, FilterOperator.REBOOL, valueExpression, convertor, null); }
public InstrumentationBuilderExpr( Type generator, ExprForgeInstrumentable forge, string qname, Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { this.generator = generator; this.forge = forge; this.qname = qname; this.requiredType = requiredType; this.codegenMethodScope = codegenMethodScope; this.exprSymbol = exprSymbol; this.codegenClassScope = codegenClassScope; string text = ExprNodeUtilityPrint.ToExpressionStringMinPrecedence(forge); this.qParams.Insert(0, Constant(text)); }
public CodegenMethod InitializeCodegen( CodegenClassScope classScope, CodegenMethodScope parent, SAIFFInitializeSymbol symbols) { var method = parent.MakeChild(typeof(StatementAgentInstanceFactorySelect), GetType(), classScope); method.Block .DeclareVar<StatementAgentInstanceFactorySelect>( "saiff", NewInstance(typeof(StatementAgentInstanceFactorySelect))); // stream names method.Block.SetProperty(Ref("saiff"), "StreamNames", Constant(_streamNames)); // activators method.Block.DeclareVar<ViewableActivator[]>( "activators", NewArrayByLength(typeof(ViewableActivator), Constant(_viewableActivatorForges.Length))); for (var i = 0; i < _viewableActivatorForges.Length; i++) { method.Block.AssignArrayElement( "activators", Constant(i), _viewableActivatorForges[i].MakeCodegen(method, symbols, classScope)); } method.Block.SetProperty(Ref("saiff"), "ViewableActivators", Ref("activators")); // views method.Block.DeclareVar<ViewFactory[][]>( "viewFactories", NewArrayByLength(typeof(ViewFactory[]), Constant(_views.Length))); for (var i = 0; i < _views.Length; i++) { if (_views[i] != null) { var array = ViewFactoryForgeUtil.CodegenForgesWInit( _views[i], i, null, method, symbols, classScope); method.Block.AssignArrayElement("viewFactories", Constant(i), array); } } method.Block.SetProperty(Ref("saiff"), "ViewFactories", Ref("viewFactories")); // view delegate information ('prior' and 'prev') method.Block.DeclareVar<ViewResourceDelegateDesc[]>( "viewResourceDelegates", NewArrayByLength(typeof(ViewResourceDelegateDesc), Constant(_viewResourceDelegates.Length))); for (var i = 0; i < _viewResourceDelegates.Length; i++) { method.Block.AssignArrayElement( "viewResourceDelegates", Constant(i), _viewResourceDelegates[i].ToExpression()); } method.Block.SetProperty(Ref("saiff"), "ViewResourceDelegates", Ref("viewResourceDelegates")); // result set processor method.Block.DeclareVar( _resultSetProcessorProviderClassName, RSPFACTORYPROVIDER, NewInstanceInner(_resultSetProcessorProviderClassName, symbols.GetAddInitSvc(method), Ref(StmtClassForgeableAIFactoryProviderBase.MEMBERNAME_STATEMENT_FIELDS))) .SetProperty(Ref("saiff"), "ResultSetProcessorFactoryProvider", Ref(RSPFACTORYPROVIDER)); // where-clause evaluator if (_whereClauseForge != null) { var whereEval = CodegenEvaluator(_whereClauseForge, method, GetType(), classScope); method.Block.SetProperty(Ref("saiff"), "WhereClauseEvaluator", whereEval); if (classScope.IsInstrumented) { method.Block.SetProperty( Ref("saiff"), "WhereClauseEvaluatorTextForAudit", Constant(ExprNodeUtilityPrint.ToExpressionStringMinPrecedence(_whereClauseForge))); } } // joins if (_joinSetComposerPrototypeForge != null) { method.Block.SetProperty( Ref("saiff"), "JoinSetComposerPrototype", _joinSetComposerPrototypeForge.Make(method, symbols, classScope)); } // output process view method.Block.DeclareVar( _outputProcessViewProviderClassName, OPVFACTORYPROVIDER, NewInstanceInner(_outputProcessViewProviderClassName, symbols.GetAddInitSvc(method), Ref("statementFields"))) .SetProperty(Ref("saiff"), "OutputProcessViewFactoryProvider", Ref(OPVFACTORYPROVIDER)); // subselects if (!_subselects.IsEmpty()) { method.Block.SetProperty( Ref("saiff"), "Subselects", SubSelectFactoryForge.CodegenInitMap(_subselects, GetType(), method, symbols, classScope)); } // table-access if (!_tableAccesses.IsEmpty()) { method.Block.SetProperty( Ref("saiff"), "TableAccesses", ExprTableEvalStrategyUtil.CodegenInitMap(_tableAccesses, GetType(), method, symbols, classScope)); } // order-by with no output-limit method.Block.SetProperty( Ref("saiff"), "OrderByWithoutOutputRateLimit", Constant(_orderByWithoutOutputRateLimit)); // unidirectional join method.Block.SetProperty(Ref("saiff"), "IsUnidirectionalJoin", Constant(_unidirectionalJoin)); method.Block.MethodReturn(Ref("saiff")); return method; }
public static CodegenExpression Codegen( ExprDotNodeForgeStream forge, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var evaluationType = forge.EvaluationType; var eventUndType = forge.EventType.UnderlyingType; var methodNode = codegenMethodScope.MakeChild( evaluationType, typeof(ExprDotNodeForgeStreamEvalMethod), codegenClassScope); var refEPS = exprSymbol.GetAddEPS(methodNode); var block = methodNode.Block .Apply( Instblock( codegenClassScope, "qExprStreamUndMethod", Constant(ExprNodeUtilityPrint.ToExpressionStringMinPrecedence(forge)))) .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(forge.StreamNumber))); if (evaluationType == typeof(void)) { block.IfCondition(EqualsNull(Ref("@event"))) .Apply(Instblock(codegenClassScope, "aExprStreamUndMethod", ConstantNull())) .BlockReturnNoValue(); } else { block.IfRefNull("@event") .Apply(Instblock(codegenClassScope, "aExprStreamUndMethod", ConstantNull())) .BlockReturn(ConstantNull()); } var typeInformation = ConstantNull(); if (codegenClassScope.IsInstrumented) { typeInformation = codegenClassScope.AddOrGetDefaultFieldSharable( new EPTypeCodegenSharable( EPTypeHelper.SingleValue(forge.EventType.UnderlyingType), codegenClassScope)); } block.DeclareVar(eventUndType, "inner", Cast(eventUndType, ExprDotName(Ref("@event"), "Underlying"))) .Apply( Instblock( codegenClassScope, "qExprDotChain", typeInformation, Ref("inner"), Constant(forge.Evaluators.Length))); var invoke = ExprDotNodeUtility.EvaluateChainCodegen( methodNode, exprSymbol, codegenClassScope, Ref("inner"), eventUndType, forge.Evaluators, null); if (evaluationType == typeof(void)) { block.Expression(invoke) .Apply(Instblock(codegenClassScope, "aExprDotChain")) .Apply(Instblock(codegenClassScope, "aExprStreamUndMethod", ConstantNull())) .MethodEnd(); } else { block.DeclareVar(evaluationType, "result", invoke) .Apply(Instblock(codegenClassScope, "aExprDotChain")) .Apply(Instblock(codegenClassScope, "aExprStreamUndMethod", Ref("result"))) .MethodReturn(Ref("result")); } return LocalMethod(methodNode); }