@Test public void params_choose_existing_2() { StoreParams p = StoreParamsFactory.decideStoreParams(Location.mem(), false, pApp, null, pDft) ; // p is pLoc modified by pApp assertFalse(StoreParams.sameValues(p, pApp)) ; assertFalse(StoreParams.sameValues(p, pDft)) ; // Existing store, no pLoc, so pDft is implicit pLoc and fixed the block size. assertEquals(pDft.getBlockSize(), p.getBlockSize()) ; assertEquals(12, p.getNodeMissCacheSize().intValue()) ; }
@Test public void params_choose_new_2() { StoreParams p = StoreParamsFactory.decideStoreParams(Location.mem(), true, pApp, null, pDft) ; // New store, no pLoc, so pApp is the enire settings. assertEquals(12, p.getBlockSize().intValue()) ; assertTrue(StoreParams.sameValues(p, pApp)) ; }
@Test public void params_choose_new_3() { StoreParams p = StoreParamsFactory.decideStoreParams(Location.mem(), true, null, pLoc, pDft) ; // New store, pLoc, no pApp, so pLoc is the entire settings. assertEquals(0, p.getBlockSize().intValue()) ; assertTrue(StoreParams.sameValues(p, pLoc)) ; }
@Test public void params_choose_new_3() { StoreParams p = StoreParamsFactory.decideStoreParams(Location.mem(), true, null, pLoc, pDft) ; // New store, pLoc, no pApp, so pLoc is the entire settings. assertEquals(0, p.getBlockSize().intValue()) ; assertTrue(StoreParams.sameValues(p, pLoc)) ; }
@Test public void params_choose_existing_2() { StoreParams p = StoreParamsFactory.decideStoreParams(Location.mem(), false, pApp, null, pDft) ; // p is pLoc modified by pApp assertFalse(StoreParams.sameValues(p, pApp)) ; assertFalse(StoreParams.sameValues(p, pDft)) ; // Existing store, no pLoc, so pDft is implicit pLoc and fixed the block size. assertEquals(pDft.getBlockSize(), p.getBlockSize()) ; assertEquals(12, p.getNodeMissCacheSize().intValue()) ; }
@Test public void params_choose_new_2() { StoreParams p = StoreParamsFactory.decideStoreParams(Location.mem(), true, pApp, null, pDft) ; // New store, no pLoc, so pApp is the enire settings. assertEquals(12, p.getBlockSize().intValue()) ; assertTrue(StoreParams.sameValues(p, pApp)) ; }
@Test public void store_params_10() { StoreParams params = StoreParams.builder().fileMode(FileMode.direct).blockSize(1024).build() ; StoreParams params2 = roundTrip(params) ; assertEqualsStoreParams(params,params2) ; assertEquals(params.getFileMode(), params2.getFileMode()) ; assertEquals(params.getBlockSize(), params2.getBlockSize()) ; }
@Test public void store_params_10() { StoreParams params = StoreParams.builder().fileMode(FileMode.direct).blockSize(1024).build() ; StoreParams params2 = roundTrip(params) ; assertEqualsStoreParams(params,params2) ; assertEquals(params.getFileMode(), params2.getFileMode()) ; assertEquals(params.getBlockSize(), params2.getBlockSize()) ; }
@Test public void params_choose_existing_4() { StoreParams p = StoreParamsFactory.decideStoreParams(Location.mem(), false, pApp, pLoc, pDft) ; // p is pLoc modifed by pApp. assertFalse(StoreParams.sameValues(p, pApp)) ; assertFalse(StoreParams.sameValues(p, pLoc)) ; assertFalse(StoreParams.sameValues(p, pDft)) ; assertEquals(0, p.getBlockSize().intValue()) ; assertEquals(12, p.getNodeMissCacheSize().intValue()) ; }
@Test public void params_choose_new_4() { StoreParams p = StoreParamsFactory.decideStoreParams(Location.mem(), true, pApp, pLoc, pDft) ; // New store, pLoc, no pApp, so pLoc is the entire settings. assertFalse(StoreParams.sameValues(p, pApp)) ; assertFalse(StoreParams.sameValues(p, pLoc)) ; assertFalse(StoreParams.sameValues(p, pDft)) ; assertEquals(0, p.getBlockSize().intValue()) ; assertEquals(12, p.getNodeMissCacheSize().intValue()) ; }
@Test public void params_reconnect_02() { // Create. StoreConnection.connectCreate(loc, null) ; // Drop. expel(); // Reconnect StoreConnection.connectCreate(loc, pSpecial) ; //StoreParams pLoc = StoreParamsCodec.read(loc) ; //assertNotNull(pLoc) ; StoreParams pDB = StoreConnection.connectExisting(loc).getDatasetGraphTDB().getStoreParams() ; assertNotNull(pDB) ; // Should be the default setup, modified by pApp for cache sizes. assertFalse(StoreParams.sameValues(pDft, pDB)) ; assertFalse(StoreParams.sameValues(pSpecial, pDB)) ; // Check it's default-modified-by-special. assertEquals(pSpecial.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pDft.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pSpecial.getBlockSize(), pDB.getBlockSize()) ; assertEquals(pDft.getBlockSize(), pDB.getBlockSize()) ; }
@Test public void params_reconnect_03() { // Create. StoreConnection.connectCreate(loc, pApp) ; // Drop. expel(); // Reconnect StoreConnection.connectCreate(loc, pSpecial) ; //StoreParams pLoc = StoreParamsCodec.read(loc) ; //assertNotNull(pLoc) ; StoreParams pDB = StoreConnection.connectExisting(loc).getDatasetGraphTDB().getStoreParams() ; assertNotNull(pDB) ; // Should be the default setup, modified by pApp for cache sizes. assertFalse(StoreParams.sameValues(pApp, pDB)) ; assertFalse(StoreParams.sameValues(pSpecial, pDB)) ; // Check it's default-modified-by-special. assertEquals(pSpecial.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pApp.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pSpecial.getBlockSize(), pDB.getBlockSize()) ; assertEquals(pApp.getBlockSize(), pDB.getBlockSize()) ; }
@Test public void params_choose_existing_4() { StoreParams p = StoreParamsFactory.decideStoreParams(Location.mem(), false, pApp, pLoc, pDft) ; // p is pLoc modifed by pApp. assertFalse(StoreParams.sameValues(p, pApp)) ; assertFalse(StoreParams.sameValues(p, pLoc)) ; assertFalse(StoreParams.sameValues(p, pDft)) ; assertEquals(0, p.getBlockSize().intValue()) ; assertEquals(12, p.getNodeMissCacheSize().intValue()) ; }
@Test public void params_reconnect_02() { // Create. StoreConnection.connectCreate(loc, null) ; // Drop. expel(); // Reconnect StoreConnection.connectCreate(loc, pSpecial) ; //StoreParams pLoc = StoreParamsCodec.read(loc) ; //assertNotNull(pLoc) ; StoreParams pDB = StoreConnection.connectExisting(loc).getDatasetGraphTDB().getStoreParams() ; assertNotNull(pDB) ; // Should be the default setup, modified by pApp for cache sizes. assertFalse(StoreParams.sameValues(pDft, pDB)) ; assertFalse(StoreParams.sameValues(pSpecial, pDB)) ; // Check it's default-modified-by-special. assertEquals(pSpecial.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pDft.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pSpecial.getBlockSize(), pDB.getBlockSize()) ; assertEquals(pDft.getBlockSize(), pDB.getBlockSize()) ; }
@Test public void params_choose_new_4() { StoreParams p = StoreParamsFactory.decideStoreParams(Location.mem(), true, pApp, pLoc, pDft) ; // New store, pLoc, no pApp, so pLoc is the entire settings. assertFalse(StoreParams.sameValues(p, pApp)) ; assertFalse(StoreParams.sameValues(p, pLoc)) ; assertFalse(StoreParams.sameValues(p, pDft)) ; assertEquals(0, p.getBlockSize().intValue()) ; assertEquals(12, p.getNodeMissCacheSize().intValue()) ; }
@Test public void params_reconnect_03() { // Create. StoreConnection.connectCreate(loc, pApp) ; // Drop. expel(); // Reconnect StoreConnection.connectCreate(loc, pSpecial) ; //StoreParams pLoc = StoreParamsCodec.read(loc) ; //assertNotNull(pLoc) ; StoreParams pDB = StoreConnection.connectExisting(loc).getDatasetGraphTDB().getStoreParams() ; assertNotNull(pDB) ; // Should be the default setup, modified by pApp for cache sizes. assertFalse(StoreParams.sameValues(pApp, pDB)) ; assertFalse(StoreParams.sameValues(pSpecial, pDB)) ; // Check it's default-modified-by-special. assertEquals(pSpecial.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pApp.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pSpecial.getBlockSize(), pDB.getBlockSize()) ; assertEquals(pApp.getBlockSize(), pDB.getBlockSize()) ; }
@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 = StoreParamsFactory.decideStoreParams(loc, true, pApp, pLoc, pDft) ; // Check location still has a pLoc. String fn = loc.getPath(Names.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 }
@Override public String toString() { StringBuilder buff = new StringBuilder() ; fmt(buff, "fileMode", getFileMode().toString(), fileMode.isSet) ; fmt(buff, "blockSize", getBlockSize(), blockSize.isSet) ; fmt(buff, "readCacheSize", getBlockReadCacheSize(), blockReadCacheSize.isSet) ; fmt(buff, "writeCacheSize", getBlockWriteCacheSize(), blockWriteCacheSize.isSet) ; fmt(buff, "Node2NodeIdCacheSize", getNode2NodeIdCacheSize(), Node2NodeIdCacheSize.isSet) ; fmt(buff, "NodeId2NodeCacheSize", getNodeId2NodeCacheSize(), NodeId2NodeCacheSize.isSet) ; fmt(buff, "NodeMissCacheSize", getNodeMissCacheSize(), NodeMissCacheSize.isSet) ; fmt(buff, "nodeTableBaseName", getNodeTableBaseName(), nodeTableBaseName.isSet) ; fmt(buff, "primaryIndexTriples", getPrimaryIndexTriples(), primaryIndexTriples.isSet) ; fmt(buff, "tripleIndexes", getTripleIndexes(), tripleIndexes.isSet) ; fmt(buff, "primaryIndexQuads", getPrimaryIndexQuads(), primaryIndexQuads.isSet) ; fmt(buff, "quadIndexes", getQuadIndexes(), quadIndexes.isSet) ; fmt(buff, "prefixTableBaseName", getPrefixTableBaseName(), prefixTableBaseName.isSet) ; fmt(buff, "primaryIndexPrefix", getPrimaryIndexPrefix(), primaryIndexPrefix.isSet) ; fmt(buff, "prefixIndexes", getPrefixIndexes(), prefixIndexes.isSet) ; return buff.toString() ; }
@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 = StoreParamsFactory.decideStoreParams(loc, true, pApp, pLoc, pDft) ; // Check location still has a pLoc. String fn = loc.getPath(Names.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 }
public static JsonObject encodeToJson(StoreParams params) { JsonBuilder builder = new JsonBuilder() ; builder.startObject("StoreParams") ; // "StoreParams" is an internal alignment marker - not in the JSON. encode(builder, key(fFileMode), params.getFileMode().name()) ; encode(builder, key(fBlockSize), params.getBlockSize()) ; encode(builder, key(fBlockReadCacheSize), params.getBlockReadCacheSize()) ; encode(builder, key(fBlockWriteCacheSize), params.getBlockWriteCacheSize()) ; encode(builder, key(fNode2NodeIdCacheSize), params.getNode2NodeIdCacheSize()) ; encode(builder, key(fNodeId2NodeCacheSize), params.getNodeId2NodeCacheSize()) ; encode(builder, key(fNodeMissCacheSize), params.getNodeMissCacheSize()) ; encode(builder, key(fNodeTableBaseName), params.getNodeTableBaseName()) ; encode(builder, key(fPrimaryIndexTriples), params.getPrimaryIndexTriples()) ; encode(builder, key(fTripleIndexes), params.getTripleIndexes()) ; encode(builder, key(fPrimaryIndexQuads), params.getPrimaryIndexQuads()) ; encode(builder, key(fQuadIndexes), params.getQuadIndexes()) ; encode(builder, key(fPrefixTableBaseName), params.getPrefixTableBaseName()) ; encode(builder, key(fPrimaryIndexPrefix), params.getPrimaryIndexPrefix()) ; encode(builder, key(fPrefixIndexes), params.getPrefixIndexes()) ; builder.finishObject("StoreParams") ; return (JsonObject)builder.build() ; }