use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation in project jena by apache.
the class OpExecutorTDB1 method optimizeExecuteQuads.
/**
* Execute, with optimization, a quad pattern
*/
private static QueryIterator optimizeExecuteQuads(DatasetGraphTDB dsgtdb, QueryIterator input, Node gn, BasicPattern bgp, ExprList exprs, ExecutionContext execCxt) {
if (!input.hasNext())
return input;
// ---- Graph names with special meaning.
gn = decideGraphNode(gn, execCxt);
if (gn == null)
return optimizeExecuteTriples(dsgtdb, input, bgp, exprs, execCxt);
// ---- Execute quads+filters
if (bgp.size() >= 2) {
ReorderTransformation transform = dsgtdb.getReorderTransform();
if (transform != null) {
QueryIterPeek peek = QueryIterPeek.create(input, execCxt);
// Original input now invalid.
input = peek;
bgp = reorder(bgp, peek, transform);
}
}
if (exprs == null) {
// Triple-backed (but may be named as explicit default graph).
Explain.explain("Execute", bgp, execCxt.getContext());
Predicate<Tuple<NodeId>> filter = QC2.getFilter(execCxt.getContext());
return PatternMatchTDB1.execute(dsgtdb, gn, bgp, input, filter, execCxt);
}
// -- Filter placement
Op op = TransformFilterPlacement.transform(exprs, gn, bgp);
return plainExecute(op, input, execCxt);
}
use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation in project jena by apache.
the class DatasetBuilderStd method buildWorker.
private synchronized DatasetGraphTDB buildWorker(Location location, boolean writeable, ReorderTransformation _transform, StoreParams params) {
recorder.start();
DatasetControl policy = createConcurrencyPolicy();
NodeTable nodeTable = makeNodeTable(location, params);
TripleTable tripleTable = makeTripleTable(location, nodeTable, policy, params);
QuadTable quadTable = makeQuadTable(location, nodeTable, policy, params);
DatasetPrefixesTDB prefixes = makePrefixTable(location, policy, params);
ReorderTransformation transform = (_transform == null) ? chooseReorderTransformation(location) : _transform;
StorageConfig storageConfig = new StorageConfig(location, params, writeable, recorder.blockMgrs, recorder.objectFiles, recorder.bufferChannels);
recorder.finish();
DatasetGraphTDB dsg = new DatasetGraphTDB(tripleTable, quadTable, prefixes, transform, storageConfig);
// TDB does filter placement on BGPs itself.
dsg.getContext().set(ARQ.optFilterPlacementBGP, false);
QC.setFactory(dsg.getContext(), OpExecutorTDB1.OpExecFactoryTDB);
return dsg;
}
use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation in project jena by apache.
the class DatasetBuilderStd method chooseOptimizer.
public static ReorderTransformation chooseOptimizer(Location location) {
if (location == null)
return ReorderLib.identity();
ReorderTransformation reorder = null;
if (location.exists(Names.optStats)) {
try {
reorder = ReorderLib.weighted(location.getPath(Names.optStats));
} catch (SSE_ParseException ex) {
log.warn("Error in stats file: " + ex.getMessage());
reorder = null;
}
}
if (reorder == null && location.exists(Names.optFixed)) {
// Not as good but better than nothing.
reorder = ReorderLib.fixed();
log.debug("Fixed pattern BGP optimizer");
}
if (location.exists(Names.optNone)) {
reorder = ReorderLib.identity();
log.debug("Optimizer explicitly turned off");
}
if (reorder == null)
reorder = SystemTDB.defaultReorderTransform;
if (reorder == null && warnAboutOptimizer)
ARQ.getExecLogger().warn("No BGP optimizer");
return reorder;
}
use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation in project jena by apache.
the class TDB2StorageBuilder method chooseReorderTransformation.
public static ReorderTransformation chooseReorderTransformation(Location location) {
if (location == null)
return ReorderLib.identity();
ReorderTransformation reorder = null;
if (location.exists(Names.optStats)) {
try {
reorder = ReorderLib.weighted(location.getPath(Names.optStats));
log.debug("Statistics-based BGP optimizer");
} catch (SSE_ParseException ex) {
log.warn("Error in stats file: " + ex.getMessage());
reorder = null;
}
}
if (reorder == null && location.exists(Names.optFixed)) {
reorder = ReorderLib.fixed();
log.debug("Fixed pattern BGP optimizer");
}
if (location.exists(Names.optNone)) {
reorder = ReorderLib.identity();
log.debug("Optimizer explicitly turned off");
}
if (reorder == null)
reorder = SystemTDB.getDefaultReorderTransform();
if (reorder == null && warnAboutOptimizer)
ARQ.getExecLogger().warn("No BGP optimizer");
return reorder;
}
use of org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation in project jena by apache.
the class TDB2StorageBuilder method build.
// public static DatasetGraphTxn build(Location location, StoreParams appParams) {
// StoreParams locParams = StoreParamsCodec.read(location);
// StoreParams dftParams = StoreParams.getDftStoreParams();
// boolean newArea = isNewDatabaseArea(location);
// if ( newArea ) {
// }
// // This can write the chosen parameters if necessary (new database, appParams != null, locParams == null)
// StoreParams params = StoreParamsFactory.decideStoreParams(location, newArea, appParams, locParams, dftParams);
// return create(location, params).build$();
// }
public static DatasetGraphTDB build(Location location, StoreParams appParams) {
StoreParams locParams = StoreParamsCodec.read(location);
StoreParams dftParams = StoreParams.getDftStoreParams();
boolean newArea = isNewDatabaseArea(location);
if (newArea) {
}
// This can write the chosen parameters if necessary (new database, appParams != null, locParams == null)
StoreParams params = StoreParamsFactory.decideStoreParams(location, newArea, appParams, locParams, dftParams);
// Builder pattern for adding components.
TransactionCoordinator txnCoord = buildTransactionCoordinator(location);
TransactionalSystem txnSystem = new TransactionalBase(txnCoord);
TDB2StorageBuilder builder = new TDB2StorageBuilder(txnSystem, location, params, new ComponentIdMgr(UUID.randomUUID()));
StorageTDB storage = builder.buildStorage();
StoragePrefixes prefixes = builder.buildPrefixes();
// Finalize.
builder.components.forEach(txnCoord::add);
builder.listeners.forEach(txnCoord::addListener);
// Freezes the TransactionCoordinator components
txnCoord.start();
ReorderTransformation reorderTranform = chooseReorderTransformation(location);
DatasetGraphTDB dsg = new DatasetGraphTDB(location, params, reorderTranform, storage, prefixes, txnSystem);
// Enable query processing.
QC.setFactory(dsg.getContext(), OpExecutorTDB2.OpExecFactoryTDB);
return dsg;
}
Aggregations