Search in sources :

Example 1 with GraphFetchCacheByEqualityKeys

use of org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys in project legend-engine by finos.

the class TestPlanExecutionWithGraphFetchEqualityCache method testSimpleCacheWithToOneComplexPropertiesManyObjects.

@Test
public void testSimpleCacheWithToOneComplexPropertiesManyObjects() throws IOException, JavaCompileException {
    SingleExecutionPlan plan = readPlan("org/finos/legend/engine/plan/execution/stores/relational/test/cache/graphFetch//equalityCachePlanWithToOneComplexProperties.json");
    Map<String, ?> params = org.eclipse.collections.api.factory.Maps.mutable.of("count", 100);
    GraphFetchCacheByEqualityKeys personCache = ExecutionCacheBuilder.buildGraphFetchCacheByEqualityKeysFromGuavaCache(CacheBuilder.newBuilder().recordStats().expireAfterWrite(10, TimeUnit.MINUTES).build(), "meta::relational::tests::simpleRelationalMappingInc", "meta_pure_tests_model_simple_Person");
    String expectedRes = "{\"builder\":{\"_type\":\"json\"},\"values\":[{\"firstName\":\"Anthony\",\"lastName\":\"Allen\",\"firm\":{\"legalName\":\"FirmA\",\"address\":{\"name\":\"New York\"}}},{\"firstName\":\"Olivier\",\"lastName\":\"Doe\",\"firm\":{\"legalName\":\"FirmC\",\"address\":{\"name\":\"Tokyo\"}}},{\"firstName\":\"David\",\"lastName\":\"Harris\",\"firm\":{\"legalName\":\"FirmD\",\"address\":{\"name\":\"Mountain View\"}}},{\"firstName\":\"John\",\"lastName\":\"Hill\",\"firm\":{\"legalName\":\"FirmA\",\"address\":{\"name\":\"New York\"}}},{\"firstName\":\"John\",\"lastName\":\"Johnson\",\"firm\":{\"legalName\":\"FirmA\",\"address\":{\"name\":\"New York\"}}},{\"firstName\":\"Fabrice\",\"lastName\":\"Roberts\",\"firm\":{\"legalName\":\"FirmB\",\"address\":{\"name\":\"Cupertino\"}}},{\"firstName\":\"Peter\",\"lastName\":\"Smith\",\"firm\":{\"legalName\":\"FirmA\",\"address\":{\"name\":\"New York\"}}}]}";
    String expectedSubTree = "{firstName,lastName,firm{legalName,address{name}}}";
    assertCachingForAllObjects(plan, params, personCache, expectedRes, expectedSubTree, 7);
}
Also used : GraphFetchCacheByEqualityKeys(org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) Test(org.junit.Test)

Example 2 with GraphFetchCacheByEqualityKeys

use of org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys in project legend-engine by finos.

the class TestPlanExecutionWithGraphFetchEqualityCache method testSimpleCacheWithNoDepth.

@Test
public void testSimpleCacheWithNoDepth() throws IOException, JavaCompileException {
    SingleExecutionPlan plan = readPlan("org/finos/legend/engine/plan/execution/stores/relational/test/cache/graphFetch//equalityCachePlanWithNoDepth.json");
    Map<String, ?> params = org.eclipse.collections.api.factory.Maps.mutable.of("count", 1);
    GraphFetchCacheByEqualityKeys personCache = ExecutionCacheBuilder.buildGraphFetchCacheByEqualityKeysFromGuavaCache(CacheBuilder.newBuilder().recordStats().expireAfterWrite(10, TimeUnit.MINUTES).build(), "meta::relational::tests::simpleRelationalMappingInc", "meta_pure_tests_model_simple_Person");
    String expectedRes = "{\"builder\":{\"_type\":\"json\"},\"values\":{\"firstName\":\"Anthony\",\"lastName\":\"Allen\"}}";
    String expectedSubTree = "{firstName,lastName}";
    assertCachingForAllObjects(plan, params, personCache, expectedRes, expectedSubTree, 1);
}
Also used : GraphFetchCacheByEqualityKeys(org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) Test(org.junit.Test)

Example 3 with GraphFetchCacheByEqualityKeys

use of org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys in project legend-engine by finos.

the class TestPlanExecutionWithGraphFetchEqualityCache method testUnUtilizedCache.

