use of org.apache.jena.dboe.base.file.Location in project jena by apache.
the class StoreConnection method internalReset.
/**
* Stop managing all locations.
* Use with extreme care.
* This is intended to support internal testing.
*/
public static synchronized void internalReset() {
// Copy to avoid potential CME.
Set<Location> x = Set.copyOf(cache.keySet());
for (Location loc : x) internalExpel(loc, true);
cache.clear();
ChannelManager.reset();
}
use of org.apache.jena.dboe.base.file.Location in project jena by apache.
the class DatabaseOps method createSwitchable.
private static DatasetGraphSwitchable createSwitchable(Location location, StoreParams params) {
if (location.isMem()) {
DatasetGraph dsg = StoreConnection.connectCreate(location).getDatasetGraph();
return new DatasetGraphSwitchable(null, location, dsg);
}
// Exists?
if (!location.exists())
throw new TDBException("No such location: " + location);
Path path = IO_DB.asPath(location);
// Scan for DBs
Path db = findLocation(path, dbPrefix);
if (db == null) {
db = path.resolve(dbPrefix + SEP + startCount);
IOX.createDirectory(db);
}
Location loc2 = IO_DB.asLocation(db);
DatasetGraphTDB dsg = StoreConnection.connectCreate(loc2, params).getDatasetGraphTDB();
DatasetGraphSwitchable appDSG = new DatasetGraphSwitchable(path, location, dsg);
return appDSG;
}
use of org.apache.jena.dboe.base.file.Location in project jena by apache.
the class ProcIngestDataX method build.
private static Pair<Long, Long> build(DatasetGraph dsg, ProgressMonitor monitor, OutputStream outputTriples, OutputStream outputQuads, List<String> datafiles) {
DatasetGraphTDB dsgtdb = TDBInternal.getDatasetGraphTDB(dsg);
outputTriples = IO.ensureBuffered(outputTriples);
outputQuads = IO.ensureBuffered(outputQuads);
IngestData sink = new IngestData(dsgtdb, monitor, outputTriples, outputQuads, false);
Timer timer = new Timer();
timer.startTimer();
// [BULK] XXX Start monitor on first item from parser.
monitor.start();
sink.startBulk();
AsyncParser.asyncParse(datafiles, sink);
// for( String filename : datafiles) {
// if ( datafiles.size() > 0 )
// cmdLog.info("Load: "+filename+" -- "+DateTimeUtils.nowAsString());
// RDFParser.source(filename).parse(sink);
// }
sink.finishBulk();
IO.close(outputTriples);
IO.close(outputQuads);
long cTriple = sink.tripleCount();
long cQuad = sink.quadCount();
// See Stats class.
if (sink.getCollector() != null) {
Location location = dsgtdb.getLocation();
if (!location.isMem())
Stats.write(location.getPath(Names.optStats), sink.getCollector().results());
}
// ---- Monitor
monitor.finish();
long time = timer.endTimer();
long total = monitor.getTicks();
float elapsedSecs = time / 1000F;
float rate = (elapsedSecs != 0) ? total / elapsedSecs : 0;
// [BULK] End stage.
String str = String.format("%s Total: %,d tuples : %,.2f seconds : %,.2f tuples/sec [%s]", BulkLoaderX.StepMarker, total, elapsedSecs, rate, DateTimeUtils.nowAsString());
BulkLoaderX.LOG_Data.info(str);
return Pair.create(cTriple, cQuad);
}
use of org.apache.jena.dboe.base.file.Location in project jena by apache.
the class TestTDBFactory method testTDBFactory3.
@Test
public void testTDBFactory3() {
TDBInternal.reset();
// Only do disk things for tests that need them (disk takes time!).
String DIRx = ConfigTest.getCleanDir();
Location DIR = Location.create(DIRx);
try {
FileOps.clearDirectory(DIRx);
Dataset ds = TDB2Factory.connectDataset(DIR);
test(ds);
} finally {
FileOps.clearDirectory(DIRx);
}
}
use of org.apache.jena.dboe.base.file.Location in project jena by apache.
the class TestDatabaseConnection method testStoreConnectionTxn1.
@Test
public void testStoreConnectionTxn1() {
TDBInternal.reset();
// Only do disk things for test that need them (disk takes time!).
String DIRx = ConfigTest.getCleanDir();
Location DIR = Location.create(DIRx);
FileOps.clearDirectory(DIRx);
try {
DatasetGraph dg1 = DatabaseConnection.connectCreate(DIR).getDatasetGraph();
DatasetGraph dg2 = DatabaseConnection.connectCreate(DIR).getDatasetGraph();
assertSame(dg1, dg2);
} finally {
FileOps.clearDirectory(DIRx);
}
}
Aggregations