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());
}
Aggregations