Search in sources :

Example 1 with JoinImpl

use of org.apache.jackrabbit.oak.query.ast.JoinImpl in project jackrabbit-oak by apache.

the class QueryImpl method buildJoin.

private static SourceImpl buildJoin(SourceImpl result, SourceImpl last, List<JoinConditionImpl> conditions) {
    if (result == null) {
        return last;
    }
    List<SourceImpl> selectors = result.getInnerJoinSelectors();
    Set<SourceImpl> oldSelectors = new HashSet<SourceImpl>();
    oldSelectors.addAll(selectors);
    Set<SourceImpl> newSelectors = new HashSet<SourceImpl>();
    newSelectors.addAll(selectors);
    newSelectors.add(last);
    for (JoinConditionImpl j : conditions) {
        // but couldn't be evaluated before
        if (!j.canEvaluate(oldSelectors) && j.canEvaluate(newSelectors)) {
            JoinImpl join = new JoinImpl(result, last, JoinType.INNER, j);
            return join;
        }
    }
    // no join condition was found
    return null;
}
Also used : JoinImpl(org.apache.jackrabbit.oak.query.ast.JoinImpl) SourceImpl(org.apache.jackrabbit.oak.query.ast.SourceImpl) HashSet(java.util.HashSet) ChildNodeJoinConditionImpl(org.apache.jackrabbit.oak.query.ast.ChildNodeJoinConditionImpl) JoinConditionImpl(org.apache.jackrabbit.oak.query.ast.JoinConditionImpl) EquiJoinConditionImpl(org.apache.jackrabbit.oak.query.ast.EquiJoinConditionImpl) DescendantNodeJoinConditionImpl(org.apache.jackrabbit.oak.query.ast.DescendantNodeJoinConditionImpl) SameNodeJoinConditionImpl(org.apache.jackrabbit.oak.query.ast.SameNodeJoinConditionImpl)

Aggregations

HashSet (java.util.HashSet)1 ChildNodeJoinConditionImpl (org.apache.jackrabbit.oak.query.ast.ChildNodeJoinConditionImpl)1 DescendantNodeJoinConditionImpl (org.apache.jackrabbit.oak.query.ast.DescendantNodeJoinConditionImpl)1 EquiJoinConditionImpl (org.apache.jackrabbit.oak.query.ast.EquiJoinConditionImpl)1 JoinConditionImpl (org.apache.jackrabbit.oak.query.ast.JoinConditionImpl)1 JoinImpl (org.apache.jackrabbit.oak.query.ast.JoinImpl)1 SameNodeJoinConditionImpl (org.apache.jackrabbit.oak.query.ast.SameNodeJoinConditionImpl)1 SourceImpl (org.apache.jackrabbit.oak.query.ast.SourceImpl)1