use of org.apache.jena.tdb2.TDB2 in project jena by apache.
the class ModTDBDataset method createDataset.
@Override
public Dataset createDataset() {
if (inMemFile != null) {
Dataset ds = TDB2Factory.createDataset();
RDFDataMgr.read(ds, inMemFile);
return ds;
}
if (modAssembler.getAssemblerFile() != null) {
Dataset thing = null;
// (which may go wrong later if TDB2 directly is needed).
try {
thing = (Dataset) AssemblerUtils.build(modAssembler.getAssemblerFile(), VocabTDB2.tDatasetTDB);
if (thing != null) {
DatasetGraph dsg = thing.asDatasetGraph();
if (!(dsg instanceof DatasetGraphSwitchable) && !(dsg instanceof DatasetGraphTDB))
Log.warn(this, "Unexpected: Not a TDB2 dataset for type DatasetTDB2");
}
if (thing == null)
// Should use assembler inheritance but how do we assert
// the subclass relationship in a program?
thing = (Dataset) AssemblerUtils.build(modAssembler.getAssemblerFile(), DatasetAssemblerVocab.tDataset);
} catch (JenaException ex) {
throw ex;
} catch (Exception ex) {
throw new CmdException("Error creating", ex);
}
return thing;
}
if (modAssembler.getLocation() == null)
throw new CmdException("No assembler file nor location provided");
// No assembler - use location to find a database.
Dataset ds = TDB2Factory.connectDataset(modAssembler.getLocation());
return ds;
}
use of org.apache.jena.tdb2.TDB2 in project jena by apache.
the class StageGeneratorDirectTDB method execute.
@Override
public QueryIterator execute(BasicPattern pattern, QueryIterator input, ExecutionContext execCxt) {
// --- In case this isn't for TDB2
Graph g = execCxt.getActiveGraph();
if (g instanceof GraphViewSwitchable) {
GraphViewSwitchable gvs = (GraphViewSwitchable) g;
g = gvs.getBaseGraph();
}
if (!(g instanceof GraphTDB))
// Not us - bounce up the StageGenerator chain
return above.execute(pattern, input, execCxt);
GraphTDB graph = (GraphTDB) g;
Predicate<Tuple<NodeId>> filter = QC2.getFilter(execCxt.getContext());
return PatternMatchTDB2.execute(graph, pattern, input, filter, execCxt);
}
use of org.apache.jena.tdb2.TDB2 in project jena by apache.
the class DatasetAssemblerTDB2 method make.
public static DatasetGraph make(Assembler a, Resource root) {
if (!exactlyOneProperty(root, pLocation))
throw new AssemblerException(root, "No location given");
String dir = getStringValue(root, pLocation);
Location loc = Location.create(dir);
DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(loc);
if (root.hasProperty(pUnionDefaultGraph)) {
Node b = root.getProperty(pUnionDefaultGraph).getObject().asNode();
NodeValue nv = NodeValue.makeNode(b);
if (nv.isBoolean())
dsg.getContext().set(TDB2.symUnionDefaultGraph, nv.getBoolean());
else
Log.warn(DatasetAssemblerTDB2.class, "Failed to recognize value for union graph setting (ignored): " + b);
}
/*
<r> rdf:type tdb:DatasetTDB2;
tdb:location "dir";
//ja:context [ ja:cxtName "arq:queryTimeout"; ja:cxtValue "10000" ] ;
tdb:unionGraph true; # or "true"
*/
AssemblerUtils.mergeContext(root, dsg.getContext());
return dsg;
}
use of org.apache.jena.tdb2.TDB2 in project jena by apache.
the class SystemTDB method intValue.
private static int intValue(String name, int defaultValue) {
if (name == null)
return defaultValue;
if (name.length() == 0)
throw new TDBException("Empty string for value name");
if (properties == null)
return defaultValue;
String x = properties.getProperty(name);
if (x == null)
return defaultValue;
TDB2.logInfo.info("Set: " + name + " = " + x);
int v = Integer.parseInt(x);
return v;
}
use of org.apache.jena.tdb2.TDB2 in project jena by apache.
the class DatabaseMgr method compact.
/**
* Compact a datasets which must be a switchable TDB database.
* This is the normal dataset type for on-disk TDB2 databases.
*
* Deletes old database after successful compaction if `shouldDeleteOld` is `true`.
*
* @param container
* @param shouldDeleteOld
*/
public static void compact(DatasetGraph container, boolean shouldDeleteOld) {
DatasetGraphSwitchable dsg = requireSwitchable(container);
DatabaseOps.compact(dsg, shouldDeleteOld);
}
Aggregations