private static void LogFilterPlans( IList<ExprNode> validatedNodes, FilterSpecPlanForge plan, EventType eventType, string optionalStreamName, StatementRawInfo statementRawInfo) { var buf = new StringBuilder(); buf .Append("Filter plan for statement '") .Append(statementRawInfo.StatementName) .Append("' filtering event type '") .Append(eventType.Name + "'"); if (optionalStreamName != null) { buf.Append(" alias '" + optionalStreamName + "'"); } if (validatedNodes.IsEmpty()) { buf.Append(" empty"); } else { var andNode = ExprNodeUtilityMake.ConnectExpressionsByLogicalAndWhenNeeded(validatedNodes); var expression = ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(andNode); buf .Append(" expression '") .Append(expression) .Append("' for ") .Append(plan.Paths.Length) .Append(" paths"); } buf.Append(Environment.NewLine); plan.AppendPlan(buf); Log.Info(buf.ToString()); }
private static FilterSpecPlanForge PlanFilterParametersInternal( IList<ExprNode> validatedNodes, FilterSpecCompilerArgs args) { if (validatedNodes.IsEmpty()) { return EMPTY; } if (args.compileTimeServices.Configuration.Compiler.Execution.FilterIndexPlanning == ConfigurationCompilerExecution.FilterIndexPlanningEnum.NONE) { DecomposeCheckAggregation(validatedNodes); return BuildNoPlan(validatedNodes, args); } var performConditionPlanning = HasLevelOrHint(FilterSpecCompilerIndexPlannerHint.CONDITIONS, args.statementRawInfo, args.compileTimeServices); var filterParamExprMap = new FilterSpecParaForgeMap(); // Make filter parameter for each expression node, if it can be optimized. // Optionally receive a top-level control condition that negates var topLevelNegation = DecomposePopulateConsolidate(filterParamExprMap, performConditionPlanning, validatedNodes, args); // Use all filter parameter and unassigned expressions var countUnassigned = filterParamExprMap.CountUnassignedExpressions(); // we are done if there are no remaining nodes if (countUnassigned == 0) { return MakePlanFromTriplets(filterParamExprMap.Triplets, topLevelNegation, args); } // determine max-width var filterServiceMaxFilterWidth = args.compileTimeServices.Configuration.Compiler.Execution.FilterServiceMaxFilterWidth; var hint = HintEnum.MAX_FILTER_WIDTH.GetHint(args.statementRawInfo.Annotations); if (hint != null) { var hintValue = HintEnum.MAX_FILTER_WIDTH.GetHintAssignedValue(hint); filterServiceMaxFilterWidth = int.Parse(hintValue); } FilterSpecPlanForge plan = null; if (filterServiceMaxFilterWidth > 0) { if (performConditionPlanning) { plan = PlanRemainingNodesWithConditions(filterParamExprMap, args, filterServiceMaxFilterWidth, topLevelNegation); } else { plan = PlanRemainingNodesBasic(filterParamExprMap, args, filterServiceMaxFilterWidth); } } if (plan != null) { return plan; } // handle no-plan var triplets = new List<FilterSpecPlanPathTripletForge>(filterParamExprMap.Triplets); var unassignedExpressions = filterParamExprMap.UnassignedExpressions; var triplet = MakeRemainingNode(unassignedExpressions, args); triplets.Add(triplet); return MakePlanFromTriplets(triplets, topLevelNegation, args); }
/// <summary> /// Constructor - validates parameter list against event type, throws exception if invalid /// property names or mismatcing filter operators are found. /// </summary> /// <param name="eventType">is the event type</param> /// <param name="filterParameters">is a list of filter parameters</param> /// <param name="eventTypeName">is the name of the event type</param> /// <param name="optionalPropertyEvaluator">optional if evaluating properties returned by filtered events</param> /// <throws>ArgumentException if validation invalid</throws> public FilterSpecCompiled( EventType eventType, string eventTypeName, FilterSpecPlanForge filterParameters, PropertyEvaluatorForge optionalPropertyEvaluator) { FilterForEventType = eventType; FilterForEventTypeName = eventTypeName; Parameters = SortRemoveDups(filterParameters); OptionalPropertyEvaluator = optionalPropertyEvaluator; }
public static FilterSpecPlanForge SortRemoveDups(FilterSpecPlanForge parameters) { var processed = parameters.Paths .Select(v => SortRemoveDups(v)) .ToArray(); return new FilterSpecPlanForge( processed, parameters.FilterConfirm, parameters.FilterNegate, parameters.ConvertorForge); }
private static void PromoteControlConfirmSinglePathSingleTriplet(FilterSpecPlanForge plan) { if (plan.Paths.Length != 1) { return; } var path = plan.Paths[0]; if (path.Triplets.Length != 1) { return; } var controlConfirm = path.Triplets[0].TripletConfirm; if (controlConfirm == null) { return; } plan.FilterConfirm = controlConfirm; path.Triplets[0].TripletConfirm = null; }
public bool EqualsFilter(FilterSpecPlanForge other) { if (Paths.Length != other.Paths.Length) { return false; } for (var i = 0; i < Paths.Length; i++) { var myPath = Paths[i]; var otherPath = other.Paths[i]; if (!myPath.EqualsFilter(otherPath)) { return false; } } if (!ExprNodeUtilityCompare.DeepEqualsNullChecked(FilterConfirm, other.FilterConfirm, true)) { return false; } return ExprNodeUtilityCompare.DeepEqualsNullChecked(FilterNegate, other.FilterNegate, true); }