Search in sources :

Example 6 with PlanKey

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);
}
Also used : PlanKey(com.hazelcast.sql.impl.optimizer.PlanKey) SqlPlan(com.hazelcast.sql.impl.optimizer.SqlPlan) PlanCache(com.hazelcast.sql.impl.plan.cache.PlanCache) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with PlanKey

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));
    }
}
Also used : PlanKey(com.hazelcast.sql.impl.optimizer.PlanKey) PlanCache(com.hazelcast.sql.impl.plan.cache.PlanCache) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

PlanKey (com.hazelcast.sql.impl.optimizer.PlanKey)7 SqlPlan (com.hazelcast.sql.impl.optimizer.SqlPlan)4 Test (org.junit.Test)4 PlanCache (com.hazelcast.sql.impl.plan.cache.PlanCache)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 QueryConvertResult (com.hazelcast.jet.sql.impl.parse.QueryConvertResult)2 SqlAlterJob (com.hazelcast.jet.sql.impl.parse.SqlAlterJob)2 SqlCreateIndex (com.hazelcast.jet.sql.impl.parse.SqlCreateIndex)2 SqlCreateJob (com.hazelcast.jet.sql.impl.parse.SqlCreateJob)2 SqlCreateMapping (com.hazelcast.jet.sql.impl.parse.SqlCreateMapping)2 SqlCreateSnapshot (com.hazelcast.jet.sql.impl.parse.SqlCreateSnapshot)2 SqlCreateView (com.hazelcast.jet.sql.impl.parse.SqlCreateView)2 SqlDropIndex (com.hazelcast.jet.sql.impl.parse.SqlDropIndex)2 SqlDropJob (com.hazelcast.jet.sql.impl.parse.SqlDropJob)2 SqlDropMapping (com.hazelcast.jet.sql.impl.parse.SqlDropMapping)2 SqlDropSnapshot (com.hazelcast.jet.sql.impl.parse.SqlDropSnapshot)2 SqlDropView (com.hazelcast.jet.sql.impl.parse.SqlDropView)2 SqlExplainStatement (com.hazelcast.jet.sql.impl.parse.SqlExplainStatement)2 SqlShowStatement (com.hazelcast.jet.sql.impl.parse.SqlShowStatement)2