PhysicalInfo(Long gid, Long id, int inode, long lastAccess, int sizeEstimate) { super(new CacheKey(id, lastAccess, 0)); this.inode = inode; this.gid = gid; this.sizeEstimate = sizeEstimate; }
PhysicalInfo(Long gid, Long id, int inode, long lastAccess, int sizeEstimate) { super(new CacheKey(id, lastAccess, 0)); this.inode = inode; this.gid = gid; this.sizeEstimate = sizeEstimate; }
public CacheEntry(Long oid) { this(new CacheKey(oid, 0, 0), 0, null, null, false); }
PhysicalInfo(Long gid, Long id, int inode, long lastAccess, int sizeEstimate) { super(new CacheKey(id, lastAccess, 0)); this.inode = inode; this.gid = gid; this.sizeEstimate = sizeEstimate; }
public CacheEntry(Long oid) { this(new CacheKey(oid, 0, 0), 0, null, null, false); }
public CacheEntry(Long oid) { this(new CacheKey(oid, 0, 0), 0, null, null, false); }
/** * Callers should be synchronized on value */ void recordAccess(V value) { CacheKey key = value.getKey(); long lastAccess = key.getLastAccess(); long currentClock = clock.get(); long orderingValue = key.getOrderingValue(); orderingValue = computeNextOrderingValue(currentClock, lastAccess, orderingValue); assert !this.evictionQueue.containsKey(value.getKey()); value.setKey(new CacheKey(key.getId(), currentClock, orderingValue)); }
/** * Callers should be synchronized on value */ void recordAccess(V value) { CacheKey key = value.getKey(); long lastAccess = key.getLastAccess(); long currentClock = clock.get(); long orderingValue = key.getOrderingValue(); orderingValue = computeNextOrderingValue(currentClock, lastAccess, orderingValue); assert !this.evictionQueue.containsKey(value.getKey()); value.setKey(new CacheKey(key.getId(), currentClock, orderingValue)); }
/** * Callers should be synchronized on value */ void recordAccess(V value) { CacheKey key = value.getKey(); long lastAccess = key.getLastAccess(); long currentClock = clock.get(); long orderingValue = key.getOrderingValue(); orderingValue = computeNextOrderingValue(currentClock, lastAccess, orderingValue); assert !this.evictionQueue.containsKey(value.getKey()); value.setKey(new CacheKey(key.getId(), currentClock, orderingValue)); }
CacheEntry ce = new CacheEntry(new CacheKey(oid, 1, 1), info.sizeEstimate, serializer.deserialize(dis), ref, true); return ce; } catch(IOException e) {
rowsSampled += batch.size(); Long oid = batchAdded.getAndIncrement(); CacheKey key = new CacheKey(oid, readAttempts.get(), old!=null?old.getKey().getOrderingValue():0); CacheEntry ce = new CacheEntry(key, sizeEstimate, batch, this.ref, false); if (!cache.addToCacheGroup(id, ce.getId())) {
rowsSampled += batch.size(); Long oid = batchAdded.getAndIncrement(); CacheKey key = new CacheKey(oid, readAttempts.get(), old!=null?old.getKey().getOrderingValue():0); CacheEntry ce = new CacheEntry(key, sizeEstimate, batch, this.ref, false); if (!cache.addToCacheGroup(id, ce.getId())) {
CacheEntry ce = new CacheEntry(new CacheKey(oid, 1, 1), info.sizeEstimate, serializer.deserialize(dis), ref, true); return ce; } catch(IOException e) {
CacheEntry ce = new CacheEntry(new CacheKey(oid, 1, 1), info.sizeEstimate, serializer.deserialize(dis), ref, true); return ce; } catch(IOException e) {
rowsSampled += batch.size(); Long oid = batchAdded.getAndIncrement(); CacheKey key = new CacheKey(oid, readAttempts.get(), old!=null?old.getKey().getOrderingValue():0); CacheEntry ce = new CacheEntry(key, sizeEstimate, batch, this.ref, false); if (!cache.addToCacheGroup(id, ce.getId())) {
@Test public void testTouch() { AtomicLong clock = new AtomicLong(); LrfuEvictionQueue<BaseCacheEntry> q = new LrfuEvictionQueue<BaseCacheEntry>(clock); CacheKey key = new CacheKey(0l, 0l, 0l); BaseCacheEntry value = new BaseCacheEntry(key); q.touch(value); assertEquals(1, q.getSize()); assertNotNull(q.firstEntry(true)); //advance the clock to perform the remove/add clock.set(LrfuEvictionQueue.MIN_INTERVAL); q.touch(value); assertEquals(1, q.getSize()); assertNotNull(q.firstEntry(true)); }
@Test public void testMultipleAdds() throws Exception { cache = createLayeredCache(1 << 18, 1 << 18, true); Serializer<Integer> s = new SimpleSerializer() { @Override public void serialize(Integer obj, ObjectOutput oos) throws IOException { throw new IOException(); } }; CacheEntry ce = new CacheEntry(new CacheKey(31l, 0, 0), 1000000, null, null, false); cache.createCacheGroup(s.getId()); Integer cacheObject = Integer.valueOf(50000); ce.setObject(cacheObject); cache.addToCacheGroup(s.getId(), ce.getId()); assertTrue(cache.add(ce, s)); s = new SimpleSerializer(); assertTrue(cache.add(ce, s)); assertNotNull(get(cache, ce.getId(), s)); }