private static void CompareTableLookupPlan(
            int streamNum,
            int numInstruction,
            TableLookupPlanForge expectedPlan,
            TableLookupPlanForge actualPlan,
            IDictionary<TableLookupIndexReqKey, TableLookupIndexReqKey> indexNameMapping)
        {
            var message = "Failed at stream " + streamNum + " and instruction " + numInstruction;
            Assert.AreEqual(expectedPlan.IndexedStream, actualPlan.IndexedStream, message);
            Assert.AreEqual(expectedPlan.LookupStream, actualPlan.LookupStream, message);
            Assert.AreEqual(expectedPlan.GetType().FullName, actualPlan.GetType().FullName, message);

            // assert index mapping
            Assert.AreEqual(expectedPlan.IndexNum.Length, actualPlan.IndexNum.Length, message);
            for (var i = 0; i < expectedPlan.IndexNum.Length; i++) {
                var expectedIndexKey = expectedPlan.IndexNum[i];
                var actualIndexKey = actualPlan.IndexNum[i];
                Assert.AreEqual(expectedIndexKey, indexNameMapping.Get(actualIndexKey), message);
            }

            if (expectedPlan is FullTableScanLookupPlanForge && actualPlan is FullTableScanLookupPlanForge) {
            }
            else if (expectedPlan is IndexedTableLookupPlanHashedOnlyForge &&
                     actualPlan is IndexedTableLookupPlanHashedOnlyForge) {
                var singleActual = (IndexedTableLookupPlanHashedOnlyForge) actualPlan;
                var singleExpected = (IndexedTableLookupPlanHashedOnlyForge) expectedPlan;
                CompareIndexDesc(singleExpected.KeyDescriptor, singleActual.KeyDescriptor);
            }
            else if (expectedPlan is InKeywordTableLookupPlanMultiIdxForge &&
                     actualPlan is InKeywordTableLookupPlanMultiIdxForge) {
                var inExpected = (InKeywordTableLookupPlanMultiIdxForge) expectedPlan;
                var inActual = (InKeywordTableLookupPlanMultiIdxForge) actualPlan;
                Assert.IsTrue(ExprNodeUtilityCompare.DeepEquals(inExpected.KeyExpr, inActual.KeyExpr, false));
            }
            else if (expectedPlan is InKeywordTableLookupPlanSingleIdxForge &&
                     actualPlan is InKeywordTableLookupPlanSingleIdxForge) {
                var inExpected = (InKeywordTableLookupPlanSingleIdxForge) expectedPlan;
                var inActual = (InKeywordTableLookupPlanSingleIdxForge) actualPlan;
                Assert.IsTrue(ExprNodeUtilityCompare.DeepEquals(inExpected.Expressions, inActual.Expressions, false));
            }
            else if (expectedPlan is SortedTableLookupPlanForge && actualPlan is SortedTableLookupPlanForge) {
                var inExpected = (SortedTableLookupPlanForge) expectedPlan;
                var inActual = (SortedTableLookupPlanForge) actualPlan;
                Assert.AreEqual(inExpected.LookupStream, inActual.LookupStream);
                Assert.IsTrue(
                    ExprNodeUtilityCompare.DeepEquals(
                        inExpected.RangeKeyPair.Expressions,
                        inActual.RangeKeyPair.Expressions,
                        false));
            }
            else {
                Assert.Fail("Failed to compare plan for stream " + streamNum + ", found type " + actualPlan.GetType());
            }
        }
Exemple #2
0
        public override bool EqualsNode(
            ExprNode node,
            bool ignoreStreamPrefix)
        {
            if (!(node is ExprDeclaredNodeImpl)) {
                return false;
            }

            var otherExprCaseNode = (ExprDeclaredNodeImpl) node;
            return ExprNodeUtilityCompare.DeepEquals(ExpressionBodyCopy, otherExprCaseNode, false);
        }