@Test
public void testUnUtilizedCache() throws IOException, JavaCompileException {
    String expectedRes = "{\"builder\":{\"_type\":\"json\"},\"values\":{\"legalName\":\"FirmA\",\"employees\":[{\"firstName\":\"Peter\",\"lastName\":\"Smith\"},{\"firstName\":\"John\",\"lastName\":\"Johnson\"},{\"firstName\":\"John\",\"lastName\":\"Hill\"},{\"firstName\":\"Anthony\",\"lastName\":\"Allen\"}]}}";
    SingleExecutionPlan plan = readPlan("org/finos/legend/engine/plan/execution/stores/relational/test/cache/graphFetch//equalityCachePlanWithToManyComplexProperties.json");
    GraphFetchCacheByEqualityKeys personCache = ExecutionCacheBuilder.buildGraphFetchCacheByEqualityKeysFromGuavaCache(CacheBuilder.newBuilder().recordStats().expireAfterWrite(10, TimeUnit.MINUTES).build(), "meta::relational::tests::simpleRelationalMappingInc", "meta_pure_tests_model_simple_Person");
    PlanExecutionContext planExecutionContext = new PlanExecutionContext(plan, personCache);
    JsonStreamingResult result = (JsonStreamingResult) planExecutor.execute(plan, Collections.emptyMap(), null, planExecutionContext);
    String res = result.flush(new JsonStreamToJsonDefaultSerializer(result));
    Assert.assertEquals(expectedRes, res);
    Assert.assertFalse(personCache.isCacheUtilized());
    Assert.assertEquals(0, personCache.getExecutionCache().estimatedSize());
    Assert.assertEquals(0, personCache.getExecutionCache().stats().requestCount());
    Assert.assertEquals(0, personCache.getExecutionCache().stats().hitCount());
    Assert.assertEquals(0, personCache.getExecutionCache().stats().missCount());
}
Also used : JsonStreamingResult(org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult) GraphFetchCacheByEqualityKeys(org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) PlanExecutionContext(org.finos.legend.engine.plan.execution.PlanExecutionContext) JsonStreamToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer) Test(org.junit.Test)

Example 4 with GraphFetchCacheByEqualityKeys

use of org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys in project legend-engine by finos.

the class TestPlanExecutionWithGraphFetchEqualityCache method testSimpleCacheWithToOneComplexProperties.

@Test
public void testSimpleCacheWithToOneComplexProperties() throws IOException, JavaCompileException {
    SingleExecutionPlan plan = readPlan("org/finos/legend/engine/plan/execution/stores/relational/test/cache/graphFetch//equalityCachePlanWithToOneComplexProperties.json");
    Map<String, ?> params = org.eclipse.collections.api.factory.Maps.mutable.of("count", 1);
    GraphFetchCacheByEqualityKeys personCache = ExecutionCacheBuilder.buildGraphFetchCacheByEqualityKeysFromGuavaCache(CacheBuilder.newBuilder().recordStats().expireAfterWrite(10, TimeUnit.MINUTES).build(), "meta::relational::tests::simpleRelationalMappingInc", "meta_pure_tests_model_simple_Person");
    String expectedRes = "{\"builder\":{\"_type\":\"json\"},\"values\":{\"firstName\":\"Anthony\",\"lastName\":\"Allen\",\"firm\":{\"legalName\":\"FirmA\",\"address\":{\"name\":\"New York\"}}}}";
    String expectedSubTree = "{firstName,lastName,firm{legalName,address{name}}}";
    assertCachingForAllObjects(plan, params, personCache, expectedRes, expectedSubTree, 1);
}
Also used : GraphFetchCacheByEqualityKeys(org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) Test(org.junit.Test)

Example 5 with GraphFetchCacheByEqualityKeys

use of org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys in project legend-engine by finos.

the class TestPlanExecutionWithGraphFetchEqualityCache method testSimpleCacheWithToManyComplexProperties.

@Test
public void testSimpleCacheWithToManyComplexProperties() throws IOException, JavaCompileException {
    SingleExecutionPlan plan = readPlan("org/finos/legend/engine/plan/execution/stores/relational/test/cache/graphFetch//equalityCachePlanWithToManyComplexProperties.json");
    Map<String, ?> params = Collections.emptyMap();
    GraphFetchCacheByEqualityKeys firmCache = ExecutionCacheBuilder.buildGraphFetchCacheByEqualityKeysFromGuavaCache(CacheBuilder.newBuilder().recordStats().expireAfterWrite(10, TimeUnit.MINUTES).build(), "meta::relational::tests::simpleRelationalMappingInc", "meta_pure_tests_model_simple_Firm");
    String expectedRes = "{\"builder\":{\"_type\":\"json\"},\"values\":{\"legalName\":\"FirmA\",\"employees\":[{\"firstName\":\"Peter\",\"lastName\":\"Smith\"},{\"firstName\":\"John\",\"lastName\":\"Johnson\"},{\"firstName\":\"John\",\"lastName\":\"Hill\"},{\"firstName\":\"Anthony\",\"lastName\":\"Allen\"}]}}";
    String expectedSubTree = "{legalName,employees{firstName,lastName}}";
    assertCachingForAllObjects(plan, params, firmCache, expectedRes, expectedSubTree, 1);
}
Also used : GraphFetchCacheByEqualityKeys(org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) Test(org.junit.Test)

Aggregations

GraphFetchCacheByEqualityKeys (org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys)11 SingleExecutionPlan (org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan)8 Test (org.junit.Test)8 ResultSet (java.sql.ResultSet)2 PlanExecutionContext (org.finos.legend.engine.plan.execution.PlanExecutionContext)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Scope (io.opentracing.Scope)1 Span (io.opentracing.Span)1 GlobalTracer (io.opentracing.util.GlobalTracer)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 java.util (java.util)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1