@Override public boolean contains(T obj) { return cacheMap.containsKey(obj) ; }
@Override public boolean contains(T obj) { return cacheMap.containsKey(obj) ; }
@Override public boolean containsKey(Key key) { return cache.containsKey(key) ; }
@Override synchronized public boolean containsKey(Key key) { return cache.containsKey(key) ; }
@Override public Value get(Key key) { if ( cache.containsKey(key) ) cacheMisses ++ ; else cacheHits++ ; return cache.get(key) ; }
public boolean hasCachedModel(String filenameOrURI) { if ( ! isCachingModels() ) return false ; return modelCache.containsKey(filenameOrURI) ; }
public boolean hasCachedModel(String filenameOrURI) { if ( ! isCachingModels() ) return false ; return modelCache.containsKey(filenameOrURI) ; }
@Override public boolean containsGraph(Node graphNode) { if ( namedGraphs.containsKey(graphNode) ) // Empty graph may or may not count. // If they don't, need to override this method. return true ; return _containsGraph(graphNode) ; }
private void writeCache(Block block) { Long id = block.getId() ; log("WriteCache : %d", id) ; // Should not be in the read cache due to a getWrite earlier. if ( readCache.containsKey(id) ) log.warn("write: Block in the read cache") ; if ( writeCache != null ) { writeCache.put(id, block) ; return ; } }
private void writeCache(Block block) { Long id = block.getId() ; log("WriteCache : %d", id) ; // Should not be in the read cache due to a getWrite earlier. if ( readCache.containsKey(id) ) log.warn("write: Block in the read cache") ; if ( writeCache != null ) { writeCache.put(id, block) ; return ; } }
private void writeCache(Block block) { Long id = block.getId() ; log("WriteCache : %d", id) ; // Should not be in the read cache due to a getWrite earlier. if ( readCache.containsKey(id) ) log.warn("write: Block in the read cache") ; if ( writeCache != null ) { writeCache.put(id, block) ; return ; } }
@Override public IRI resolveSilent(String uriStr) { if (resolvedIRIs != null && resolvedIRIs.containsKey(uriStr)) return resolvedIRIs.get(uriStr) ; IRI iri = iriFactory.create(uriStr) ; if (resolvedIRIs != null) resolvedIRIs.put(uriStr, iri) ; return iri ; }
@Override synchronized public void free(Block block) { Long id = block.getId() ; log("Free : %d", id) ; if ( readCache.containsKey(id) ) { log.warn("Freeing block from read cache") ; readCache.remove(id) ; } if ( writeCache != null ) writeCache.remove(id) ; super.free(block) ; }
@Override synchronized public void free(Block block) { Long id = block.getId() ; log("Free : %d", id) ; if ( readCache.containsKey(id) ) { log.warn("Freeing block from read cache") ; readCache.remove(id) ; } if ( writeCache != null ) writeCache.remove(id) ; super.free(block) ; }
public final boolean checkURI(Node node, long line, long col) { if ( cache != null && cache.containsKey(node) ) return true ; IRI iri = iriFactory.create(node.getURI()) ; // always works - no exceptions. boolean b = checkIRI(iri, line, col) ; // If OK, put in cache. if ( cache != null && b ) cache.put(node, iri) ; return b ; }
@Override synchronized public void free(Block block) { Long id = block.getId() ; log("Free : %d", id) ; if ( readCache.containsKey(id) ) { log.warn("Freeing block from read cache") ; readCache.remove(id) ; } if ( writeCache != null ) writeCache.remove(id) ; super.free(block) ; }
public final boolean checkURI(Node node, long line, long col) { if ( cache != null && cache.containsKey(node) ) return true ; IRI iri = iriFactory.create(node.getURI()); // always works - no exceptions. boolean b = checkIRI(iri, line, col) ; // If OK, put in cache. if ( cache != null && b ) cache.put(node, iri) ; return b ; }
@Test public void cache_02() { cache.put(7, 7) ; cache.put(8, 8) ; // Not true for Cache1. if ( size > 2 ) assertEquals(2, cache.size()) ; if ( size > 2 ) assertTrue(cache.containsKey(7)) ; if ( size > 2 ) assertEquals(Integer.valueOf(7), cache.getIfPresent(7)) ; assertTrue(cache.containsKey(8)) ; assertEquals(Integer.valueOf(8), cache.getIfPresent(8)) ; }
@Test public void cache_03() { cache.put(7, 7) ; Integer x1 = cache.getIfPresent(7) ; cache.put(7, 18) ; assertEquals(1, cache.size()) ; assertEquals(7, x1.intValue()) ; assertTrue(cache.containsKey(7)) ; assertEquals(Integer.valueOf(18), cache.getIfPresent(7)) ; }
@Test public void cache_01() { Integer x = cache.getIfPresent(7) ; cache.put(7, 7) ; assertEquals(1, cache.size()) ; assertNull(x) ; assertTrue(cache.containsKey(7)) ; assertEquals(Integer.valueOf(7), cache.getIfPresent(7)) ; }