public boolean containsKey(Long key) { return map.containsKey(key); }
public void clear() { map.clear(); }
public V remove(Long key) { CacheEntry<Long, V> cacheEntry = map.remove(key); if (cacheEntry != null) { stats.size.decrementAndGet(); return cacheEntry.value; } return null; }
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; }
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 LRUVertexCache(int capacity) { volatileVertices = new NonBlockingHashMapLong<InternalVertex>(); cache = new ConcurrentLRUCache<InternalVertex>(capacity * 2, // upper is double capacity capacity + capacity / 3, // lower is capacity + 1/3 capacity, // acceptable watermark is capacity 100, true, false, // 100 items initial size + use only one thread for items cleanup new ConcurrentLRUCache.EvictionListener<InternalVertex>() { @Override public void evictedEntry(Long vertexId, InternalVertex vertex) { if (vertexId == null || vertex == null) return; if (vertex.isModified()) { volatileVertices.putIfAbsent(vertexId, vertex); } } }); cache.setAlive(true); //need counters to its actually LRU }
public Map<Long,EntryList> retrievePartitionAggregates() { for (PartitionVertexAggregate agg : partitionVertices.values()) agg.completeIteration(); return Maps.transformValues(partitionVertices, s -> s.getLoadedProperties()); }
public void clear() { map.clear(); }
public boolean containsKey(Long key) { return map.containsKey(key); }
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; }
public V remove(Long key) { CacheEntry<Long, V> cacheEntry = map.remove(key); if (cacheEntry != null) { stats.size.decrementAndGet(); return cacheEntry.value; } return null; }
@Override public synchronized void close() { volatileVertices.clear(); cache.destroy(); } }
@Override public boolean contains(long id) { Long vertexId = id; return cache.containsKey(vertexId) || volatileVertices.containsKey(vertexId); }
@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 synchronized void close() { volatileVertices.clear(); cache.destroy(); } }
@Override public boolean contains(long id) { Long vertexId = id; return cache.containsKey(vertexId) || volatileVertices.containsKey(vertexId); }
void nextIteration(Set<MessageScope> scopes) { currentScopes = getIdMap(normalizeScopes(scopes)); partitionVertices.clear(); }
void nextIteration(Set<MessageScope> scopes) { currentScopes = getIdMap(normalizeScopes(scopes)); partitionVertices.clear(); inExecute = true; }