logger.trace("Incoming query model:\n{}", query);
// Clone the tuple expression to allow for more aggressive optimizations
query = query.clone();
Lock readLock = nativeStore.getReadLock();
try {
replaceValues(query);
NativeTripleSource tripleSource = new NativeTripleSource(nativeStore, includeInferred,
!isAutoCommit());
EvaluationStrategyImpl strategy = new EvaluationStrategyImpl(tripleSource, query);
QueryOptimizerList optimizerList = new QueryOptimizerList();
optimizerList.add(new BindingAssigner());
optimizerList.add(new ConstantOptimizer(strategy));
optimizerList.add(new CompareOptimizer());
optimizerList.add(new ConjunctiveConstraintSplitter());
optimizerList.add(new DisjunctiveConstraintOptimizer());
optimizerList.add(new SameTermFilterOptimizer());
optimizerList.add(new QueryModelPruner());
optimizerList.add(new QueryJoinOptimizer(new NativeEvaluationStatistics(nativeStore)));
optimizerList.add(new FilterOptimizer());
optimizerList.optimize(query, bindings);
logger.trace("Optimized query model:\n{}", query);
Cursor<BindingSet> iter;
iter = strategy.evaluate(query, EmptyBindingSet.getInstance());
iter = new LockingCursor<BindingSet>(readLock, iter);
return iter;
}
catch (EvaluationException e) {
readLock.release();
throw e;
}
catch (RuntimeException e) {
readLock.release();
throw e;
}
}