use of com.hazelcast.sql.impl.optimizer.PlanKey in project hazelcast by hazelcast.
the class PlanCacheTest method testPlanUsageUpdate.
@Test
public void testPlanUsageUpdate() {
PlanCache cache = new PlanCache(10);
PlanKey key = createKey("sql");
SqlPlan plan = createPlan(key, PART_MAP_1);
cache.put(key, plan);
long timestamp1 = plan.getPlanLastUsed();
assertTrue(timestamp1 > 0);
advanceTime();
cache.put(key, plan);
long timestamp2 = plan.getPlanLastUsed();
assertTrue(timestamp2 > timestamp1);
advanceTime();
cache.get(key);
long timestamp3 = plan.getPlanLastUsed();
assertTrue(timestamp3 > timestamp2);
}
use of com.hazelcast.sql.impl.optimizer.PlanKey in project hazelcast by hazelcast.
the class PlanCacheTest method testOverflow.
@Test
public void testOverflow() {
// Fill till full
int size = 5;
PlanCache cache = new PlanCache(size);
for (int i = 0; i < size; i++) {
PlanKey key = createKey(Integer.toString(i));
cache.put(key, createPlan(key, PART_MAP_1));
advanceTime();
}
assertEquals(size, cache.size());
// Overflow happens here
PlanKey overflowKey = createKey(Integer.toString(size));
cache.put(overflowKey, createPlan(overflowKey, PART_MAP_1));
assertEquals(size, cache.size());
for (int i = 0; i < size; i++) {
PlanKey key = createKey(Integer.toString(i + 1));
assertNotNull(cache.get(key));
}
}
Aggregations