/// <summary>Add a node and filter param. </summary> /// <param name="exprNode">is the node to add</param> /// <param name="param">is null if the expression node has not optimized form</param> public void Put(ExprNode exprNode, FilterSpecParam param) { _exprNodes.Put(exprNode, param); if (param != null) { _specParams.Put(param, exprNode); } }
public static FilterSpecParam[][] SortRemoveDups(IList <FilterSpecParam>[] parameters) { var processed = new FilterSpecParam[parameters.Length][]; for (int i = 0; i < parameters.Length; i++) { processed[i] = SortRemoveDups(parameters[i]); } return(processed); }
/// <summary>Remove a filter parameter leaving the expression node in place. </summary> /// <param name="param">filter parameter to remove</param> public void RemoveValue(FilterSpecParam param) { ExprNode exprNode = _specParams.Get(param); if (exprNode == null) { throw new IllegalStateException("Not found in collection param: " + param); } _specParams.Remove(param); _exprNodes.Put(exprNode, null); }
public void TestEquals() { FilterSpecParam c1 = MakeParam("a", FilterOperator.RANGE_CLOSED, new DoubleRange(5d, 6d)); FilterSpecParam c2 = MakeParam("b", FilterOperator.RANGE_CLOSED, new DoubleRange(5d, 6d)); FilterSpecParam c3 = MakeParam("a", FilterOperator.RANGE_HALF_CLOSED, new DoubleRange(5d, 6d)); FilterSpecParam c4 = MakeParam("a", FilterOperator.RANGE_CLOSED, new DoubleRange(7d, 6d)); FilterSpecParam c5 = MakeParam("a", FilterOperator.RANGE_CLOSED, new DoubleRange(5d, 6d)); Assert.IsFalse(c1.Equals(c2)); Assert.IsFalse(c1.Equals(c3)); Assert.IsFalse(c1.Equals(c4)); Assert.IsTrue(c1.Equals(c5)); }
/// <summary>Removes a filter parameter and it's associated expression node </summary> /// <param name="param">is the parameter to remove</param> /// <returns>expression node removed</returns> public ExprNode RemoveEntry(FilterSpecParam param) { ExprNode exprNode = _specParams.Get(param); if (exprNode == null) { throw new IllegalStateException("Not found in collection param: " + param); } _specParams.Remove(param); _exprNodes.Remove(exprNode); return(exprNode); }
private static void DecomposePopulateConsolidate( FilterParamExprMap filterParamExprMap, IList<ExprNode> validatedNodes, FilterSpecCompilerArgs args) { IList<ExprNode> constituents = DecomposeCheckAggregation(validatedNodes); // Make filter parameter for each expression node, if it can be optimized foreach (ExprNode constituent in constituents) { FilterSpecParam param = FilterSpecCompilerMakeParamUtil.MakeFilterParam( constituent, args.ArrayEventTypes, args.ExprEvaluatorContext, args.StatementName); filterParamExprMap.Put(constituent, param); // accepts null values as the expression may not be optimized } // Consolidate entries as possible, i.e. (a != 5 and a != 6) is (a not in (5,6)) // Removes duplicates for same property and same filter operator for filter service index optimizations FilterSpecCompilerConsolidateUtil.Consolidate(filterParamExprMap, args.StatementName); }
internal static FilterSpecParam[] SortRemoveDups(IList <FilterSpecParam> parameters) { if (parameters.IsEmpty()) { return(FilterSpecParam.EMPTY_PARAM_ARRAY); } if (parameters.Count == 1) { return(new FilterSpecParam[] { parameters[0] }); } var result = new ArrayDeque <FilterSpecParam>(); var map = new SortedDictionary <FilterOperator, List <FilterSpecParam> >(COMPARATOR_PARAMETERS); foreach (var parameter in parameters) { var list = map.Get(parameter.FilterOperator); if (list == null) { list = new List <FilterSpecParam>(); map.Put(parameter.FilterOperator, list); } var hasDuplicate = list.Any(existing => existing.Lookupable.Equals(parameter.Lookupable)); if (hasDuplicate) { continue; } list.Add(parameter); } foreach (var entry in map) { result.AddAll(entry.Value); } return(FilterSpecParam.ToArray(result)); }