Search in sources :

Example 6 with CacheKey

use of org.teiid.common.buffer.CacheKey in project teiid by teiid.

the class TestLrfuEvictionQueue method testKeyCompare.

@Test
public void testKeyCompare() {
    CacheKey key = new CacheKey(-5600000000000000000l, 0l, 0l);
    CacheKey key1 = new CacheKey(3831662765844904176l, 0l, 0l);
    assertTrue(key.compareTo(key1) < 0);
    assertTrue(key1.compareTo(key) > 0);
}
Also used : CacheKey(org.teiid.common.buffer.CacheKey) Test(org.junit.Test)

Example 7 with CacheKey

use of org.teiid.common.buffer.CacheKey in project teiid by teiid.

the class TestLrfuEvictionQueue method testTouch.

@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));
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) BaseCacheEntry(org.teiid.common.buffer.BaseCacheEntry) CacheKey(org.teiid.common.buffer.CacheKey) Test(org.junit.Test)

Aggregations

CacheKey (org.teiid.common.buffer.CacheKey)7 Test (org.junit.Test)3 IOException (java.io.IOException)2 CacheEntry (org.teiid.common.buffer.CacheEntry)2 InputStream (java.io.InputStream)1 ObjectInput (java.io.ObjectInput)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutput (java.io.ObjectOutput)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 BaseCacheEntry (org.teiid.common.buffer.BaseCacheEntry)1 ExtensibleBufferedInputStream (org.teiid.common.buffer.ExtensibleBufferedInputStream)1 FileStore (org.teiid.common.buffer.FileStore)1 TeiidComponentException (org.teiid.core.TeiidComponentException)1 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)1