Exemple #3
0
        protected override bool EqualsNodeInternal(ExprTableAccessNode other)
        {
            var that = (ExprTableAccessNodeSubpropAccessor) other;
            if (!SubpropName.Equals(that.SubpropName)) {
                return false;
            }

            return ExprNodeUtilityCompare.DeepEquals(
                aggregateAccessMultiValueNode,
                that.aggregateAccessMultiValueNode,
                false);
        }
Exemple #4
0
        private static void AddEquivalent(
            ExprAggregateNode aggNodeToAdd,
            IList<AggregationServiceAggExpressionDesc> equivalencyList)
        {
            // Check any same aggregation nodes among all aggregation clauses
            var foundEquivalent = false;
            foreach (var existing in equivalencyList) {
                var aggNode = existing.AggregationNode;

                // we have equivalence when:
                // (a) equals on node returns true
                // (b) positional parameters are the same
                // (c) non-positional (group-by over, if present, are the same ignoring duplicates)
                if (!aggNode.EqualsNode(aggNodeToAdd, false)) {
                    continue;
                }

                if (!ExprNodeUtilityCompare.DeepEquals(
                    aggNode.PositionalParams,
                    aggNodeToAdd.PositionalParams,
                    false)) {
                    continue;
                }

                if (!ExprNodeUtilityCompare.DeepEqualsNullChecked(
                    aggNode.OptionalFilter,
                    aggNodeToAdd.OptionalFilter,
                    false)) {
                    continue;
                }

                if (aggNode.OptionalLocalGroupBy != null || aggNodeToAdd.OptionalLocalGroupBy != null) {
                    if (aggNode.OptionalLocalGroupBy == null && aggNodeToAdd.OptionalLocalGroupBy != null ||
                        aggNode.OptionalLocalGroupBy != null && aggNodeToAdd.OptionalLocalGroupBy == null) {
                        continue;
                    }

                    if (!ExprNodeUtilityCompare.DeepEqualsIgnoreDupAndOrder(
                        aggNode.OptionalLocalGroupBy.PartitionExpressions,
                        aggNodeToAdd.OptionalLocalGroupBy.PartitionExpressions)) {
                        continue;
                    }
                }

                existing.AddEquivalent(aggNodeToAdd);
                foundEquivalent = true;
                break;
            }

            if (!foundEquivalent) {
                equivalencyList.Add(new AggregationServiceAggExpressionDesc(aggNodeToAdd, aggNodeToAdd.Factory));
            }
        }
Exemple #5
0
        public override bool Equals(object obj)
        {
            if (this == obj) {
                return true;
            }

            if (!(obj is FilterForEvalConstRuntimeExprForge)) {
                return false;
            }

            var other = (FilterForEvalConstRuntimeExprForge) obj;
            return ExprNodeUtilityCompare.DeepEquals(other._runtimeConstant, _runtimeConstant, true);
        }
Exemple #6
0
        public override bool Equals(object o)
        {
            if (this == o) {
                return true;
            }

            if (o == null || GetType() != o.GetType()) {
                return false;
            }

            var that = (ChainableArray) o;
            return EqualsChainable(that) && ExprNodeUtilityCompare.DeepEquals(Indexes, that.Indexes);
        }
Exemple #7
0
        public override bool Equals(object o)
        {
            if (this == o) {
                return true;
            }

            if (o == null || GetType() != o.GetType()) {
                return false;
            }

            var that = (ChainableCall) o;
            return EqualsChainable(that) 
                   && Name.Equals(that.Name)
                   && ExprNodeUtilityCompare.DeepEquals(Parameters, that.Parameters);
        }
