@Override public boolean contains(T obj) { return cache.contains(obj) ; }
@Override public boolean contains(T obj) { return cache.contains(obj) ; }
@Override synchronized public boolean contains(T obj) { return cache.contains(obj) ; }
@Override public boolean contains(T obj) { return cache.contains(obj) ; }
@Override synchronized public boolean contains(T obj) { return cache.contains(obj) ; }
@Override synchronized public boolean contains(T obj) { return cache.contains(obj) ; }
/** Check caches to see if we can map a Node to a NodeId. Returns null on no cache entry. */ private NodeId cacheLookup(Node node) { // Remember things known (currently) not to exist. // Does not matter if notPresent is being updated elsewhere. if ( notPresent != null && notPresent.contains(node) ) return null ; if ( node2id_Cache == null ) return null ; return node2id_Cache.getIfPresent(node) ; }
/** * Check caches to see if we can map a Node to a NodeId. Returns null on no * cache entry. */ private NodeId cacheLookup(Node node) { // Remember things known (currently) not to exist. // Does not matter if notPresent is being updated elsewhere. if ( notPresent != null && notPresent.contains(node) ) return null ; if ( node2id_Cache == null ) return null ; return node2id_Cache.getIfPresent(node) ; }
/** Generate a warning, once(ish) */ public static void warnOnce(Class<?> cls, String message, Object key) { if ( ! warningsDone.contains(key) ) { Log.warn(cls, message) ; warningsDone.add(key); } } }
/** Generate a warning, once(ish) */ public static void warnOnce(Class<?> cls, String message, Object key) { if ( ! warningsDone.contains(key) ) { Log.warn(cls, message) ; warningsDone.add(key); } } }
private void testForConsistency() { Iterator<Node> iter1 = Iter.toList(node2id_Cache.keys()).iterator() ; for ( ; iter1.hasNext() ; ) { Node n = iter1.next() ; NodeId nId = node2id_Cache.getIfPresent(n) ; if ( !id2node_Cache.containsKey(nId) ) throw new TDBException("Inconsistent: " + n + " => " + nId) ; if ( notPresent.contains(n) ) throw new TDBException("Inconsistent: " + n + " in notPresent cache (1)") ; } Iterator<NodeId> iter2 = Iter.toList(id2node_Cache.keys()).iterator() ; for ( ; iter2.hasNext() ; ) { NodeId nId = iter2.next() ; Node n = id2node_Cache.getIfPresent(nId) ; if ( !node2id_Cache.containsKey(n) ) throw new TDBException("Inconsistent: " + nId + " => " + n) ; if ( notPresent.contains(n) ) throw new TDBException("Inconsistent: " + n + " in notPresent cache (2)") ; } }
private void testForConsistency() { Iterator<Node> iter1 = Iter.toList(node2id_Cache.keys()).iterator() ; for ( ; iter1.hasNext() ; ) { Node n = iter1.next() ; NodeId nId = node2id_Cache.getIfPresent(n) ; if ( !id2node_Cache.containsKey(nId) ) throw new TDBException("Inconsistent: "+n+" => "+nId) ; if ( notPresent.contains(n) ) throw new TDBException("Inconsistent: "+n+" in notPresent cache (1)") ; } Iterator<NodeId> iter2 = Iter.toList(id2node_Cache.keys()).iterator() ; for ( ; iter2.hasNext() ; ) { NodeId nId = iter2.next() ; Node n = id2node_Cache.getIfPresent(nId) ; if ( !node2id_Cache.containsKey(n) ) throw new TDBException("Inconsistent: "+nId+" => "+n) ; if ( notPresent.contains(n) ) throw new TDBException("Inconsistent: "+n+" in notPresent cache (2)") ; } }
/** Update the Node->NodeId caches */ private void cacheUpdate(Node node, NodeId id) { if ( node == null ) return ; // synchronized is further out. // The "notPresent" cache is used to note whether a node // is known not to exist. // This must be specially handled later if the node is added. if ( NodeId.isDoesNotExist(id) ) { if ( notPresent != null ) notPresent.add(node) ; return ; } if ( id == NodeId.NodeIdAny ) { Log.warn(this, "Attempt to cache NodeIdAny - ignored") ; return ; } if ( node2id_Cache != null ) node2id_Cache.put(node, id) ; if ( id2node_Cache != null ) id2node_Cache.put(id, node) ; // Remove if previously marked "not present" if ( notPresent != null && notPresent.contains(node) ) notPresent.remove(node) ; }
/** Update the Node->NodeId caches */ private void cacheUpdate(Node node, NodeId id) { if ( node == null ) return ; // synchronized is further out. // The "notPresent" cache is used to note whether a node // is known not to exist. // This must be specially handled later if the node is added. if ( NodeId.isDoesNotExist(id) ) { if ( notPresent != null ) notPresent.add(node) ; return ; } if ( id == NodeId.NodeIdAny ) { Log.warn(this, "Attempt to cache NodeIdAny - ignored") ; return ; } if ( node2id_Cache != null ) node2id_Cache.put(node, id) ; if ( id2node_Cache != null ) id2node_Cache.put(id, node) ; // Remove if previously marked "not present" if ( notPresent != null && notPresent.contains(node) ) notPresent.remove(node) ; } // ----