Search in sources :

Example 1 with IndexedExecutionPlanGenerator

use of org.apache.rya.indexing.IndexPlanValidator.IndexedExecutionPlanGenerator in project incubator-rya by apache.

the class PCJOptimizerTest method validatePcj.

private boolean validatePcj(final TupleExpr optTupleExp, final TupleExpr unOptTup, final List<ExternalTupleSet> pcjs, final Set<QueryModelNode> expUnmatchedNodes) {
    final IndexedExecutionPlanGenerator iep = new IndexedExecutionPlanGenerator(unOptTup, pcjs);
    final List<ExternalTupleSet> indexList = iep.getNormalizedIndices();
    final Set<QueryModelNode> indexSet = new HashSet<>();
    for (final ExternalTupleSet etup : indexList) {
        indexSet.add(etup);
    }
    final Set<QueryModelNode> tupNodes = Sets.newHashSet(getNodes(optTupleExp));
    final Set<QueryModelNode> diff = Sets.difference(tupNodes, indexSet);
    return diff.equals(expUnmatchedNodes);
}
Also used : QueryModelNode(org.openrdf.query.algebra.QueryModelNode) IndexedExecutionPlanGenerator(org.apache.rya.indexing.IndexPlanValidator.IndexedExecutionPlanGenerator) SimpleExternalTupleSet(org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet) ExternalTupleSet(org.apache.rya.indexing.external.tupleSet.ExternalTupleSet) HashSet(java.util.HashSet)

Example 2 with IndexedExecutionPlanGenerator

use of org.apache.rya.indexing.IndexPlanValidator.IndexedExecutionPlanGenerator in project incubator-rya by apache.

the class AbstractPcjIndexSetProvider method getExternalSets.

/**
 * @param segment - QuerySegment used to get relevant queries form index cache for matching
 * @return List of PCJs for matching
 */
@Override
public List<ExternalTupleSet> getExternalSets(final QuerySegment<ExternalTupleSet> segment) {
    try {
        if (!init) {
            indexCache = PCJOptimizerUtilities.getValidPCJs(getIndices());
            init = true;
        }
        final TupleExpr query = segment.getQuery().getTupleExpr();
        final IndexedExecutionPlanGenerator iep = new IndexedExecutionPlanGenerator(query, indexCache);
        final List<ExternalTupleSet> pcjs = iep.getNormalizedIndices();
        final List<ExternalTupleSet> tuples = new ArrayList<>();
        for (final ExternalTupleSet tuple : pcjs) {
            final QuerySegment<ExternalTupleSet> pcj = converter.setToSegment(tuple);
            if (segment.containsQuerySegment(pcj)) {
                tuples.add(tuple);
            }
        }
        return tuples;
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) IndexedExecutionPlanGenerator(org.apache.rya.indexing.IndexPlanValidator.IndexedExecutionPlanGenerator) TupleExpr(org.openrdf.query.algebra.TupleExpr) ExternalTupleSet(org.apache.rya.indexing.external.tupleSet.ExternalTupleSet)

Aggregations

IndexedExecutionPlanGenerator (org.apache.rya.indexing.IndexPlanValidator.IndexedExecutionPlanGenerator)2 ExternalTupleSet (org.apache.rya.indexing.external.tupleSet.ExternalTupleSet)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 SimpleExternalTupleSet (org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet)1 QueryModelNode (org.openrdf.query.algebra.QueryModelNode)1 TupleExpr (org.openrdf.query.algebra.TupleExpr)1