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);
}
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);
}
}
Aggregations