Search in sources :

Example 1 with DoNotExpandSP

use of org.apache.rya.rdftriplestore.inference.DoNotExpandSP in project incubator-rya by apache.

the class JoinSegment method getJoinArgs.

/**
 * @param tupleExpr
 *            - the query object that will be traversed by this method
 * @param joinArgs
 *            - all nodes connected by Joins and Filters
 * @return - List containing all nodes connected by Joins, LeftJoins, and
 *         Filters. This List contains the
 * @param ValueExpr
 *            in place of the Filter
 */
private List<QueryModelNode> getJoinArgs(TupleExpr tupleExpr, List<QueryModelNode> joinArgs) {
    if (tupleExpr instanceof Join) {
        if (!(((Join) tupleExpr).getLeftArg() instanceof FixedStatementPattern) && !(((Join) tupleExpr).getRightArg() instanceof DoNotExpandSP)) {
            Join join = (Join) tupleExpr;
            getJoinArgs(join.getRightArg(), joinArgs);
            getJoinArgs(join.getLeftArg(), joinArgs);
        }
    } else if (tupleExpr instanceof Filter) {
        Filter filter = (Filter) tupleExpr;
        joinArgs.add(filter.getCondition());
        conditionMap.put(filter.getCondition(), filter);
        getJoinArgs(filter.getArg(), joinArgs);
    } else {
        joinArgs.add(tupleExpr);
    }
    return joinArgs;
}
Also used : Filter(org.openrdf.query.algebra.Filter) Join(org.openrdf.query.algebra.Join) DoNotExpandSP(org.apache.rya.rdftriplestore.inference.DoNotExpandSP) FixedStatementPattern(org.apache.rya.rdftriplestore.utils.FixedStatementPattern)

Example 2 with DoNotExpandSP

use of org.apache.rya.rdftriplestore.inference.DoNotExpandSP in project incubator-rya by apache.

the class FlattenedOptional method getJoinArgs.

/**
 * This method is used to retrieve a set view of all descendants of the
 * rightArg of the LeftJoin (the optional part)
 *
 * @param tupleExpr
 *            - tupleExpr whose args are being retrieved
 * @param joinArgs
 *            - set view of all non-join args that are descendants of
 *            tupleExpr
 * @return joinArgs
 */
private Set<TupleExpr> getJoinArgs(TupleExpr tupleExpr, Set<TupleExpr> joinArgs) {
    if (tupleExpr instanceof Join) {
        if (!(((Join) tupleExpr).getLeftArg() instanceof FixedStatementPattern) && !(((Join) tupleExpr).getRightArg() instanceof DoNotExpandSP)) {
            Join join = (Join) tupleExpr;
            getJoinArgs(join.getLeftArg(), joinArgs);
            getJoinArgs(join.getRightArg(), joinArgs);
        }
    } else if (tupleExpr instanceof LeftJoin) {
        // TODO probably not
        // necessary if not
        // including leftarg
        LeftJoin lj = (LeftJoin) tupleExpr;
        joinArgs.add(new FlattenedOptional(lj));
        getJoinArgs(lj.getLeftArg(), joinArgs);
    } else if (tupleExpr instanceof Filter) {
        getJoinArgs(((Filter) tupleExpr).getArg(), joinArgs);
    } else {
        joinArgs.add(tupleExpr);
    }
    return joinArgs;
}
Also used : LeftJoin(org.openrdf.query.algebra.LeftJoin) Filter(org.openrdf.query.algebra.Filter) LeftJoin(org.openrdf.query.algebra.LeftJoin) Join(org.openrdf.query.algebra.Join) DoNotExpandSP(org.apache.rya.rdftriplestore.inference.DoNotExpandSP) FixedStatementPattern(org.apache.rya.rdftriplestore.utils.FixedStatementPattern)

Example 3 with DoNotExpandSP

use of org.apache.rya.rdftriplestore.inference.DoNotExpandSP in project incubator-rya by apache.

the class OptionalJoinSegment method getJoinArgs.

/**
 * @param tupleExpr
 *            - the query object that will be traversed by this method
 * @param joinArgs
 *            - all nodes connected by Joins, LeftJoins, and Filters
 * @return - List containing all nodes connected by Joins, LeftJoins, and
 *         Filters. This List contains the {@link ValueExpr} in place of the
 *         Filter and a {@link FlattenedOptional} in place of the LeftJoin
 *         for ease of comparison with PCJ nodes.
 */
private List<QueryModelNode> getJoinArgs(TupleExpr tupleExpr, List<QueryModelNode> joinArgs) {
    if (tupleExpr instanceof Join) {
        if (!(((Join) tupleExpr).getLeftArg() instanceof FixedStatementPattern) && !(((Join) tupleExpr).getRightArg() instanceof DoNotExpandSP)) {
            Join join = (Join) tupleExpr;
            getJoinArgs(join.getRightArg(), joinArgs);
            getJoinArgs(join.getLeftArg(), joinArgs);
        }
    } else if (tupleExpr instanceof LeftJoin) {
        LeftJoin lj = (LeftJoin) tupleExpr;
        joinArgs.add(new FlattenedOptional(lj));
        getJoinArgs(lj.getLeftArg(), joinArgs);
    } else if (tupleExpr instanceof Filter) {
        Filter filter = (Filter) tupleExpr;
        joinArgs.add(filter.getCondition());
        conditionMap.put(filter.getCondition(), filter);
        getJoinArgs(filter.getArg(), joinArgs);
    } else {
        joinArgs.add(tupleExpr);
    }
    return joinArgs;
}
Also used : LeftJoin(org.openrdf.query.algebra.LeftJoin) Filter(org.openrdf.query.algebra.Filter) LeftJoin(org.openrdf.query.algebra.LeftJoin) Join(org.openrdf.query.algebra.Join) DoNotExpandSP(org.apache.rya.rdftriplestore.inference.DoNotExpandSP) FixedStatementPattern(org.apache.rya.rdftriplestore.utils.FixedStatementPattern)

Aggregations

DoNotExpandSP (org.apache.rya.rdftriplestore.inference.DoNotExpandSP)3 FixedStatementPattern (org.apache.rya.rdftriplestore.utils.FixedStatementPattern)3 Filter (org.openrdf.query.algebra.Filter)3 Join (org.openrdf.query.algebra.Join)3 LeftJoin (org.openrdf.query.algebra.LeftJoin)2