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