Exemple #8
0
        private static void VerifyGroups(IList<ViewFactoryForge> forges)
        {
            GroupByViewFactoryForge group = null;
            MergeViewFactoryForge merge = null;
            var numDataWindows = 0;
            foreach (var forge in forges) {
                if (forge is GroupByViewFactoryForge) {
                    if (group == null) {
                        group = (GroupByViewFactoryForge) forge;
                    }
                    else {
                        throw new ViewProcessingException("Multiple groupwin-declarations are not supported");
                    }
                }

                if (forge is MergeViewFactoryForge) {
                    if (merge == null) {
                        merge = (MergeViewFactoryForge) forge;
                    }
                    else {
                        throw new ViewProcessingException("Multiple merge-declarations are not supported");
                    }
                }

                numDataWindows += forge is DataWindowViewForge ? 1 : 0;
            }

            if (group != null && group != forges[0]) {
                throw new ViewProcessingException("The 'groupwin' declaration must occur in the first position");
            }

            if (merge != null) {
                if (numDataWindows > 1) {
                    throw new ViewProcessingException(
                        "The 'merge' declaration cannot be used in conjunction with multiple data windows");
                }

                if (group == null) {
                    throw new ViewProcessingException(
                        "The 'merge' declaration cannot be used in without a 'group' declaration");
                }

                if (!ExprNodeUtilityCompare.DeepEquals(group.ViewParameters, merge.ViewParameters)) {
                    throw new ViewProcessingException("Mismatching parameters between 'group' and 'merge'");
                }
            }
        }
Exemple #9
0
        public override bool Equals(object o)
        {
            if (this == o) {
                return true;
            }

            if (o == null || GetType() != o.GetType()) {
                return false;
            }

            var that = (ScriptCodegenFieldSharable) o;
            if (!(ExprNodeUtilityCompare.DeepEquals(_parameters, that._parameters, false))) {
                return false;
            }
            
            return _scriptName.Equals(that._scriptName);
        }
        private static bool IsExprExistsInAllEqualsChildNodes(
            ExprNode[] childNodes,
            ExprNode search)
        {
            foreach (var child in childNodes) {
                var lhs = child.ChildNodes[0];
                var rhs = child.ChildNodes[1];
                if (!ExprNodeUtilityCompare.DeepEquals(lhs, search, false) && !ExprNodeUtilityCompare.DeepEquals(rhs, search, false)) {
                    return false;
                }

                if (ExprNodeUtilityCompare.DeepEquals(lhs, rhs, false)) {
                    return false;
                }
            }

            return true;
        }
        public override bool Equals(object o)
        {
            if (this == o) {
                return true;
            }

            if (o == null || GetType() != o.GetType()) {
                return false;
            }

            var that = (QueryGraphValueEntryCustomKeyForge) o;

            if (!OperationName.Equals(that.OperationName)) {
                return false;
            }

            return ExprNodeUtilityCompare.DeepEquals(ExprNodes, that.ExprNodes, true);
        }
Exemple #12
0
        public override bool EqualsNode(
            ExprNode node,
            bool ignoreStreamPrefix)
        {
            if (this == node) {
                return true;
            }

            if (node == null || GetType() != node.GetType()) {
                return false;
            }

            var that = (ExprNodeScript) node;

            if (!Script?.Equals(that.Script) ?? that.Script != null) {
                return false;
            }

            return ExprNodeUtilityCompare.DeepEquals(Parameters, that.Parameters);
        }
        private static void ValidateOrderByAggregates(
            IList<ExprAggregateNode> selectAggNodes,
            IList<ExprAggregateNode> orderAggNodes)
        {
            // Check that the order-by clause doesn't contain
            // any aggregate functions not in the select expression
            foreach (var orderAgg in orderAggNodes) {
                var inSelect = false;
                foreach (var selectAgg in selectAggNodes) {
                    if (ExprNodeUtilityCompare.DeepEquals(selectAgg, orderAgg, false)) {
                        inSelect = true;
                        break;
                    }
                }

                if (!inSelect) {
                    throw new ExprValidationException(
                        "Aggregate functions in the order-by clause must also occur in the select expression");
                }
            }
        }
