/** Removes the entry whose next access is farthest away into the future. */ private void evict() { data.remove(data.lastInt()); policyStats.recordEviction(); } }
/** Performs the cache operations for the given key. */ private void process(long key) { IntPriorityQueue times = accessTimes.get(key); int lastAccess = times.dequeueInt(); boolean found = data.remove(lastAccess); if (times.isEmpty()) { data.add(infiniteTimestamp--); accessTimes.remove(key); } else { data.add(times.firstInt()); } if (found) { policyStats.recordHit(); } else { policyStats.recordMiss(); if (data.size() > maximumSize) { evict(); } } }
/** Removes the entry whose next access is farthest away into the future. */ private void evict() { data.remove(data.lastInt()); policyStats.recordEviction(); } }
@Override public int enableInstance( final R2TransformOrthogonalReadableType t) { NullCheck.notNull(t); if (this.enabledCount() == this.max_size) { final StringBuilder sb = new StringBuilder(64); sb.append("Batch is full (capacity is "); sb.append(this.max_size); sb.append(")"); throw new R2ExceptionBatchIsFull(sb.toString()); } Preconditions.checkPrecondition( !this.free.isEmpty(), "Free set must not be empty"); final int next = this.free.firstInt(); this.members[next] = t; this.free.remove(next); return next; }
public Integer add(K k) { checkK(k); Integer id = timeSortedMap.get(k); if (id == null) { if (!garbageQueue.isEmpty()) { id = garbageQueue.firstInt(); garbageQueue.remove(id); } else { id = length++; } timeSortedMap.put(k, id); ensureArraySize(id); countMap[id] = 1; } else { countMap[id]++; } return id; }
public Integer add(K k) { checkK(k); Integer id = timeSortedMap.get(k); if (id == null) { if (!garbageQueue.isEmpty()) { id = garbageQueue.firstInt(); garbageQueue.remove(id); } else { id = length++; } timeSortedMap.put(k, id); ensureArraySize(id); countMap[id] = 1; } else { countMap[id]++; } return id; }
protected int addLeaf(final Octant octant) { int id; if (!garbageQueue.isEmpty()) { id = garbageQueue.firstInt(); garbageQueue.remove(id); } else { id = length++; ensureArraySize(id); } leaves[id] = octant; leavesCount++; octant.leafId = id; return id; }
protected int addView(final GraphViewImpl view) { checkNonNullViewObject(view); int id; if (!garbageQueue.isEmpty()) { id = garbageQueue.firstInt(); garbageQueue.remove(id); } else { id = length++; ensureArraySize(id); } views[id] = view; view.storeId = id; return id; }
protected int addView(final GraphViewImpl view) { checkNonNullViewObject(view); int id; if (!garbageQueue.isEmpty()) { id = garbageQueue.firstInt(); garbageQueue.remove(id); } else { id = length++; ensureArraySize(id); } views[id] = view; view.storeId = id; return id; }
/** Performs the cache operations for the given key. */ private void process(long key) { IntPriorityQueue times = accessTimes.get(key); int lastAccess = times.dequeueInt(); boolean found = data.remove(lastAccess); if (times.isEmpty()) { data.add(infiniteTimestamp--); accessTimes.remove(key); } else { data.add(times.firstInt()); } if (found) { policyStats.recordHit(); } else { policyStats.recordMiss(); if (data.size() > maximumSize) { evict(); } } }