public String filename(String ext) { return location.getPath(basename, ext) ; } }
PlainFilePersistent(Location loc, String filename) { this(loc.getPath(filename, "dat")) ; }
/** Return the name of the file relative to this location */ public String getPath(String filename) { return getPath(filename, null) ; }
/** * Gets the lock file * * @return Lock file */ private File getLockFile() { return new File(location.getPath(LOCK_FILENAME)); }
public boolean exists(String filename, String ext) { String fn = getPath(filename, ext) ; File f = new File(fn) ; return f.exists() ; }
/** Write to a file */ public static void write(Location location, StoreParams params) { write(location.getPath(TDB_CONFIG_FILE) ,params) ; }
private void checkNodesDatJrnl(String label, Transaction txn) { if ( txn != null ) { String x = txn.getBaseDataset().getLocation().getPath(label + ": nodes.dat-jrnl") ; long len = new File(x).length() ; if ( len != 0 ) log("nodes.dat-jrnl: not empty", txn) ; } }
/** * Read from a file if possible. * Return null for memory locations, file not found or syntax errors. */ public static StoreParams read(Location location) { if ( location.isMem() ) return null ; return read(location.getPath(TDB_CONFIG_FILE)) ; }
private int countRDFNodes() { ObjectFile objects = FileFactory.createObjectFileDisk( location.getPath(Names.indexId2Node, Names.extNodeData) ) ; int count = 0 ; Iterator<Pair<Long,ByteBuffer>> iter = objects.all() ; while ( iter.hasNext() ) { iter.next() ; count++ ; } objects.close() ; return count ; } }
static StoreParams read(Location location) { String fn = location.getPath(TDB_CONFIG_FILE) ; JsonObject obj = JSON.read(fn) ; return StoreParamsCodec.decode(obj) ; } }
private int countRDFNodes() { ObjectFile objects = FileFactory.createObjectFileDisk( location.getPath(Names.indexId2Node, Names.extNodeData) ) ; int count = 0 ; Iterator<Pair<Long,ByteBuffer>> iter = objects.all() ; while ( iter.hasNext() ) { iter.next() ; count++ ; } objects.close() ; return count ; } }
static StoreParams read(Location location) { String fn = location.getPath(TDB_CONFIG_FILE) ; JsonObject obj = JSON.read(fn) ; return StoreParamsCodec.decode(obj) ; } }
@Override final public void finishBulk() { loaderTriples.loadDataFinish() ; loaderTriples.loadIndexStart() ; loaderTriples.loadIndexFinish() ; loaderTriples.loadFinish() ; if ( !dsg.getLocation().isMem() && startedEmpty && stats != null ) { String filename = dsg.getLocation().getPath(Names.optStats) ; Stats.write(filename, stats.results()) ; } forceSync(dsg) ; }
@Override protected StringFile createStringFile() { String dir = ConfigTest.getTestingDir() ; clearDirectory(dir) ; Location loc = Location.create(dir) ; fn = loc.getPath("xyz", "node") ; FileOps.delete(fn) ; return FileFactory.createStringFileDisk(fn) ; }
@Override protected StringFile createStringFile() { String dir = ConfigTest.getTestingDir() ; clearDirectory(dir) ; Location loc = Location.create(dir) ; fn = loc.getPath("xyz", "node") ; FileOps.delete(fn) ; return FileFactory.createStringFileDisk(fn) ; }
@Test public void params_choose_new_persist_3() { // new database, location defined, application modified. Location loc = Location.create(DIR) ; FileOps.clearAll(loc.getDirectoryPath()); StoreParamsCodec.write(loc, pLoc); // Clear. StoreParams p = Build.decideStoreParams(loc, true, pApp, pLoc, pDft) ; // Check location still has a pLoc. String fn = loc.getPath(StoreParamsConst.TDB_CONFIG_FILE) ; assertTrue(FileOps.exists(fn)) ; StoreParams pLoc2 = StoreParamsCodec.read(loc) ; assertFalse(StoreParams.sameValues(pLoc, p)) ; assertEquals(0, p.getBlockSize().intValue()) ; // Location assertEquals(12, p.getNodeMissCacheSize().intValue()) ; // Application }
@Test public void params_choose_new_persist_1() { // new database, app defined. Location loc = Location.create(DIR) ; FileOps.clearAll(loc.getDirectoryPath()); // Clear. StoreParams p = Build.decideStoreParams(loc, true, pApp, null, pDft) ; // Check location now has a pLoc. String fn = loc.getPath(StoreParamsConst.TDB_CONFIG_FILE) ; assertTrue(FileOps.exists(fn)) ; StoreParams pLoc2 = StoreParamsCodec.read(loc) ; assertTrue(StoreParams.sameValues(pLoc2, p)) ; }
@Test public void params_choose_new_persist_1() { // new database, app defined. Location loc = Location.create(DIR) ; FileOps.clearAll(loc.getDirectoryPath()); // Clear. StoreParams p = Build.decideStoreParams(loc, true, pApp, null, pDft) ; // Check location now has a pLoc. String fn = loc.getPath(StoreParamsConst.TDB_CONFIG_FILE) ; assertTrue(FileOps.exists(fn)) ; StoreParams pLoc2 = StoreParamsCodec.read(loc) ; assertTrue(StoreParams.sameValues(pLoc2, p)) ; }
@Test public void params_choose_new_persist_2() { // new database, location defined. Location loc = Location.create(DIR) ; FileOps.clearAll(loc.getDirectoryPath()); StoreParamsCodec.write(loc, pLoc); // Clear. StoreParams p = Build.decideStoreParams(loc, true, null, pLoc, pDft) ; // Check location still has a pLoc. String fn = loc.getPath(StoreParamsConst.TDB_CONFIG_FILE) ; assertTrue(FileOps.exists(fn)) ; StoreParams pLoc2 = StoreParamsCodec.read(loc) ; assertTrue(StoreParams.sameValues(pLoc, p)) ; }
@Test public void params_choose_new_persist_2() { // new database, location defined. Location loc = Location.create(DIR) ; FileOps.clearAll(loc.getDirectoryPath()); StoreParamsCodec.write(loc, pLoc); // Clear. StoreParams p = Build.decideStoreParams(loc, true, null, pLoc, pDft) ; // Check location still has a pLoc. String fn = loc.getPath(StoreParamsConst.TDB_CONFIG_FILE) ; assertTrue(FileOps.exists(fn)) ; StoreParams pLoc2 = StoreParamsCodec.read(loc) ; assertTrue(StoreParams.sameValues(pLoc, p)) ; }