Search in sources :

Example 1 with PureGraphCache

use of org.finos.legend.pure.m3.serialization.runtime.cache.PureGraphCache in project legend-pure by finos.

the class TestGraphIsSerialized method testInitializedFromGraphLoaderSerialization.

@Test
public void testInitializedFromGraphLoaderSerialization() {
    PureRuntime runtime = new PureRuntimeBuilder(getCodeStorage()).buildAndInitialize();
    PureGraphCache cache = new MemoryGraphLoaderPureGraphCache();
    cache.setPureRuntime(runtime);
    cache.cacheRepoAndSources();
    runtime = new PureRuntimeBuilder(getCodeStorage()).withCache(cache).buildAndTryToInitializeFromCache();
    new FunctionExecutionCompiledBuilder().build().init(runtime, new Message(""));
    Assert.assertTrue(cache.getCacheState().getLastStackTrace(), runtime.isInitialized());
    assertAllInstancesMarkedSerialized(runtime);
}
Also used : PureRuntime(org.finos.legend.pure.m3.serialization.runtime.PureRuntime) FunctionExecutionCompiledBuilder(org.finos.legend.pure.runtime.java.compiled.execution.FunctionExecutionCompiledBuilder) Message(org.finos.legend.pure.m3.serialization.runtime.Message) PureRuntimeBuilder(org.finos.legend.pure.m3.serialization.runtime.PureRuntimeBuilder) PureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.PureGraphCache) MemoryPureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.MemoryPureGraphCache) MemoryGraphLoaderPureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.MemoryGraphLoaderPureGraphCache) MemoryGraphLoaderPureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.MemoryGraphLoaderPureGraphCache) Test(org.junit.Test)

Example 2 with PureGraphCache

use of org.finos.legend.pure.m3.serialization.runtime.cache.PureGraphCache in project legend-pure by finos.

the class TestGraphIsSerialized method testInitializedFromM4Serialization.

@Test
public void testInitializedFromM4Serialization() {
    PureRuntime runtime = new PureRuntimeBuilder(getCodeStorage()).buildAndInitialize();
    PureGraphCache cache = new MemoryPureGraphCache();
    cache.setPureRuntime(runtime);
    cache.cacheRepoAndSources();
    runtime = new PureRuntimeBuilder(getCodeStorage()).withCache(cache).buildAndTryToInitializeFromCache();
    new FunctionExecutionCompiledBuilder().build().init(runtime, new Message(""));
    Assert.assertTrue(cache.getCacheState().getLastStackTrace(), runtime.isInitialized());
    assertAllInstancesMarkedSerialized(runtime);
}
Also used : PureRuntime(org.finos.legend.pure.m3.serialization.runtime.PureRuntime) FunctionExecutionCompiledBuilder(org.finos.legend.pure.runtime.java.compiled.execution.FunctionExecutionCompiledBuilder) Message(org.finos.legend.pure.m3.serialization.runtime.Message) MemoryPureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.MemoryPureGraphCache) PureRuntimeBuilder(org.finos.legend.pure.m3.serialization.runtime.PureRuntimeBuilder) PureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.PureGraphCache) MemoryPureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.MemoryPureGraphCache) MemoryGraphLoaderPureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.MemoryGraphLoaderPureGraphCache) Test(org.junit.Test)

Example 3 with PureGraphCache

use of org.finos.legend.pure.m3.serialization.runtime.cache.PureGraphCache in project legend-pure by finos.

the class TestPureRuntime method testInstancesInContextDuringCaching.

@Test
public void testInstancesInContextDuringCaching() {
    MutableCodeStorage codeStorage = new PureCodeStorage(Paths.get("..", "pure-code", "local"), new ClassLoaderCodeStorage(CodeRepository.newPlatformCodeRepository()));
    PureGraphCache cache = new CompressedMemoryPureGraphCache();
    Assert.assertFalse(cache.getCacheState().isCached());
    PureRuntime runtime = new PureRuntimeBuilder(codeStorage).withCache(cache).buildAndTryToInitializeFromCache();
    runtime.loadAndCompileCore();
    cache.cacheRepoAndSources();
    Assert.assertTrue(cache.getCacheState().isCached());
    Assert.assertTrue(cache.getCacheState().getCurrentCacheSize() > 0);
    PureRuntime newRuntime = new PureRuntimeBuilder(codeStorage).withCache(cache).buildAndTryToInitializeFromCache();
    Assert.assertEquals(runtime.getContext().getAllInstances().collect(CoreInstance.GET_NAME).toSortedList(), newRuntime.getContext().getAllInstances().collect(CoreInstance.GET_NAME).toSortedList());
}
Also used : MutableCodeStorage(org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.MutableCodeStorage) ClassLoaderCodeStorage(org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.classpath.ClassLoaderCodeStorage) CompressedMemoryPureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.CompressedMemoryPureGraphCache) CompressedMemoryPureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.CompressedMemoryPureGraphCache) PureGraphCache(org.finos.legend.pure.m3.serialization.runtime.cache.PureGraphCache) PureCodeStorage(org.finos.legend.pure.m3.serialization.filesystem.PureCodeStorage) Test(org.junit.Test)

Aggregations

PureGraphCache (org.finos.legend.pure.m3.serialization.runtime.cache.PureGraphCache)3 Test (org.junit.Test)3 Message (org.finos.legend.pure.m3.serialization.runtime.Message)2 PureRuntime (org.finos.legend.pure.m3.serialization.runtime.PureRuntime)2 PureRuntimeBuilder (org.finos.legend.pure.m3.serialization.runtime.PureRuntimeBuilder)2 MemoryGraphLoaderPureGraphCache (org.finos.legend.pure.m3.serialization.runtime.cache.MemoryGraphLoaderPureGraphCache)2 MemoryPureGraphCache (org.finos.legend.pure.m3.serialization.runtime.cache.MemoryPureGraphCache)2 FunctionExecutionCompiledBuilder (org.finos.legend.pure.runtime.java.compiled.execution.FunctionExecutionCompiledBuilder)2 PureCodeStorage (org.finos.legend.pure.m3.serialization.filesystem.PureCodeStorage)1 MutableCodeStorage (org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.MutableCodeStorage)1 ClassLoaderCodeStorage (org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.classpath.ClassLoaderCodeStorage)1 CompressedMemoryPureGraphCache (org.finos.legend.pure.m3.serialization.runtime.cache.CompressedMemoryPureGraphCache)1