Search in sources :

Example 1 with Execution

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution 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 Execution

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution 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 Execution

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution 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 Execution

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution 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 Execution

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution 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

SingleExecutionPlan (org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan)14 Test (org.junit.Test)14 PureModel (org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel)12 List (java.util.List)11 Service (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Service)11 MutableList (org.eclipse.collections.api.list.MutableList)9 GraphFetchCacheByEqualityKeys (org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys)9 PureModelContextData (org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData)9 PureSingleExecution (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureSingleExecution)8 ListIterate (org.eclipse.collections.impl.utility.ListIterate)7 Map (java.util.Map)6 Objects (java.util.Objects)6 Collectors (java.util.stream.Collectors)6 Result (org.finos.legend.engine.plan.execution.result.Result)6 ExecutionPlan (org.finos.legend.engine.protocol.pure.v1.model.executionPlan.ExecutionPlan)6 EngineRuntime (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime)6 Scope (io.opentracing.Scope)5 ServiceLoader (java.util.ServiceLoader)5 RichIterable (org.eclipse.collections.api.RichIterable)5 Lists (org.eclipse.collections.api.factory.Lists)5