Exemple #14
0
        public override bool Equals(object otherObject)
        {
            if (otherObject == this) {
                return true;
            }

            if (otherObject == null) {
                return false;
            }

            if (GetType() != otherObject.GetType()) {
                return false;
            }

            var other = (ObjectSpec) otherObject;
            if (!ObjectName.Equals(other.ObjectName)) {
                return false;
            }

            if (ObjectParameters.Count != other.ObjectParameters.Count) {
                return false;
            }

            // Compare object parameter by object parameter
            var index = 0;
            foreach (var thisParam in ObjectParameters) {
                var otherParam = other.ObjectParameters[index];
                index++;

                if (!ExprNodeUtilityCompare.DeepEquals(thisParam, otherParam, false)) {
                    return false;
                }
            }

            return true;
        }
        public static GroupByClauseExpressions GetGroupByRollupExpressions(
            IList<GroupByClauseElement> groupByElements,
            SelectClauseSpecRaw selectClauseSpec,
            ExprNode optionalHavingNode,
            IList<OrderByItem> orderByList,
            ExpressionCopier expressionCopier)
        {
            if (groupByElements == null || groupByElements.Count == 0) {
                return null;
            }

            // walk group-by-elements, determine group-by expressions and rollup nodes
            var groupByExpressionInfo = GroupByToRollupNodes(groupByElements);

            // obtain expression nodes, collect unique nodes and assign index
            IList<ExprNode> distinctGroupByExpressions = new List<ExprNode>();
            IDictionary<ExprNode, int> expressionToIndex = new Dictionary<ExprNode, int>();
            foreach (var exprNode in groupByExpressionInfo.Expressions) {
                var found = false;
                for (var i = 0; i < distinctGroupByExpressions.Count; i++) {
                    ExprNode other = distinctGroupByExpressions[i];
                    // find same expression
                    if (ExprNodeUtilityCompare.DeepEquals(exprNode, other, false)) {
                        expressionToIndex.Put(exprNode, i);
                        found = true;
                        break;
                    }
                }

                // not seen before
                if (!found) {
                    expressionToIndex.Put(exprNode, distinctGroupByExpressions.Count);
                    distinctGroupByExpressions.Add(exprNode);
                }
            }

            // determine rollup, validate it is either (not both)
            var hasGroupingSet = false;
            var hasRollup = false;
            foreach (var element in groupByElements) {
                if (element is GroupByClauseElementGroupingSet) {
                    hasGroupingSet = true;
                }

                if (element is GroupByClauseElementRollupOrCube) {
                    hasRollup = true;
                }
            }

            // no-rollup or grouping-sets means simply validate
            ExprNode[] groupByExpressions = distinctGroupByExpressions.ToArray();
            if (!hasRollup && !hasGroupingSet) {
                return new GroupByClauseExpressions(groupByExpressions);
            }

            // evaluate rollup node roots
            var nodes = groupByExpressionInfo.Nodes;
            var perNodeCombinations = new object[nodes.Count][];
            var context = new GroupByRollupEvalContext(expressionToIndex);
            try {
                for (var i = 0; i < nodes.Count; i++) {
                    GroupByRollupNodeBase node = nodes[i];
                    var combinations = node.Evaluate(context);
                    perNodeCombinations[i] = new object[combinations.Count];
                    for (var j = 0; j < combinations.Count; j++) {
                        perNodeCombinations[i][j] = combinations[j];
                    }
                }
            }
            catch (GroupByRollupDuplicateException ex) {
                if (ex.Indexes.Length == 0) {
                    throw new ExprValidationException(
                        "Failed to validate the group-by clause, found duplicate specification of the overall grouping '()'");
                }

                var writer = new StringWriter();
                var delimiter = "";
                for (var i = 0; i < ex.Indexes.Length; i++) {
                    writer.Write(delimiter);
                    writer.Write(
                        ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(groupByExpressions[ex.Indexes[i]]));
                    delimiter = ", ";
                }

                throw new ExprValidationException(
                    "Failed to validate the group-by clause, found duplicate specification of expressions (" +
                    writer +
                    ")");
            }

            // enumerate combinations building an index list
            var combinationEnumeration = new CombinationEnumeration(perNodeCombinations);
            var combination = new SortedSet<int>();
            var indexList = new LinkedHashSet<MultiKeyArrayInt>();
            while (combinationEnumeration.MoveNext()) {
                combination.Clear();
                object[] combinationOA = combinationEnumeration.Current;
                foreach (var indexes in combinationOA) {
                    var indexarr = (int[]) indexes;
                    foreach (var anIndex in indexarr) {
                        combination.Add(anIndex);
                    }
                }

                var indexArr = CollectionUtil.IntArray(combination);
                indexList.Add(new MultiKeyArrayInt(indexArr));
            }

            // obtain rollup levels
            var rollupLevels = new int[indexList.Count][];
            var count = 0;
            foreach (var mk in indexList) {
                rollupLevels[count++] = mk.Keys;
            }

            var numberOfLevels = rollupLevels.Length;
            if (numberOfLevels == 1 && rollupLevels[0].Length == 0) {
                throw new ExprValidationException(
                    "Failed to validate the group-by clause, the overall grouping '()' cannot be the only grouping");
            }

            // obtain select-expression copies for rewrite
            var expressions = selectClauseSpec.SelectExprList;
            var selects = new ExprNode[numberOfLevels][];
            for (var i = 0; i < numberOfLevels; i++) {
                selects[i] = new ExprNode[expressions.Count];
                for (var j = 0; j < expressions.Count; j++) {
                    SelectClauseElementRaw selectRaw = expressions[j];
                    if (!(selectRaw is SelectClauseExprRawSpec)) {
                        throw new ExprValidationException(
                            "Group-by with rollup requires that the select-clause does not use wildcard");
                    }

                    var compiled = (SelectClauseExprRawSpec) selectRaw;
                    selects[i][j] = CopyVisitExpression(compiled.SelectExpression, expressionCopier);
                }
            }

            // obtain having-expression copies for rewrite
            ExprNode[] optHavingNodeCopy = null;
            if (optionalHavingNode != null) {
                optHavingNodeCopy = new ExprNode[numberOfLevels];
                for (var i = 0; i < numberOfLevels; i++) {
                    optHavingNodeCopy[i] = CopyVisitExpression(optionalHavingNode, expressionCopier);
                }
            }

            // obtain orderby-expression copies for rewrite
            ExprNode[][] optOrderByCopy = null;
            if (orderByList != null && orderByList.Count > 0) {
                optOrderByCopy = new ExprNode[numberOfLevels][];
                for (var i = 0; i < numberOfLevels; i++) {
                    optOrderByCopy[i] = new ExprNode[orderByList.Count];
                    for (var j = 0; j < orderByList.Count; j++) {
                        OrderByItem element = orderByList[j];
                        optOrderByCopy[i][j] = CopyVisitExpression(element.ExprNode, expressionCopier);
                    }
                }
            }

            return new GroupByClauseExpressions(
                groupByExpressions,
                rollupLevels,
                selects,
                optHavingNodeCopy,
                optOrderByCopy);
        }
