diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/GraphServer.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/GraphServer.java index ceb542a84c77..d8bafa8cd5bc 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/GraphServer.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/GraphServer.java @@ -82,15 +82,16 @@ public GraphServer( public void start() throws Exception { ExecutionClient executionClient = ExecutionClient.Factory.create(configs, channelFetcher); QueryIdGenerator idGenerator = new QueryIdGenerator(configs); + QueryCache queryCache = new QueryCache(configs); if (!FrontendConfig.GREMLIN_SERVER_DISABLED.get(configs)) { GraphPlanner graphPlanner = new GraphPlanner(configs, new LogicalPlanFactory.Gremlin(), optimizer); - QueryCache queryCache = new QueryCache(configs, graphPlanner); this.gremlinServer = new IrGremlinServer( configs, idGenerator, queryCache, + graphPlanner, executionClient, channelFetcher, metaQueryCallback, @@ -100,10 +101,14 @@ public void start() throws Exception { if (!FrontendConfig.NEO4J_BOLT_SERVER_DISABLED.get(configs)) { GraphPlanner graphPlanner = new GraphPlanner(configs, new LogicalPlanFactory.Cypher(), optimizer); - QueryCache queryCache = new QueryCache(configs, graphPlanner); this.cypherBootstrapper = new CypherBootstrapper( - configs, idGenerator, metaQueryCallback, executionClient, queryCache); + configs, + idGenerator, + metaQueryCallback, + executionClient, + queryCache, + graphPlanner); Path neo4jHomePath = getNeo4jHomePath(); this.cypherBootstrapper.start( neo4jHomePath, diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphPlanner.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphPlanner.java index 358b6e7f3bf1..cb69a5d6f987 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphPlanner.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphPlanner.java @@ -93,20 +93,34 @@ public PlannerInstance instance(String query, IrMeta irMeta) { if (mq != null) { optCluster.setMetadataQuerySupplier(() -> mq); } - return new PlannerInstance(query, optCluster, irMeta); + // build logical plan from parsed query + IrGraphSchema schema = irMeta.getSchema(); + GraphBuilder graphBuilder = + GraphBuilder.create( + graphConfig, optCluster, new GraphOptSchema(optCluster, schema)); + + LogicalPlan logicalPlan = logicalPlanFactory.create(graphBuilder, irMeta, query); + return new PlannerInstance(query, logicalPlan, graphBuilder, irMeta); } public class PlannerInstance { private final String query; - private final GraphOptCluster optCluster; + private final LogicalPlan parsedPlan; + private final GraphBuilder graphBuilder; private final IrMeta irMeta; - public PlannerInstance(String query, GraphOptCluster optCluster, IrMeta irMeta) { + public PlannerInstance( + String query, LogicalPlan parsedPlan, GraphBuilder graphBuilder, IrMeta irMeta) { this.query = query; - this.optCluster = optCluster; + this.parsedPlan = parsedPlan; + this.graphBuilder = graphBuilder; this.irMeta = irMeta; } + public LogicalPlan getParsedPlan() { + return parsedPlan; + } + public Summary plan() { LogicalPlan logicalPlan = ClassUtils.callException(() -> planLogical(), Code.LOGICAL_PLAN_BUILD_FAILED); @@ -117,16 +131,7 @@ public Summary plan() { } public LogicalPlan planLogical() { - // build logical plan from parsed query - IrGraphSchema schema = irMeta.getSchema(); - GraphBuilder graphBuilder = - GraphBuilder.create( - graphConfig, - this.optCluster, - new GraphOptSchema(this.optCluster, schema)); - - LogicalPlan logicalPlan = logicalPlanFactory.create(graphBuilder, irMeta, query); - + LogicalPlan logicalPlan = parsedPlan; // apply optimizations if (logicalPlan.getRegularQuery() != null && !logicalPlan.isReturnEmpty()) { RelNode before = logicalPlan.getRegularQuery(); diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/LogicalPlan.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/LogicalPlan.java index 74854cff7266..bfb214e9d7bd 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/LogicalPlan.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/LogicalPlan.java @@ -22,7 +22,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import org.apache.calcite.plan.RelDigest; import org.apache.calcite.rel.RelNode; import org.apache.calcite.rel.logical.LogicalValues; import org.apache.calcite.rel.type.RelDataType; @@ -136,7 +135,7 @@ public int hashCode() { return Objects.hash(getDigest(regularQuery), procedureCall, returnEmpty, dynamicParams); } - private RelDigest getDigest(RelNode rel) { - return rel == null ? null : rel.getRelDigest(); + private String getDigest(RelNode rel) { + return rel == null ? null : rel.explain(); } } diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/QueryCache.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/QueryCache.java index 7832667722df..53775fbdb0b5 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/QueryCache.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/QueryCache.java @@ -18,8 +18,6 @@ import com.alibaba.graphscope.common.config.Configs; import com.alibaba.graphscope.common.config.FrontendConfig; -import com.alibaba.graphscope.common.ir.meta.IrMeta; -import com.alibaba.graphscope.common.ir.runtime.PhysicalPlan; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -32,34 +30,22 @@ public class QueryCache { private final LoadingCache cache; - private final GraphPlanner graphPlanner; - public QueryCache(Configs configs, GraphPlanner graphPlanner) { - this.graphPlanner = graphPlanner; + public QueryCache(Configs configs) { int cacheSize = FrontendConfig.QUERY_CACHE_SIZE.get(configs); this.cache = CacheBuilder.newBuilder() .maximumSize(cacheSize) - .build( - CacheLoader.from( - key -> { - PhysicalPlan physicalPlan = - key.plannerInstance.planPhysical( - key.logicalPlan); - GraphPlanner.Summary summary = - new GraphPlanner.Summary( - key.logicalPlan, physicalPlan); - return new Value(summary, null); - })); + .build(CacheLoader.from(key -> new Value(key.instance.plan(), null))); } public class Key { - public final GraphPlanner.PlannerInstance plannerInstance; + public final GraphPlanner.PlannerInstance instance; public final LogicalPlan logicalPlan; - public Key(String query, IrMeta irMeta) { - this.plannerInstance = Objects.requireNonNull(graphPlanner.instance(query, irMeta)); - this.logicalPlan = Objects.requireNonNull(this.plannerInstance.planLogical()); + public Key(GraphPlanner.PlannerInstance instance) { + this.instance = instance; + this.logicalPlan = instance.getParsedPlan(); } @Override @@ -76,8 +62,8 @@ public int hashCode() { } } - public Key createKey(String query, IrMeta irMeta) { - return new Key(query, irMeta); + public Key createKey(GraphPlanner.PlannerInstance instance) { + return new Key(instance); } public static class Value { diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/executor/GraphQueryExecutor.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/executor/GraphQueryExecutor.java index a837c8f7b141..f3b07b1f8780 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/executor/GraphQueryExecutor.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/executor/GraphQueryExecutor.java @@ -64,6 +64,7 @@ public class GraphQueryExecutor extends FabricExecutor { private final QueryIdGenerator idGenerator; private final FabricConfig fabricConfig; private final QueryCache queryCache; + private final GraphPlanner graphPlanner; public GraphQueryExecutor( FabricConfig config, @@ -77,7 +78,8 @@ public GraphQueryExecutor( QueryIdGenerator idGenerator, IrMetaQueryCallback metaQueryCallback, ExecutionClient client, - QueryCache queryCache) { + QueryCache queryCache, + GraphPlanner graphPlanner) { super( config, planner, @@ -92,6 +94,7 @@ public GraphQueryExecutor( this.metaQueryCallback = metaQueryCallback; this.client = client; this.queryCache = queryCache; + this.graphPlanner = graphPlanner; } /** @@ -124,7 +127,8 @@ public StatementResult run( return super.run(fabricTransaction, statement, parameters); } irMeta = metaQueryCallback.beforeExec(); - QueryCache.Key cacheKey = queryCache.createKey(statement, irMeta); + QueryCache.Key cacheKey = + queryCache.createKey(graphPlanner.instance(statement, irMeta)); QueryCache.Value cacheValue = queryCache.get(cacheKey); Preconditions.checkArgument( cacheValue != null, diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/service/CypherBootstrapper.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/service/CypherBootstrapper.java index 768c8a0bbce3..188af4a8741b 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/service/CypherBootstrapper.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/service/CypherBootstrapper.java @@ -18,6 +18,7 @@ import com.alibaba.graphscope.common.client.ExecutionClient; import com.alibaba.graphscope.common.config.Configs; +import com.alibaba.graphscope.common.ir.tools.GraphPlanner; import com.alibaba.graphscope.common.ir.tools.QueryCache; import com.alibaba.graphscope.common.ir.tools.QueryIdGenerator; import com.alibaba.graphscope.common.manager.IrMetaQueryCallback; @@ -55,18 +56,20 @@ public CypherBootstrapper( QueryIdGenerator idGenerator, IrMetaQueryCallback queryCallback, ExecutionClient client, - QueryCache queryCache) { + QueryCache queryCache, + GraphPlanner graphPlanner) { this.client = client; this.externalDependencies = createExternalDependencies( - graphConfig, idGenerator, queryCallback, client, queryCache); + graphConfig, idGenerator, queryCallback, client, queryCache, graphPlanner); this.externalClassTypes = Arrays.asList( Configs.class, QueryIdGenerator.class, IrMetaQueryCallback.class, ExecutionClient.class, - QueryCache.class); + QueryCache.class, + GraphPlanner.class); } @Override @@ -94,9 +97,11 @@ private Dependencies createExternalDependencies( QueryIdGenerator idGenerator, IrMetaQueryCallback queryCallback, ExecutionClient client, - QueryCache queryCache) { + QueryCache queryCache, + GraphPlanner graphPlanner) { Dependencies dependencies = new Dependencies(); - dependencies.satisfyDependencies(configs, idGenerator, queryCallback, client, queryCache); + dependencies.satisfyDependencies( + configs, idGenerator, queryCallback, client, queryCache, graphPlanner); return dependencies; } diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/service/CypherQueryServiceBootstrap.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/service/CypherQueryServiceBootstrap.java index 38700b7cb3db..4539527c5c04 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/service/CypherQueryServiceBootstrap.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/service/CypherQueryServiceBootstrap.java @@ -22,6 +22,7 @@ import com.alibaba.graphscope.common.client.ExecutionClient; import com.alibaba.graphscope.common.config.Configs; +import com.alibaba.graphscope.common.ir.tools.GraphPlanner; import com.alibaba.graphscope.common.ir.tools.QueryCache; import com.alibaba.graphscope.common.ir.tools.QueryIdGenerator; import com.alibaba.graphscope.common.manager.IrMetaQueryCallback; @@ -164,6 +165,7 @@ public void bootstrapServices() { var metaQueryCallback = (IrMetaQueryCallback) resolve(IrMetaQueryCallback.class); var executionClient = (ExecutionClient) resolve(ExecutionClient.class); var queryCache = (QueryCache) resolve(QueryCache.class); + var graphPlanner = (GraphPlanner) resolve(GraphPlanner.class); var fabricExecutor = new GraphQueryExecutor( fabricConfig, @@ -177,7 +179,8 @@ public void bootstrapServices() { idGenerator, metaQueryCallback, executionClient, - queryCache); + queryCache, + graphPlanner); register(fabricExecutor, FabricExecutor.class); register( diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/processor/IrTestOpProcessor.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/processor/IrTestOpProcessor.java index 8d3ec28088b6..6a3eee75c803 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/processor/IrTestOpProcessor.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/processor/IrTestOpProcessor.java @@ -74,6 +74,7 @@ public IrTestOpProcessor( Configs configs, QueryIdGenerator idGenerator, QueryCache queryCache, + GraphPlanner graphPlanner, ExecutionClient executionClient, ChannelFetcher fetcher, IrMetaQueryCallback metaQueryCallback, @@ -84,6 +85,7 @@ public IrTestOpProcessor( configs, idGenerator, queryCache, + graphPlanner, executionClient, fetcher, metaQueryCallback, @@ -157,7 +159,9 @@ public ThrowingConsumer select(Context ctx) { break; case GremlinCalciteScriptEngineFactory.LANGUAGE_NAME: QueryCache.Value value = - queryCache.get(queryCache.createKey(script, irMeta)); + queryCache.get( + queryCache.createKey( + graphPlanner.instance(script, irMeta))); GraphPlanner.Summary summary = value.summary; ResultSchema resultSchema = new ResultSchema(summary.getLogicalPlan()); diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/IrStandardOpProcessor.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/IrStandardOpProcessor.java index 646c6bfa987f..a297e0451864 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/IrStandardOpProcessor.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/IrStandardOpProcessor.java @@ -35,6 +35,7 @@ import com.alibaba.graphscope.common.exception.FrontendException; import com.alibaba.graphscope.common.intermediate.InterOpCollection; import com.alibaba.graphscope.common.ir.meta.IrMeta; +import com.alibaba.graphscope.common.ir.tools.GraphPlanner; import com.alibaba.graphscope.common.ir.tools.QueryCache; import com.alibaba.graphscope.common.ir.tools.QueryIdGenerator; import com.alibaba.graphscope.common.manager.IrMetaQueryCallback; @@ -109,6 +110,7 @@ public class IrStandardOpProcessor extends StandardOpProcessor { protected final IrMetaQueryCallback metaQueryCallback; protected final QueryIdGenerator idGenerator; protected final QueryCache queryCache; + protected final GraphPlanner graphPlanner; protected final ExecutionClient executionClient; protected Tracer tracer; protected LongHistogram queryHistogram; @@ -124,6 +126,7 @@ public IrStandardOpProcessor( Configs configs, QueryIdGenerator idGenerator, QueryCache queryCache, + GraphPlanner graphPlanner, ExecutionClient executionClient, ChannelFetcher fetcher, IrMetaQueryCallback metaQueryCallback, @@ -143,6 +146,7 @@ public IrStandardOpProcessor( this.metaQueryCallback = metaQueryCallback; this.idGenerator = idGenerator; this.queryCache = queryCache; + this.graphPlanner = graphPlanner; this.executionClient = executionClient; this.printThreshold = FrontendConfig.QUERY_PRINT_THRESHOLD_MS.get(configs); this.opentelemetryIdGenerator = IdGenerator.random(); @@ -215,6 +219,7 @@ protected void evalOpInternal( configs, ctx, queryCache, + graphPlanner, executionClient, jobId, jobName, diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/LifeCycleSupplier.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/LifeCycleSupplier.java index 3a46c6fa408c..2b21ef46d244 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/LifeCycleSupplier.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/LifeCycleSupplier.java @@ -40,6 +40,7 @@ public class LifeCycleSupplier implements Supplier { private final Configs configs; private final QueryCache queryCache; + private final GraphPlanner graphPlanner; private final ExecutionClient client; private final Context ctx; private final BigInteger queryId; @@ -52,6 +53,7 @@ public LifeCycleSupplier( Configs configs, Context ctx, QueryCache queryCache, + GraphPlanner graphPlanner, ExecutionClient client, BigInteger queryId, String queryName, @@ -61,6 +63,7 @@ public LifeCycleSupplier( this.configs = configs; this.ctx = ctx; this.queryCache = queryCache; + this.graphPlanner = graphPlanner; this.client = client; this.queryId = queryId; this.queryName = queryName; @@ -76,6 +79,7 @@ public GremlinExecutor.LifeCycle get() { .beforeEval( b -> { b.put("graph.query.cache", queryCache); + b.put("graph.planner", graphPlanner); b.put("graph.meta", meta); }) .withResult( diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/script/GremlinCalciteScriptEngineFactory.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/script/GremlinCalciteScriptEngineFactory.java index 19d87863fd50..6398e88340b3 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/script/GremlinCalciteScriptEngineFactory.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/script/GremlinCalciteScriptEngineFactory.java @@ -18,6 +18,7 @@ import com.alibaba.graphscope.common.exception.FrontendException; import com.alibaba.graphscope.common.ir.meta.IrMeta; +import com.alibaba.graphscope.common.ir.tools.GraphPlanner; import com.alibaba.graphscope.common.ir.tools.QueryCache; import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinScriptEngineFactory; @@ -69,8 +70,10 @@ public Object eval(String script, ScriptContext ctx) throws ScriptException { try { Bindings globalBindings = ctx.getBindings(ScriptContext.ENGINE_SCOPE); QueryCache queryCache = (QueryCache) globalBindings.get("graph.query.cache"); + GraphPlanner graphPlanner = (GraphPlanner) globalBindings.get("graph.planner"); IrMeta irMeta = (IrMeta) globalBindings.get("graph.meta"); - QueryCache.Key cacheKey = queryCache.createKey(script, irMeta); + QueryCache.Key cacheKey = + queryCache.createKey(graphPlanner.instance(script, irMeta)); return queryCache.get(cacheKey); } catch (FrontendException e) { throw e; diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/service/IrGremlinServer.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/service/IrGremlinServer.java index cd7744b0ec1d..8e3659e16f5c 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/service/IrGremlinServer.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/service/IrGremlinServer.java @@ -20,6 +20,7 @@ import com.alibaba.graphscope.common.client.channel.ChannelFetcher; import com.alibaba.graphscope.common.config.Configs; import com.alibaba.graphscope.common.config.FrontendConfig; +import com.alibaba.graphscope.common.ir.tools.GraphPlanner; import com.alibaba.graphscope.common.ir.tools.QueryCache; import com.alibaba.graphscope.common.ir.tools.QueryIdGenerator; import com.alibaba.graphscope.common.manager.IrMetaQueryCallback; @@ -49,6 +50,7 @@ public class IrGremlinServer implements AutoCloseable { private final Configs configs; private final QueryCache queryCache; + private final GraphPlanner graphPlanner; private final ExecutionClient executionClient; private final ChannelFetcher channelFetcher; private final IrMetaQueryCallback metaQueryCallback; @@ -65,6 +67,7 @@ public IrGremlinServer( Configs configs, QueryIdGenerator idGenerator, QueryCache queryCache, + GraphPlanner graphPlanner, ExecutionClient executionClient, ChannelFetcher channelFetcher, IrMetaQueryCallback metaQueryCallback, @@ -72,6 +75,7 @@ public IrGremlinServer( this.configs = configs; this.idGenerator = idGenerator; this.queryCache = queryCache; + this.graphPlanner = graphPlanner; this.executionClient = executionClient; this.channelFetcher = channelFetcher; this.metaQueryCallback = metaQueryCallback; @@ -95,6 +99,7 @@ public void start() throws Exception { configs, idGenerator, queryCache, + graphPlanner, executionClient, channelFetcher, metaQueryCallback, @@ -106,6 +111,7 @@ public void start() throws Exception { configs, idGenerator, queryCache, + graphPlanner, executionClient, channelFetcher, metaQueryCallback, diff --git a/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/common/ir/QueryCacheTest.java b/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/common/ir/QueryCacheTest.java index f2b7d0f4258e..45f8ef0395c3 100644 --- a/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/common/ir/QueryCacheTest.java +++ b/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/common/ir/QueryCacheTest.java @@ -34,15 +34,21 @@ public void query_cache_1_test() { GraphPlanner graphPlanner = new GraphPlanner( configs, new LogicalPlanFactory.Cypher(), new GraphRelOptimizer(configs)); - QueryCache cache = new QueryCache(configs, graphPlanner); - QueryCache.Key key1 = cache.createKey("Match (n {name: 'ma'}) Return n", Utils.schemaMeta); + QueryCache cache = new QueryCache(configs); + QueryCache.Key key1 = + cache.createKey( + graphPlanner.instance("Match (n {name: 'ma'}) Return n", Utils.schemaMeta)); Assert.assertEquals( "GraphLogicalProject(n=[n], isAppend=[false])\n" + " GraphLogicalSource(tableConfig=[{isAll=true, tables=[software, person]}]," + " alias=[n], fusedFilter=[[=(_.name, _UTF-8'ma')]], opt=[VERTEX])", key1.logicalPlan.explain().trim()); - QueryCache.Key key2 = cache.createKey("Match (n {name: 'ma'}) Return n", Utils.schemaMeta); - QueryCache.Key key3 = cache.createKey("Match (n {age: 10}) Return n", Utils.schemaMeta); + QueryCache.Key key2 = + cache.createKey( + graphPlanner.instance("Match (n {name: 'ma'}) Return n", Utils.schemaMeta)); + QueryCache.Key key3 = + cache.createKey( + graphPlanner.instance("Match (n {age: 10}) Return n", Utils.schemaMeta)); Assert.assertEquals(key1, key2); Assert.assertNotEquals(key1, key3); } @@ -54,10 +60,16 @@ public void query_cache_2_test() throws Exception { GraphPlanner graphPlanner = new GraphPlanner( configs, new LogicalPlanFactory.Cypher(), new GraphRelOptimizer(configs)); - QueryCache cache = new QueryCache(configs, graphPlanner); - QueryCache.Key key1 = cache.createKey("Match (n {name: 'ma'}) Return n", Utils.schemaMeta); - QueryCache.Key key2 = cache.createKey("Match (n {age: 10}) Return n", Utils.schemaMeta); - QueryCache.Key key3 = cache.createKey("Match (n {name: 'ma'}) Return n", Utils.schemaMeta); + QueryCache cache = new QueryCache(configs); + QueryCache.Key key1 = + cache.createKey( + graphPlanner.instance("Match (n {name: 'ma'}) Return n", Utils.schemaMeta)); + QueryCache.Key key2 = + cache.createKey( + graphPlanner.instance("Match (n {age: 10}) Return n", Utils.schemaMeta)); + QueryCache.Key key3 = + cache.createKey( + graphPlanner.instance("Match (n {name: 'ma'}) Return n", Utils.schemaMeta)); QueryCache.Value value1 = cache.get(key1); QueryCache.Value value2 = cache.get(key2); QueryCache.Value value3 = cache.get(key3);