Search in sources :

Example 1 with FragmentResultCacheContext

use of com.facebook.presto.execution.FragmentResultCacheContext in project presto by prestodb.

the class TestLocalExecutionPlanner method testCreatingFragmentResultCacheContext.

@Test
public void testCreatingFragmentResultCacheContext() {
    Session session = Session.builder(runner.getDefaultSession()).setSystemProperty(FRAGMENT_RESULT_CACHING_ENABLED, "true").build();
    LocalExecutionPlan planWithoutIntermediateAggregation = getLocalExecutionPlan(session);
    // Expect one driver factory: partial aggregation
    assertEquals(planWithoutIntermediateAggregation.getDriverFactories().size(), 1);
    Optional<FragmentResultCacheContext> contextWithoutIntermediateAggregation = planWithoutIntermediateAggregation.getDriverFactories().get(0).getFragmentResultCacheContext();
    assertTrue(contextWithoutIntermediateAggregation.isPresent());
    session = Session.builder(runner.getDefaultSession()).setSystemProperty(FRAGMENT_RESULT_CACHING_ENABLED, "true").setSystemProperty(ENABLE_INTERMEDIATE_AGGREGATIONS, "true").build();
    LocalExecutionPlan planWithIntermediateAggregation = getLocalExecutionPlan(session);
    // Expect twp driver factories: partial aggregation and intermediate aggregation
    assertEquals(planWithIntermediateAggregation.getDriverFactories().size(), 2);
    Optional<FragmentResultCacheContext> contextWithIntermediateAggregation = planWithIntermediateAggregation.getDriverFactories().get(0).getFragmentResultCacheContext();
    assertTrue(contextWithIntermediateAggregation.isPresent());
    assertEquals(contextWithIntermediateAggregation.get().getHashedCanonicalPlanFragment(), contextWithoutIntermediateAggregation.get().getHashedCanonicalPlanFragment());
}
Also used : LocalExecutionPlan(com.facebook.presto.sql.planner.LocalExecutionPlanner.LocalExecutionPlan) FragmentResultCacheContext(com.facebook.presto.execution.FragmentResultCacheContext) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Aggregations

Session (com.facebook.presto.Session)1 FragmentResultCacheContext (com.facebook.presto.execution.FragmentResultCacheContext)1 LocalExecutionPlan (com.facebook.presto.sql.planner.LocalExecutionPlanner.LocalExecutionPlan)1 Test (org.testng.annotations.Test)1