@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()) ; }
@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 store_params_02() { StoreParams input = StoreParams.getDftStoreParams() ; StoreParams sp = StoreParams.builder(input).build() ; assertEqualsStoreParams(StoreParams.getDftStoreParams(), sp) ; }
public static NodeTable create(NodeTable nodeTable, StoreParams params) { int nodeToIdCacheSize = params.getNode2NodeIdCacheSize() ; int idToNodeCacheSize = params.getNodeId2NodeCacheSize() ; if ( nodeToIdCacheSize <= 0 && idToNodeCacheSize <= 0 ) return nodeTable ; return new NodeTableCache(nodeTable, nodeToIdCacheSize, idToNodeCacheSize, params.getNodeMissCacheSize()) ; }
public TripleTable buildTripleTable(NodeTable nodeTable) { String primary = params.getPrimaryIndexTriples(); String[] indexes = params.getTripleIndexes(); // Validation checks - common index forms. if ( indexes.length != 3 && indexes.length != 2 ) error(log(), "Wrong number of triple table indexes: "+String.join(",", indexes)); log().debug("Triple table: "+primary+" :: "+String.join(",", indexes)); TupleIndex tripleIndexes[] = makeTupleIndexes(primary, indexes); if ( tripleIndexes.length != indexes.length ) error(log(), "Wrong number of triple table tuples indexes: "+tripleIndexes.length); TripleTable tripleTable = new TripleTable(tripleIndexes, nodeTable); return tripleTable; }
@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_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 store_params_22() { StoreParams params1 = StoreParams.builder() .blockReadCacheSize(0) .blockWriteCacheSize(1) .build(); StoreParams params2 = StoreParams.builder() .blockReadCacheSize(5) .build(); StoreParams params3 = StoreParamsBuilder.modify(params1, params2) ; assertFalse(params2.isSetBlockWriteCacheSize()) ; assertTrue(params3.isSetBlockReadCacheSize()) ; assertTrue(params3.isSetBlockWriteCacheSize()) ; assertEquals(5, params3.getBlockReadCacheSize().intValue()) ; // From params2 assertEquals(1, params3.getBlockWriteCacheSize().intValue()) ; // From params1, not params2(unset) }
if ( params2 == null ) return false ; if ( !sameValues(params1.fileMode, params2.fileMode) ) return false ; if ( !sameValues(params1.blockSize, params2.blockSize) ) return false ; if ( !sameValues(params1.blockReadCacheSize, params2.blockReadCacheSize) ) return false ; if ( !sameValues(params1.blockWriteCacheSize, params2.blockWriteCacheSize) ) return false ; if ( !sameValues(params1.Node2NodeIdCacheSize, params2.Node2NodeIdCacheSize) ) return false ; if ( !sameValues(params1.NodeId2NodeCacheSize, params2.NodeId2NodeCacheSize) ) return false ; if ( !sameValues(params1.NodeMissCacheSize, params2.NodeMissCacheSize) ) return false ; if ( !sameValues(params1.nodeTableBaseName, params2.nodeTableBaseName) ) return false ; if ( !sameValues(params1.primaryIndexTriples, params2.primaryIndexTriples) ) return false ; if ( !sameValues(params1.tripleIndexes, params2.tripleIndexes) ) return false ; if ( !sameValues(params1.primaryIndexQuads, params2.primaryIndexQuads) ) return false ; if ( !sameValues(params1.quadIndexes, params2.quadIndexes) ) return false ; if ( !sameValues(params1.prefixTableBaseName, params2.prefixTableBaseName) ) return false ; if ( !sameValues(params1.primaryIndexPrefix, params2.primaryIndexPrefix) )
@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_21() { StoreParams params1 = StoreParams.builder().blockReadCacheSize(0).build(); assertTrue(params1.isSetBlockReadCacheSize()) ; assertFalse(params1.isSetBlockWriteCacheSize()) ; StoreParams params2 = StoreParams.builder(params1).blockWriteCacheSize(0).build(); assertTrue(params2.isSetBlockReadCacheSize()) ; assertTrue(params2.isSetBlockWriteCacheSize()) ; assertFalse(params2.isSetNodeMissCacheSize()) ; }
public static DatasetGraphTxn build(Location location) { return build(location, StoreParams.getDftStoreParams()); }
@Test public void store_params_20() { StoreParams params = StoreParams.builder().blockReadCacheSize(0).build(); assertTrue(params.isSetBlockReadCacheSize()) ; assertFalse(params.isSetBlockWriteCacheSize()) ; }
@Test public void store_params_04() { StoreParams params = StoreParams.builder().build() ; StoreParams params2 = roundTrip(params) ; assertEqualsStoreParams(params,params2) ; }
@Test public void store_params_13() { String xs = "{ \"tdb.triple_indexes\" : [ \"POS\" , \"PSO\"] } " ; JsonObject x = JSON.parse(xs) ; StoreParams params = StoreParamsCodec.decode(x) ; String[] expected = { "POS" , "PSO" } ; assertArrayEquals(expected, params.getTripleIndexes()) ; }
public StoreParams build() { return new StoreParams( fileMode, blockSize, blockReadCacheSize, blockWriteCacheSize, Node2NodeIdCacheSize, NodeId2NodeCacheSize, NodeMissCacheSize, nodeTableBaseName, primaryIndexTriples, tripleIndexes, primaryIndexQuads, quadIndexes, prefixTableBaseName, primaryIndexPrefix, prefixIndexes) ; }
@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_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 store_params_22() { StoreParams params1 = StoreParams.builder() .blockReadCacheSize(0) .blockWriteCacheSize(1) .build(); StoreParams params2 = StoreParams.builder() .blockReadCacheSize(5) .build(); StoreParams params3 = StoreParamsBuilder.modify(params1, params2) ; assertFalse(params2.isSetBlockWriteCacheSize()) ; assertTrue(params3.isSetBlockReadCacheSize()) ; assertTrue(params3.isSetBlockWriteCacheSize()) ; assertEquals(5, params3.getBlockReadCacheSize().intValue()) ; // From params2 assertEquals(1, params3.getBlockWriteCacheSize().intValue()) ; // From params1, not params2(unset) }
private static void assertEqualsStoreParams(StoreParams params1, StoreParams params2) { assertTrue(StoreParams.sameValues(params1, params2)) ; } }