Exemple #16
0
        public static ExprNode RewriteOrToInIfApplicable(ExprNode constituent)
        {
            if (!(constituent is ExprOrNode) || constituent.ChildNodes.Length < 2) {
                return constituent;
            }

            // check eligibility
            var childNodes = constituent.ChildNodes;
            foreach (var child in childNodes) {
                if (!(child is ExprEqualsNode)) {
                    return constituent;
                }

                var equalsNode = (ExprEqualsNode) child;
                if (equalsNode.IsIs || equalsNode.IsNotEquals) {
                    return constituent;
                }
            }

            // find common-expression node
            ExprNode commonExpressionNode;
            var lhs = childNodes[0].ChildNodes[0];
            var rhs = childNodes[0].ChildNodes[1];
            if (ExprNodeUtilityCompare.DeepEquals(lhs, rhs, false)) {
                return constituent;
            }

            if (IsExprExistsInAllEqualsChildNodes(childNodes, lhs)) {
                commonExpressionNode = lhs;
            }
            else if (IsExprExistsInAllEqualsChildNodes(childNodes, rhs)) {
                commonExpressionNode = rhs;
            }
            else {
                return constituent;
            }

            // build node
            var @in = new ExprInNodeImpl(false);
            @in.AddChildNode(commonExpressionNode);
            for (var i = 0; i < constituent.ChildNodes.Length; i++) {
                var child = constituent.ChildNodes[i];
                var nodeindex = ExprNodeUtilityCompare.DeepEquals(
                    commonExpressionNode,
                    childNodes[i].ChildNodes[0],
                    false)
                    ? 1
                    : 0;
                @in.AddChildNode(child.ChildNodes[nodeindex]);
            }

            // validate
            try {
                @in.ValidateWithoutContext();
            }
            catch (ExprValidationException) {
                return constituent;
            }

            return @in;
        }
        public static ExprNode RewriteOrToInIfApplicable(
            ExprNode constituent,
            bool rewriteRegardlessOfLookupable)
        {
            if (!(constituent is ExprOrNode) || constituent.ChildNodes.Length < 2) {
                return constituent;
            }

            // check eligibility
            var childNodes = constituent.ChildNodes;
            foreach (var child in childNodes) {
                if (!(child is ExprEqualsNode)) {
                    return constituent;
                }

                var equalsNode = (ExprEqualsNode) child;
                if (equalsNode.IsIs || equalsNode.IsNotEquals) {
                    return constituent;
                }
            }

            // find common-expression node
            ExprNode commonExpressionNode;
            var lhs = childNodes[0].ChildNodes[0];
            var rhs = childNodes[0].ChildNodes[1];
            if (ExprNodeUtilityCompare.DeepEquals(lhs, rhs, false)) {
                return constituent;
            }

            if (IsExprExistsInAllEqualsChildNodes(childNodes, lhs)) {
                commonExpressionNode = lhs;
            }
            else if (IsExprExistsInAllEqualsChildNodes(childNodes, rhs)) {
                commonExpressionNode = rhs;
            }
            else {
                return constituent;
            }

            // if the common expression doesn't reference an event property, no need to rewrite
            if (!rewriteRegardlessOfLookupable) {
                var lookupableVisitor = new FilterSpecExprNodeVisitorLookupableLimitedExpr();
                commonExpressionNode.Accept(lookupableVisitor);
                if (!lookupableVisitor.HasStreamZeroReference || !lookupableVisitor.IsLimited) {
                    return constituent;
                }
            }

            // build node
            var @in = new ExprInNodeImpl(false);
            @in.AddChildNode(commonExpressionNode);
            for (var i = 0; i < constituent.ChildNodes.Length; i++) {
                var child = constituent.ChildNodes[i];
                var nodeindex = ExprNodeUtilityCompare.DeepEquals(commonExpressionNode, childNodes[i].ChildNodes[0], false) ? 1 : 0;
                @in.AddChildNode(child.ChildNodes[nodeindex]);
            }

            // validate
            try {
                @in.ValidateWithoutContext();
            }
            catch (ExprValidationException) {
                return constituent;
            }

            return @in;
        }
        internal static FilterSpecPlanForge PlanRemainingNodesWithConditions(
            FilterSpecParaForgeMap overallExpressions,
            FilterSpecCompilerArgs args,
            int filterServiceMaxFilterWidth,
            ExprNode topLevelNegator)
        {
            var unassigned = overallExpressions.UnassignedExpressions;
            var orNodes    = new List <ExprOrNode>(unassigned.Count);

            foreach (var node in unassigned)
            {
                if (node is ExprOrNode)
                {
                    orNodes.Add((ExprOrNode)node);
                }
            }

            var expressionsWithoutOr = new FilterSpecParaForgeMap();

            expressionsWithoutOr.Add(overallExpressions);

            // first dimension: or-node index
            // second dimension: or child node index
            var countOr        = 0;
            var sizeFactorized = 1;
            var sizePerOr      = new int[orNodes.Count];
            var orChildNodes   = new OrChildNode[orNodes.Count][];
            var hasControl     = false;

            foreach (var orNode in orNodes)
            {
                expressionsWithoutOr.RemoveNode(orNode);

                // get value-nodes and non-value nodes
                var nonValueNodes = GetNonValueChildNodes(orNode);
                var valueNodes    = new List <ExprNode>(Arrays.AsList(orNode.ChildNodes));
                valueNodes.RemoveAll(nonValueNodes);
                ExprNode singleValueNode = ExprNodeUtilityMake.ConnectExpressionsByLogicalOrWhenNeeded(valueNodes);

                // get all child nodes; last one is confirm if present
                IList <ExprNode> allChildNodes = new List <ExprNode>(nonValueNodes);
                if (singleValueNode != null)
                {
                    allChildNodes.Add(singleValueNode);
                }

                var len = allChildNodes.Count;
                orChildNodes[countOr] = new OrChildNode[len];

                for (var i = 0; i < len; i++)
                {
                    var child = allChildNodes[i];
                    if (child == singleValueNode)
                    {
                        hasControl = true;
                        orChildNodes[countOr][i] = new OrChildNodeV(singleValueNode);
                    }
                    else
                    {
                        var map     = new FilterSpecParaForgeMap();
                        var nodes   = Collections.SingletonList(child);
                        var confirm = DecomposePopulateConsolidate(map, true, nodes, args);
                        if (confirm == null)
                        {
                            orChildNodes[countOr][i] = new OrChildNodeNV(child, map);
                        }
                        else
                        {
                            hasControl = true;
                            orChildNodes[countOr][i] = new OrChildNodeNVNegated(child, map, confirm);
                        }
                    }
                }

                sizePerOr[countOr] = len;
                sizeFactorized     = sizeFactorized * len;
                countOr++;
            }

            // compute permutations
            var permutations           = new CombPermutationTriplets[sizeFactorized];
            var combinationEnumeration = CombinationEnumeration.FromZeroBasedRanges(sizePerOr);
            var count = 0;

            foreach (var permutation in combinationEnumeration)
            {
                permutations[count] = ComputePermutation(expressionsWithoutOr, permutation, orChildNodes, hasControl, args);
                count++;
            }

            // Remove any permutations that only have a control-confirm
            var result             = new List <FilterSpecPlanPathForge>(sizeFactorized);
            var pathControlConfirm = new List <ExprNode>();

            foreach (var permutation in permutations)
            {
                if (permutation.Triplets.Length > 0)
                {
                    result.Add(new FilterSpecPlanPathForge(permutation.Triplets, permutation.NegateCondition));
                }
                else
                {
                    pathControlConfirm.Add(permutation.NegateCondition);
                }
            }

            if (result.Count > filterServiceMaxFilterWidth)
            {
                return(null);
            }

            var      pathArray         = result.ToArray();
            ExprNode topLevelConfirmer = ExprNodeUtilityMake.ConnectExpressionsByLogicalOrWhenNeeded(pathControlConfirm);

            // determine when the path-negate condition is the same as the root confirm-expression
            if (topLevelConfirmer != null)
            {
                var not = new ExprNotNode();
                not.AddChildNode(topLevelConfirmer);
                foreach (var path in pathArray)
                {
                    if (ExprNodeUtilityCompare.DeepEquals(not, path.PathNegate, true))
                    {
                        path.PathNegate = null;
                    }
                }
            }

            var convertor = new MatchedEventConvertorForge(
                args.taggedEventTypes,
                args.arrayEventTypes,
                args.allTagNamesOrdered,
                null,
                true);

            return(new FilterSpecPlanForge(pathArray, topLevelConfirmer, topLevelNegator, convertor));
        }