Package org.modeshape.jcr.query.model

Examples of org.modeshape.jcr.query.model.DescendantNodeJoinCondition


        // FROM ...
        Join join = isJoin(query.source());
        assertThat(join.getLeft(), is((Source)namedSelector(selectorName("lom:Metadata"), selectorName("lom"))));
        assertThat(join.getRight(), is((Source)namedSelector(selectorName("lom:LangString"), selectorName("lang"))));
        assertThat(join.type(), is(JoinType.INNER));
        DescendantNodeJoinCondition joinCondition = isDescendantNodeJoinCondition(join.getJoinCondition());
        assertThat(joinCondition.ancestorSelectorName(), is(selectorName("lom")));
        assertThat(joinCondition.descendantSelectorName(), is(selectorName("lang")));
    }
View Full Code Here


         * @param descendantTable the name or alias of the table containing the descendant node
         * @return the query builder instance, for method chaining purposes
         */
        public QueryBuilder onDescendant( String ancestorTable,
                                          String descendantTable ) {
            return createJoin(new DescendantNodeJoinCondition(nameOf(ancestorTable), nameOf(descendantTable)));
        }
View Full Code Here

        return new EquiJoinCondition(selector1, property1, selector2, property2);
    }

    protected DescendantNodeJoinCondition descendantNodeJoinCondition( SelectorName ancestor,
                                                                       SelectorName descendant ) {
        return new DescendantNodeJoinCondition(ancestor, descendant);
    }
View Full Code Here

                             LinkedList<OptimizerRule> ruleStack ) {
        for (PlanNode join : plan.findAllAtOrBelow(Type.JOIN)) {
            boolean swapChildren = false;
            JoinCondition joinCondition = join.getProperty(Property.JOIN_CONDITION, JoinCondition.class);
            if (joinCondition instanceof DescendantNodeJoinCondition) {
                DescendantNodeJoinCondition condition = (DescendantNodeJoinCondition)joinCondition;
                SelectorName ancestorSelector = condition.ancestorSelectorName();
                // The ancestor needs to be on the left side of the join ...
                swapChildren = !join.getFirstChild().getSelectors().contains(ancestorSelector);
            } else if (joinCondition instanceof ChildNodeJoinCondition) {
                ChildNodeJoinCondition condition = (ChildNodeJoinCondition)joinCondition;
                SelectorName parentSelector = condition.parentSelectorName();
                // The ancestor needs to be on the left side of the join ...
                swapChildren = !join.getFirstChild().getSelectors().contains(parentSelector);
            }

            JoinType joinType = join.getProperty(Property.JOIN_TYPE, JoinType.class);
View Full Code Here

                                rightExtractor = createExtractFromRow(sel2, prop2, joinQueryContext, rightColumns, sources, null,
                                                                      true);
                            }

                        } else if (joinCondition instanceof DescendantNodeJoinCondition) {
                            DescendantNodeJoinCondition condition = (DescendantNodeJoinCondition)joinCondition;
                            // For this to work, we want the ancestors to be on the left, so that the descendants can quickly
                            // be found given a path of each ancestor ...
                            assert leftColumns.getSelectorNames().contains(condition.getAncestorSelectorName());
                            String ancestorSelector = condition.getAncestorSelectorName();
                            String descendantSelector = condition.getDescendantSelectorName();
                            int ancestorSelectorIndex = leftColumns.getSelectorIndex(ancestorSelector);
                            int descendantSelectorIndex = rightColumns.getSelectorIndex(descendantSelector);
                            leftExtractor = RowExtractors.extractPath(ancestorSelectorIndex, cache, types);
                            rightExtractor = RowExtractors.extractPath(descendantSelectorIndex, cache, types);
                            // This is the only time we need a RangeProducer ...
View Full Code Here

            if (parentSelector == null) parentSelector = condition.parentSelectorName();
            if (childSelector == condition.childSelectorName() && parentSelector == condition.parentSelectorName()) return condition;
            return new ChildNodeJoinCondition(parentSelector, childSelector);
        }
        if (joinCondition instanceof DescendantNodeJoinCondition) {
            DescendantNodeJoinCondition condition = (DescendantNodeJoinCondition)joinCondition;
            SelectorName ancestor = rewrittenSelectors.get(condition.ancestorSelectorName());
            SelectorName descendant = rewrittenSelectors.get(condition.descendantSelectorName());
            if (ancestor == null) ancestor = condition.ancestorSelectorName();
            if (descendant == null) descendant = condition.descendantSelectorName();
            if (ancestor == condition.ancestorSelectorName() && descendant == condition.descendantSelectorName()) return condition;
            return new ChildNodeJoinCondition(ancestor, descendant);
        }
        return joinCondition;
    }
View Full Code Here

            if (childSelector == condition.childSelectorName() && parentSelector == condition.parentSelectorName()) return condition;
            node.addSelector(childSelector, parentSelector);
            return new ChildNodeJoinCondition(parentSelector, childSelector);
        }
        if (joinCondition instanceof DescendantNodeJoinCondition) {
            DescendantNodeJoinCondition condition = (DescendantNodeJoinCondition)joinCondition;
            SelectorName ancestor = condition.ancestorSelectorName();
            SelectorName descendant = condition.descendantSelectorName();
            if (ancestor.equals(viewName)) ancestor = sourceName;
            if (descendant.equals(viewName)) descendant = sourceName;
            if (ancestor == condition.ancestorSelectorName() && descendant == condition.descendantSelectorName()) return condition;
            node.addSelector(ancestor, descendant);
            return new DescendantNodeJoinCondition(ancestor, descendant);
        }
        return joinCondition;
    }
View Full Code Here

    public void shouldHaveBestRuleAlwaysSetJoinAlgorithmToNestedLoopIfConditionIsDescendantNode() {
        PlanNode join = new PlanNode(Type.JOIN, selector("Ancestor"), selector("Descendant"));
        PlanNode ancestorSource = new PlanNode(Type.SOURCE, join, selector("Ancestor"));
        PlanNode descendantSource = new PlanNode(Type.SOURCE, join, selector("Descendant"));
        // Set the join type and condition ...
        JoinCondition joinCondition = new DescendantNodeJoinCondition(selector("Ancestor"), selector("Descendant"));
        join.setProperty(Property.JOIN_CONDITION, joinCondition);
        join.setProperty(Property.JOIN_TYPE, JoinType.INNER);

        // Execute the rule ...
        PlanNode result = bestRule.execute(context, join, new LinkedList<OptimizerRule>());
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.query.model.DescendantNodeJoinCondition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.