public V get(Long key) { CacheEntry<Long, V> e = map.get(key); if (e == null) { if (islive) stats.missCounter.incrementAndGet(); return null; } if (islive) e.lastAccessed = stats.accessCounter.incrementAndGet(); return e.value; }
public V get(Long key) { CacheEntry<Long, V> e = map.get(key); if (e == null) { if (isAlive) stats.missCounter.incrementAndGet(); return null; } if (isAlive) e.lastAccessed = stats.accessCounter.incrementAndGet(); return e.value; }
private VertexState<M> get(long vertexId, boolean create) { assert vertexId==getCanonicalId(vertexId); VertexState<M> state = vertexStates.get(vertexId); if (state==null) { if (!create) return VertexState.EMPTY_STATE; vertexStates.putIfAbsent(vertexId,new VertexState<>(elementKeyMap)); state = vertexStates.get(vertexId); } return state; }
private VertexState<M> get(long vertexId, boolean create) { assert vertexId==getCanonicalId(vertexId); VertexState<M> state = vertexStates.get(vertexId); if (state==null) { if (!create) return VertexState.EMPTY_STATE; vertexStates.putIfAbsent(vertexId,new VertexState<>(elementKeyMap)); state = vertexStates.get(vertexId); } return state; }
private PartitionVertexAggregate<M> getPartitioned(long vertexId) { assert idManager.isPartitionedVertex(vertexId); vertexId=getCanonicalId(vertexId); PartitionVertexAggregate<M> state = partitionVertices.get(vertexId); if (state==null) { partitionVertices.putIfAbsent(vertexId,new PartitionVertexAggregate<>(previousScopes)); state = partitionVertices.get(vertexId); } return state; }
private PartitionVertexAggregate<M> getPartitioned(long vertexId) { assert idManager.isPartitionedVertex(vertexId); vertexId=getCanonicalId(vertexId); PartitionVertexAggregate<M> state = partitionVertices.get(vertexId); if (state==null) { partitionVertices.putIfAbsent(vertexId,new PartitionVertexAggregate<>(previousScopes)); state = partitionVertices.get(vertexId); } return state; }
@Override public InternalVertex get(long id, final Retriever<Long, InternalVertex> retriever) { final Long vertexId = id; InternalVertex vertex = cache.get(vertexId); if (vertex == null) { InternalVertex newVertex = volatileVertices.get(vertexId); if (newVertex == null) { newVertex = retriever.get(vertexId); } vertex = cache.putIfAbsent(vertexId, newVertex); if (vertex == null) vertex = newVertex; } return vertex; }
@Override public InternalVertex get(long id, final Retriever<Long, InternalVertex> retriever) { final Long vertexId = id; InternalVertex vertex = cache.get(vertexId); if (vertex == null) { InternalVertex newVertex = volatileVertices.get(vertexId); if (newVertex == null) { newVertex = retriever.get(vertexId); } vertex = cache.putIfAbsent(vertexId, newVertex); if (vertex == null) vertex = newVertex; } return vertex; }
/** Tests if the key in the table. * @return <tt>true</tt> if the key is in the table */ public boolean containsKey( long key ) { return get(key) != null; }
private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Write nothing for( long K : keySet() ) { final Object V = get(K); // Do an official 'get' s.writeLong (K); // Write the <long,TypeV> pair s.writeObject(V); } s.writeLong(NO_KEY); // Sentinel to indicate end-of-data s.writeObject(null); }
private boolean hasPendingMessages(CacheLine line) { final Collection<LineMessage> msgs = pendingMessages.get(line.getId()); return msgs != null && !msgs.isEmpty(); }
private boolean hasPendingBlockingMessages(CacheLine line) { final Collection<LineMessage> msgs = pendingMessages.get(line.getId()); if (msgs == null || msgs.isEmpty()) return false; for (LineMessage m : msgs) { if (!(m instanceof Message.MSG)) return true; } return false; }
/** * Returns, but DOES NOT CLEAR the pending ops queue. */ private Collection<Op> getPendingOps(CacheLine line) { ArrayList<Op> ops = pendingOps.get(line.getId()); return (ops != null ? ops : Collections.EMPTY_LIST); }
private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Write nothing for( long K : keySet() ) { final Object V = get(K); // Do an official 'get' s.writeLong (K); // Write the <long,TypeV> pair s.writeObject(V); } s.writeLong(NO_KEY); // Sentinel to indicate end-of-data s.writeObject(null); }
private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Write nothing for( long K : keySet() ) { final Object V = get(K); // Do an official 'get' s.writeLong (K); // Write the <long,TypeV> pair s.writeObject(V); } s.writeLong(NO_KEY); // Sentinel to indicate end-of-data s.writeObject(null); }
private void addPendingMessage(CacheLine line, LineMessage message) { LinkedHashSet<LineMessage> msgs = pendingMessages.get(line.getId()); if (msgs == null) { msgs = new LinkedHashSet<LineMessage>(); pendingMessages.put(line.getId(), msgs); } msgs.add(message); if (LOG.isDebugEnabled()) LOG.debug("addPendingMessage {} to line {}", message, line); }
@Override public S get(long vertexId) { if (idManager.isPartitionedVertex(vertexId)) vertexId=idManager.getCanonicalVertexId(vertexId); return vertexStates.get(vertexId); } }
private PartitionVertexAggregate<M> getPartitioned(long vertexId) { assert idManager.isPartitionedVertex(vertexId); vertexId=getCanonicalId(vertexId); PartitionVertexAggregate<M> state = partitionVertices.get(vertexId); if (state==null) { partitionVertices.putIfAbsent(vertexId,new PartitionVertexAggregate<>(previousScopes)); state = partitionVertices.get(vertexId); } return state; }
private OwnerClock getOwnerClock(short owner) { OwnerClock oc = ownerClocks.get(owner); if (oc == null) { oc = new OwnerClock(); final OwnerClock tmp = ownerClocks.putIfAbsent(owner, oc); if (tmp != null) oc = tmp; } return oc; }
private void addPendingOp(CacheLine line, Op op) { if (op.hasFuture()) return; op.createFuture(); ArrayList<Op> ops = pendingOps.get(op.line); if (ops == null) { ops = new ArrayList<Op>(); pendingOps.put(op.line, ops); } ops.add(op); }