From 86dd6b1b1a1bcade9ee00254583ff14cdd99b3ac Mon Sep 17 00:00:00 2001 From: fickludd Date: Wed, 23 May 2018 14:31:55 +0200 Subject: [PATCH] Rename *Compatibility* to *Compiler* --- .../internal/javacompat/ExecutionEngine.java | 6 +- .../javacompat/SnapshotExecutionEngine.java | 8 +-- ...y.scala => CacheableExecutableQuery.scala} | 6 +- .../org/neo4j/cypher/internal/Compiler.scala | 2 +- .../internal/CompilerEngineDelegator.scala | 26 +++---- ...ilityCache.scala => CompilerLibrary.scala} | 71 +++++++------------ .../cypher/internal/ExecutionEngine.scala | 12 ++-- .../neo4j/cypher/internal/QueryCache.scala | 2 +- ...mpatibility.scala => Cost23Compiler.scala} | 14 ++-- ...atibility.scala => Cypher23Compiler.scala} | 6 +- ...mpatibility.scala => Rule23Compiler.scala} | 8 +-- ...mpatibility.scala => Cost31Compiler.scala} | 16 ++--- ...atibility.scala => Cypher31Compiler.scala} | 6 +- ...mpatibility.scala => Rule31Compiler.scala} | 8 +-- ...atibility.scala => Cypher33Compiler.scala} | 10 +-- ...atibility.scala => Cypher35Compiler.scala} | 8 +-- .../SnapshotExecutionEngineTest.java | 10 +-- .../cypher/ExecutionEngineTestSupport.scala | 4 +- 18 files changed, 100 insertions(+), 123 deletions(-) rename community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/{CachedExecutableQuery.scala => CacheableExecutableQuery.scala} (86%) rename community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/{CompatibilityCache.scala => CompilerLibrary.scala} (66%) rename community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/{CostCompatibility.scala => Cost23Compiler.scala} (85%) rename community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/{Compatibility.scala => Cypher23Compiler.scala} (96%) rename community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/{RuleCompatibility.scala => Rule23Compiler.scala} (86%) rename community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/{CostCompatibility.scala => Cost31Compiler.scala} (86%) rename community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/{Compatibility.scala => Cypher31Compiler.scala} (96%) rename community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/{RuleCompatibility.scala => Rule31Compiler.scala} (83%) rename community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/{Compatibility.scala => Cypher33Compiler.scala} (97%) rename community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_5/{Compatibility.scala => Cypher35Compiler.scala} (96%) diff --git a/community/cypher/cypher/src/main/java/org/neo4j/cypher/internal/javacompat/ExecutionEngine.java b/community/cypher/cypher/src/main/java/org/neo4j/cypher/internal/javacompat/ExecutionEngine.java index 4d70c6b041541..a97dd4420136c 100644 --- a/community/cypher/cypher/src/main/java/org/neo4j/cypher/internal/javacompat/ExecutionEngine.java +++ b/community/cypher/cypher/src/main/java/org/neo4j/cypher/internal/javacompat/ExecutionEngine.java @@ -23,7 +23,7 @@ import org.neo4j.cypher.CypherException; import org.neo4j.cypher.internal.CacheTracer; -import org.neo4j.cypher.internal.CompatibilityFactory; +import org.neo4j.cypher.internal.CompilerFactory; import org.neo4j.cypher.internal.CypherConfiguration; import org.neo4j.cypher.internal.StringCacheMonitor; import org.neo4j.cypher.internal.tracing.CompilationTracer; @@ -57,7 +57,7 @@ public class ExecutionEngine implements QueryExecutionEngine * @param queryService The database to wrap * @param logProvider A {@link LogProvider} for cypher-statements */ - public ExecutionEngine( GraphDatabaseQueryService queryService, LogProvider logProvider, CompatibilityFactory compatibilityFactory ) + public ExecutionEngine( GraphDatabaseQueryService queryService, LogProvider logProvider, CompilerFactory compilerFactory ) { DependencyResolver resolver = queryService.getDependencyResolver(); Monitors monitors = resolver.resolveDependency( Monitors.class ); @@ -71,7 +71,7 @@ public ExecutionEngine( GraphDatabaseQueryService queryService, LogProvider logP tracer, cacheTracer, cypherConfiguration, - compatibilityFactory, + compilerFactory, logProvider, Clock.systemUTC() ); } diff --git a/community/cypher/cypher/src/main/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngine.java b/community/cypher/cypher/src/main/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngine.java index 9557bf36d3ae9..14d82dee46d43 100644 --- a/community/cypher/cypher/src/main/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngine.java +++ b/community/cypher/cypher/src/main/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngine.java @@ -19,9 +19,7 @@ */ package org.neo4j.cypher.internal.javacompat; -import java.util.Map; - -import org.neo4j.cypher.internal.CompatibilityFactory; +import org.neo4j.cypher.internal.CompilerFactory; import org.neo4j.graphdb.Result; import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.io.pagecache.tracing.cursor.context.VersionContext; @@ -44,9 +42,9 @@ public class SnapshotExecutionEngine extends ExecutionEngine private final int maxQueryExecutionAttempts; SnapshotExecutionEngine( GraphDatabaseQueryService queryService, Config config, LogProvider logProvider, - CompatibilityFactory compatibilityFactory ) + CompilerFactory compilerFactory ) { - super( queryService, logProvider, compatibilityFactory ); + super( queryService, logProvider, compilerFactory ); this.maxQueryExecutionAttempts = config.get( GraphDatabaseSettings.snapshot_query_retries ); } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CachedExecutableQuery.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CacheableExecutableQuery.scala similarity index 86% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CachedExecutableQuery.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CacheableExecutableQuery.scala index abe0f5db69f00..add3f1816e9bd 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CachedExecutableQuery.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CacheableExecutableQuery.scala @@ -28,6 +28,6 @@ import org.neo4j.values.virtual.MapValue * @param paramNames Names of all parameters for this query, explicit and auto-parametrized. * @param extractedParams The names and values of the auto-parametrized parameters for this query. */ -case class CachedExecutableQuery(plan: ExecutionPlan, - paramNames: Seq[String], - extractedParams: MapValue) +case class CacheableExecutableQuery(plan: ExecutionPlan, + paramNames: Seq[String], + extractedParams: MapValue) diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/Compiler.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/Compiler.scala index b62929e596969..876539b6775ec 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/Compiler.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/Compiler.scala @@ -40,5 +40,5 @@ trait Compiler { tracer: CompilationPhaseTracer, preParsingNotifications: Set[org.neo4j.graphdb.Notification], transactionalContext: TransactionalContext - ): CachedExecutableQuery + ): CacheableExecutableQuery } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CompilerEngineDelegator.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CompilerEngineDelegator.scala index 873616c075494..ada4a85661ea5 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CompilerEngineDelegator.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CompilerEngineDelegator.scala @@ -53,7 +53,7 @@ class CompilerEngineDelegator(graph: GraphDatabaseQueryService, kernelMonitors: KernelMonitors, config: CypherConfiguration, logProvider: LogProvider, - compatibilityCache: CompatibilityCache) { + compilerLibrary: CompilerLibrary) { import org.neo4j.cypher.internal.CompilerEngineDelegator._ @@ -84,7 +84,7 @@ class CompilerEngineDelegator(graph: GraphDatabaseQueryService, def compile(preParsedQuery: PreParsedQuery, tracer: CompilationPhaseTracer, transactionalContext: TransactionalContext - ): CachedExecutableQuery = { + ): CacheableExecutableQuery = { var notifications = Set.newBuilder[org.neo4j.graphdb.Notification] val supportedRuntimes3_1 = Seq(CypherRuntimeOption.interpreted, CypherRuntimeOption.default) @@ -100,18 +100,18 @@ class CompilerEngineDelegator(graph: GraphDatabaseQueryService, } } - def innerCompile(preParsedQuery: PreParsedQuery): CachedExecutableQuery = { + def innerCompile(preParsedQuery: PreParsedQuery): CacheableExecutableQuery = { if ((preParsedQuery.version == CypherVersion.v3_3 || preParsedQuery.version == CypherVersion.v3_5) && preParsedQuery.planner == CypherPlannerOption.rule) { notifications += rulePlannerUnavailableFallbackNotification(preParsedQuery.offset) innerCompile(preParsedQuery.copy(version = CypherVersion.v3_1)) } else if (preParsedQuery.version == CypherVersion.v3_5) { - val compiler3_5 = compatibilityCache.selectCompiler(preParsedQuery.version, - preParsedQuery.planner, - preParsedQuery.runtime, - preParsedQuery.updateStrategy, - compilerConfig) + val compiler3_5 = compilerLibrary.selectCompiler(preParsedQuery.version, + preParsedQuery.planner, + preParsedQuery.runtime, + preParsedQuery.updateStrategy, + compilerConfig) try { compiler3_5.compile(preParsedQuery, tracer, notifications.result(), transactionalContext) @@ -130,11 +130,11 @@ class CompilerEngineDelegator(graph: GraphDatabaseQueryService, } else { - val compiler = compatibilityCache.selectCompiler(preParsedQuery.version, - preParsedQuery.planner, - preParsedQuery.runtime, - preParsedQuery.updateStrategy, - compilerConfig) + val compiler = compilerLibrary.selectCompiler(preParsedQuery.version, + preParsedQuery.planner, + preParsedQuery.runtime, + preParsedQuery.updateStrategy, + compilerConfig) compiler.compile(preParsedQuery, tracer, notifications.result(), transactionalContext) } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CompatibilityCache.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CompilerLibrary.scala similarity index 66% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CompatibilityCache.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CompilerLibrary.scala index 350bf40fcb5ab..8d1dc0d0c0949 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CompatibilityCache.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/CompilerLibrary.scala @@ -19,12 +19,10 @@ */ package org.neo4j.cypher.internal -import java.util.concurrent.ConcurrentHashMap - import org.neo4j.cypher.internal.compatibility.v2_3.helpers._ import org.neo4j.cypher.internal.compatibility.v3_1.helpers._ import org.neo4j.cypher.internal.compatibility.v3_3.{CommunityRuntimeContextCreator => CommunityRuntimeContextCreatorV3_3} -import org.neo4j.cypher.internal.compatibility.v3_5.Compatibility +import org.neo4j.cypher.internal.compatibility.v3_5.Cypher35Compiler import org.neo4j.cypher.internal.compatibility.v3_5.runtime.{CommunityRuntimeBuilder, CommunityRuntimeContextCreator => CommunityRuntimeContextCreatorv3_5} import org.neo4j.cypher.internal.compatibility.{v2_3, v3_1, v3_3 => v3_3compat} import org.neo4j.cypher.internal.compiler.v3_5.CypherPlannerConfiguration @@ -43,16 +41,16 @@ final case class PlannerSpec_v3_1(planner: CypherPlannerOption, runtime: CypherR final case class PlannerSpec_v3_3(planner: CypherPlannerOption, runtime: CypherRuntimeOption, updateStrategy: CypherUpdateStrategy) extends PlannerSpec final case class PlannerSpec_v3_5(planner: CypherPlannerOption, runtime: CypherRuntimeOption, updateStrategy: CypherUpdateStrategy) extends PlannerSpec -trait CompatibilityFactory { - def create(spec: PlannerSpec_v2_3, config: CypherPlannerConfiguration): v2_3.Compatibility +trait CompilerFactory { + def create(spec: PlannerSpec_v2_3, config: CypherPlannerConfiguration): v2_3.Cypher23Compiler - def create(spec: PlannerSpec_v3_1, config: CypherPlannerConfiguration): v3_1.Compatibility + def create(spec: PlannerSpec_v3_1, config: CypherPlannerConfiguration): v3_1.Cypher31Compiler - def create(spec: PlannerSpec_v3_3, config: CypherPlannerConfiguration): v3_3compat.Compatibility[_,_,_] + def create(spec: PlannerSpec_v3_3, config: CypherPlannerConfiguration): v3_3compat.Cypher33Compiler[_,_,_] - def create(spec: PlannerSpec_v3_5, config: CypherPlannerConfiguration): Compatibility[_,_] + def create(spec: PlannerSpec_v3_5, config: CypherPlannerConfiguration): Cypher35Compiler[_,_] - def selectCompiler(cypherVersion: CypherVersion, + def createCompiler(cypherVersion: CypherVersion, cypherPlanner: CypherPlannerOption, cypherRuntime: CypherRuntimeOption, cypherUpdateStrategy: CypherUpdateStrategy, @@ -67,77 +65,58 @@ trait CompatibilityFactory { } class CommunityCompatibilityFactory(graph: GraphDatabaseQueryService, kernelMonitors: KernelMonitors, - logProvider: LogProvider) extends CompatibilityFactory { + logProvider: LogProvider) extends CompilerFactory { private val log: Log = logProvider.getLog(getClass) - override def create(spec: PlannerSpec_v2_3, config: CypherPlannerConfiguration): v2_3.Compatibility = spec.planner match { + override def create(spec: PlannerSpec_v2_3, config: CypherPlannerConfiguration): v2_3.Cypher23Compiler = spec.planner match { case CypherPlannerOption.rule => - v2_3.RuleCompatibility(graph, as2_3(config), Clock.SYSTEM_CLOCK, kernelMonitors) + v2_3.Rule23Compiler(graph, as2_3(config), Clock.SYSTEM_CLOCK, kernelMonitors) case _ => - v2_3.CostCompatibility(graph, as2_3(config), Clock.SYSTEM_CLOCK, kernelMonitors, log, spec.planner, spec.runtime) + v2_3.Cost23Compiler(graph, as2_3(config), Clock.SYSTEM_CLOCK, kernelMonitors, log, spec.planner, spec.runtime) } - override def create(spec: PlannerSpec_v3_1, config: CypherPlannerConfiguration): v3_1.Compatibility = spec.planner match { + override def create(spec: PlannerSpec_v3_1, config: CypherPlannerConfiguration): v3_1.Cypher31Compiler = spec.planner match { case CypherPlannerOption.rule => - v3_1.RuleCompatibility(graph, as3_1(config), CompilerEngineDelegator.CLOCK, kernelMonitors) + v3_1.Rule31Compiler(graph, as3_1(config), CompilerEngineDelegator.CLOCK, kernelMonitors) case _ => - v3_1.CostCompatibility(graph, as3_1(config), CompilerEngineDelegator.CLOCK, kernelMonitors, log, spec.planner, spec.runtime, spec.updateStrategy) + v3_1.Cost31Compiler(graph, as3_1(config), CompilerEngineDelegator.CLOCK, kernelMonitors, log, spec.planner, spec.runtime, spec.updateStrategy) } - override def create(spec: PlannerSpec_v3_3, config: CypherPlannerConfiguration): v3_3compat.Compatibility[_,_,_] = + override def create(spec: PlannerSpec_v3_3, config: CypherPlannerConfiguration): v3_3compat.Cypher33Compiler[_,_,_] = (spec.planner, spec.runtime) match { case (CypherPlannerOption.rule, _) => throw new InvalidArgumentException("The rule planner is no longer a valid planner option in Neo4j 3.3. If you need to use it, please select compatibility mode Cypher 3.1") case _ => - v3_3compat.Compatibility(config, CompilerEngineDelegator.CLOCK, kernelMonitors, log, + v3_3compat.Cypher33Compiler(config, CompilerEngineDelegator.CLOCK, kernelMonitors, log, spec.planner, spec.runtime, spec.updateStrategy, CommunityRuntimeBuilder, CommunityRuntimeContextCreatorV3_3, CommunityRuntimeContextCreatorv3_5, LastCommittedTxIdProvider(graph)) } - override def create(spec: PlannerSpec_v3_5, config: CypherPlannerConfiguration): Compatibility[_,_] = + override def create(spec: PlannerSpec_v3_5, config: CypherPlannerConfiguration): Cypher35Compiler[_,_] = (spec.planner, spec.runtime) match { case (CypherPlannerOption.rule, _) => throw new InvalidArgumentException("The rule planner is no longer a valid planner option in Neo4j 3.4. If you need to use it, please select compatibility mode Cypher 3.1") case _ => - Compatibility(config, CompilerEngineDelegator.CLOCK, kernelMonitors, log, + Cypher35Compiler(config, CompilerEngineDelegator.CLOCK, kernelMonitors, log, spec.planner, spec.runtime, spec.updateStrategy, CommunityRuntimeBuilder, CommunityRuntimeContextCreatorv3_5, LastCommittedTxIdProvider(graph)) } } -class CompatibilityCache(factory: CompatibilityFactory) extends CompatibilityFactory { - - import scala.collection.convert.decorateAsScala._ - - private val cache_v2_3 = new ConcurrentHashMap[PlannerSpec_v2_3, v2_3.Compatibility].asScala - private val cache_v3_1 = new ConcurrentHashMap[PlannerSpec_v3_1, v3_1.Compatibility].asScala - private val cache_v3_3 = new ConcurrentHashMap[PlannerSpec_v3_3, v3_3compat.Compatibility[_,_,_]].asScala - private val cache_v3_5 = new ConcurrentHashMap[PlannerSpec_v3_5, Compatibility[_,_]].asScala +class CompilerLibrary(factory: CompilerFactory) { private val compilers = new CopyOnWriteHashMap[CompilerKey, Compiler] - override def create(spec: PlannerSpec_v2_3, config: CypherPlannerConfiguration): v2_3.Compatibility = - cache_v2_3.getOrElseUpdate(spec, factory.create(spec, config)) - - override def create(spec: PlannerSpec_v3_1, config: CypherPlannerConfiguration): v3_1.Compatibility = - cache_v3_1.getOrElseUpdate(spec, factory.create(spec, config)) - - override def create(spec: PlannerSpec_v3_3, config: CypherPlannerConfiguration): v3_3compat.Compatibility[_,_,_] = - cache_v3_3.getOrElseUpdate(spec, factory.create(spec, config)) - - override def create(spec: PlannerSpec_v3_5, config: CypherPlannerConfiguration): Compatibility[_,_] = - cache_v3_5.getOrElseUpdate(spec, factory.create(spec, config)) - - override def selectCompiler(cypherVersion: CypherVersion, - cypherPlanner: CypherPlannerOption, - cypherRuntime: CypherRuntimeOption, - cypherUpdateStrategy: CypherUpdateStrategy, - config: CypherPlannerConfiguration): Compiler = { + def selectCompiler(cypherVersion: CypherVersion, + cypherPlanner: CypherPlannerOption, + cypherRuntime: CypherRuntimeOption, + cypherUpdateStrategy: CypherUpdateStrategy, + config: CypherPlannerConfiguration): Compiler = { val key = CompilerKey(cypherVersion, cypherPlanner, cypherRuntime, cypherUpdateStrategy) val compiler = compilers.get(key) if (compiler == null) { - compilers.put(key, factory.selectCompiler(cypherVersion, cypherPlanner, cypherRuntime, cypherUpdateStrategy, config)) + compilers.put(key, factory.createCompiler(cypherVersion, cypherPlanner, cypherRuntime, cypherUpdateStrategy, config)) compilers.get(key) } else compiler } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/ExecutionEngine.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/ExecutionEngine.scala index 6375d051549fc..382afdd2f7e2c 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/ExecutionEngine.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/ExecutionEngine.scala @@ -46,7 +46,7 @@ class ExecutionEngine(val queryService: GraphDatabaseQueryService, val tracer: CompilationTracer, val cacheTracer: CacheTracer[String], val config: CypherConfiguration, - val compatibilityFactory: CompatibilityFactory, + val compatibilityFactory: CompilerFactory, val logProvider: LogProvider, val clock: Clock = Clock.systemUTC() ) { @@ -56,7 +56,7 @@ class ExecutionEngine(val queryService: GraphDatabaseQueryService, private val preParser = new PreParser(config.version, config.planner, config.runtime, config.queryCacheSize) private val lastCommittedTxIdProvider = LastCommittedTxIdProvider(queryService) - private def planReusabilitiy(cachedExecutableQuery: CachedExecutableQuery, + private def planReusabilitiy(cachedExecutableQuery: CacheableExecutableQuery, transactionalContext: TransactionalContext): ReusabilityState = cachedExecutableQuery.plan.reusabilityState(lastCommittedTxIdProvider, transactionalContext) @@ -69,15 +69,15 @@ class ExecutionEngine(val queryService: GraphDatabaseQueryService, }) private val planStalenessCaller = - new PlanStalenessCaller[CachedExecutableQuery](clock, + new PlanStalenessCaller[CacheableExecutableQuery](clock, config.statsDivergenceCalculator, lastCommittedTxIdProvider, planReusabilitiy) - private val queryCache: QueryCache[String, CachedExecutableQuery] = + private val queryCache: QueryCache[String, CacheableExecutableQuery] = new QueryCache(config.queryCacheSize, planStalenessCaller, cacheTracer) private val compilerEngineDelegator: CompilerEngineDelegator = - new CompilerEngineDelegator(queryService, kernelMonitors, config, logProvider, new CompatibilityCache(compatibilityFactory)) + new CompilerEngineDelegator(queryService, kernelMonitors, config, logProvider, new CompilerLibrary(compatibilityFactory)) private val parsedQueries = new LFUCache[String, ParsedQuery](config.queryCacheSize) @@ -119,7 +119,7 @@ class ExecutionEngine(val queryService: GraphDatabaseQueryService, private def getOrCompile(context: TransactionalContext, preParsedQuery: PreParsedQuery, tracer: QueryCompilationEvent - ): CachedExecutableQuery = { + ): CacheableExecutableQuery = { val cacheKey = preParsedQuery.statementWithVersionAndPlanner // create transaction and query context diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/QueryCache.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/QueryCache.scala index ee0dc5f1f6c6c..a91fd6c74c43b 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/QueryCache.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/QueryCache.scala @@ -144,5 +144,5 @@ class QueryCache[QUERY_KEY <: AnyRef, EXECUTABLE_QUERY <: AnyRef](val maximumSiz } object QueryCache { - val NOT_PRESENT: CachedExecutableQuery = null + val NOT_PRESENT: CacheableExecutableQuery = null } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/CostCompatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Cost23Compiler.scala similarity index 85% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/CostCompatibility.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Cost23Compiler.scala index 03b0531835f60..1c4cd434193e4 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/CostCompatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Cost23Compiler.scala @@ -28,13 +28,13 @@ import org.neo4j.kernel.impl.core.EmbeddedProxySPI import org.neo4j.kernel.monitoring.{Monitors => KernelMonitors} import org.neo4j.logging.Log -case class CostCompatibility(graph: GraphDatabaseQueryService, - config: CypherCompilerConfiguration, - clock: Clock, - kernelMonitors: KernelMonitors, - log: Log, - planner: CypherPlannerOption, - runtime: CypherRuntimeOption) extends Compatibility { +case class Cost23Compiler(graph: GraphDatabaseQueryService, + config: CypherCompilerConfiguration, + clock: Clock, + kernelMonitors: KernelMonitors, + log: Log, + planner: CypherPlannerOption, + runtime: CypherRuntimeOption) extends Cypher23Compiler { protected val compiler = { val plannerName = planner match { diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Compatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Cypher23Compiler.scala similarity index 96% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Compatibility.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Cypher23Compiler.scala index d61645f0e9217..e2266998cb7b3 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Compatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Cypher23Compiler.scala @@ -48,7 +48,7 @@ import org.opencypher.v9_0.frontend.phases.CompilationPhaseTracer import scala.collection.mutable -trait Compatibility extends CachingCompiler[PreparedQuery] { +trait Cypher23Compiler extends CachingCompiler[PreparedQuery] { val graph: GraphDatabaseQueryService val queryCacheSize: Int @@ -122,7 +122,7 @@ trait Compatibility extends CachingCompiler[PreparedQuery] { tracer: CompilationPhaseTracer, preParsingNotifications: Set[org.neo4j.graphdb.Notification], transactionalContext: TransactionalContext - ): CachedExecutableQuery = { + ): CacheableExecutableQuery = { exceptionHandler.runSafely { val notificationLogger = new RecordingNotificationLogger @@ -139,7 +139,7 @@ trait Compatibility extends CachingCompiler[PreparedQuery] { // Log notifications/warnings from planning executionPlan2_3.notifications(planContext).foreach(notificationLogger += _) val executionPlan = new ExecutionPlanWrapper(executionPlan2_3, preParsingNotifications, position2_3) - CachedExecutableQuery(executionPlan, Seq.empty[String], ValueConversion.asValues(extractedParameters)) + CacheableExecutableQuery(executionPlan, Seq.empty[String], ValueConversion.asValues(extractedParameters)) } } } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/RuleCompatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Rule23Compiler.scala similarity index 86% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/RuleCompatibility.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Rule23Compiler.scala index f5ee1a9a842fe..83bc4619f8da5 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/RuleCompatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/Rule23Compiler.scala @@ -26,10 +26,10 @@ import org.neo4j.kernel.GraphDatabaseQueryService import org.neo4j.kernel.impl.core.EmbeddedProxySPI import org.neo4j.kernel.monitoring.{Monitors => KernelMonitors} -case class RuleCompatibility(graph: GraphDatabaseQueryService, - config: CypherCompilerConfiguration, - clock: Clock, - kernelMonitors: KernelMonitors) extends Compatibility { +case class Rule23Compiler(graph: GraphDatabaseQueryService, + config: CypherCompilerConfiguration, + clock: Clock, + kernelMonitors: KernelMonitors) extends Cypher23Compiler { protected val compiler = { val proxySpi = graph.getDependencyResolver.resolveDependency(classOf[EmbeddedProxySPI]) val entityAccessor = new EntityAccessorWrapper(proxySpi) diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/CostCompatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Cost31Compiler.scala similarity index 86% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/CostCompatibility.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Cost31Compiler.scala index 80dedd83a8cef..86e788df8aa1a 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/CostCompatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Cost31Compiler.scala @@ -30,14 +30,14 @@ import org.neo4j.kernel.GraphDatabaseQueryService import org.neo4j.kernel.monitoring.{Monitors => KernelMonitors} import org.neo4j.logging.Log -case class CostCompatibility(graph: GraphDatabaseQueryService, - config: CypherCompilerConfiguration, - clock: Clock, - kernelMonitors: KernelMonitors, - log: Log, - planner: CypherPlannerOption, - runtime: CypherRuntimeOption, - strategy: CypherUpdateStrategy) extends Compatibility { +case class Cost31Compiler(graph: GraphDatabaseQueryService, + config: CypherCompilerConfiguration, + clock: Clock, + kernelMonitors: KernelMonitors, + log: Log, + planner: CypherPlannerOption, + runtime: CypherRuntimeOption, + strategy: CypherUpdateStrategy) extends Cypher31Compiler { protected val compiler = { val plannerName = planner match { diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Compatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Cypher31Compiler.scala similarity index 96% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Compatibility.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Cypher31Compiler.scala index 96c7d993464dc..44b8f03f607b8 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Compatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Cypher31Compiler.scala @@ -47,7 +47,7 @@ import org.opencypher.v9_0.{frontend => v3_5} import scala.collection.mutable -trait Compatibility extends CachingCompiler[PreparedQuerySyntax] { +trait Cypher31Compiler extends CachingCompiler[PreparedQuerySyntax] { val graph: GraphDatabaseQueryService val queryCacheSize: Int @@ -124,7 +124,7 @@ trait Compatibility extends CachingCompiler[PreparedQuerySyntax] { tracer: v3_5.phases.CompilationPhaseTracer, preParsingNotifications: Set[org.neo4j.graphdb.Notification], transactionalContext: TransactionalContext - ): CachedExecutableQuery = { + ): CacheableExecutableQuery = { exceptionHandler.runSafely { val notificationLogger = new RecordingNotificationLogger @@ -143,7 +143,7 @@ trait Compatibility extends CachingCompiler[PreparedQuerySyntax] { executionPlan3_1.notifications(planContext).foreach(notificationLogger += _) val executionPlan = new ExecutionPlanWrapper(executionPlan3_1, preParsingNotifications, position3_1) - CachedExecutableQuery(executionPlan, Seq.empty[String], ValueConversion.asValues(extractedParameters)) + CacheableExecutableQuery(executionPlan, Seq.empty[String], ValueConversion.asValues(extractedParameters)) } } } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/RuleCompatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Rule31Compiler.scala similarity index 83% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/RuleCompatibility.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Rule31Compiler.scala index a9de92954acec..c6bbad3e99771 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/RuleCompatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/Rule31Compiler.scala @@ -25,10 +25,10 @@ import org.neo4j.cypher.internal.compiler.v3_1.{CypherCompilerConfiguration, Cyp import org.neo4j.kernel.GraphDatabaseQueryService import org.neo4j.kernel.monitoring.{Monitors => KernelMonitors} -case class RuleCompatibility(graph: GraphDatabaseQueryService, - config: CypherCompilerConfiguration, - clock: Clock, - kernelMonitors: KernelMonitors) extends Compatibility { +case class Rule31Compiler(graph: GraphDatabaseQueryService, + config: CypherCompilerConfiguration, + clock: Clock, + kernelMonitors: KernelMonitors) extends Cypher31Compiler { protected val compiler = { val monitors = WrappedMonitors(kernelMonitors) CypherCompilerFactory.ruleBasedCompiler(graph, config, clock, monitors, rewriterSequencer, typeConversions) diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/Compatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/Cypher33Compiler.scala similarity index 97% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/Compatibility.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/Cypher33Compiler.scala index 2b6765af1ab9d..917412e45b20c 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/Compatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/Cypher33Compiler.scala @@ -51,7 +51,7 @@ import org.neo4j.logging.Log import org.opencypher.v9_0.frontend.phases.{CompilationPhaseTracer, Transformer, RecordingNotificationLogger => RecordingNotificationLoggerv3_5} import org.opencypher.v9_0.util.attribution.SequentialIdGen -case class Compatibility[CONTEXT3_3 <: v3_3.phases.CompilerContext, +case class Cypher33Compiler[CONTEXT3_3 <: v3_3.phases.CompilerContext, CONTEXT3_5 <: CommunityRuntimeContextv3_5, T <: Transformer[CONTEXT3_5, LogicalPlanState, CompilationState]](configv3_5: CypherPlannerConfiguration, clock: Clock, @@ -105,7 +105,7 @@ extends LatestRuntimeVariablePlannerCompatibility[CONTEXT3_5, T, StatementV3_3]( maybePlannerName, maybeUpdateStrategy, contextCreatorV3_3) - private def queryGraphSolverV3_3 = Compatibility. + private def queryGraphSolverV3_3 = Cypher33Compiler. createQueryGraphSolver(maybePlannerName.getOrElse(v3_3.CostBasedPlannerName.default), monitorsV3_3, configV3_3) private def checkForSchemaChanges(planContext: PlanContext): Unit = @@ -118,7 +118,7 @@ extends LatestRuntimeVariablePlannerCompatibility[CONTEXT3_5, T, StatementV3_3]( tracer: CompilationPhaseTracer, preParsingNotifications: Set[org.neo4j.graphdb.Notification], transactionalContext: TransactionalContext - ): CachedExecutableQuery = { + ): CacheableExecutableQuery = { val inputPositionV3_3 = as3_3(preParsedQuery.offset) val inputPositionv3_5 = preParsedQuery.offset @@ -215,7 +215,7 @@ extends LatestRuntimeVariablePlannerCompatibility[CONTEXT3_5, T, StatementV3_3]( // Log notifications/warnings from planning notificationLoggerV3_3.notifications.map(helpers.as3_5).foreach(notificationLoggerv3_5.log) val executionPlan = new ExecutionPlanWrapper(executionPlan3_5, preParsingNotifications) - CachedExecutableQuery(executionPlan, queryParamNames, ValueConversion.asValues(preparedQuery.extractedParams())) + CacheableExecutableQuery(executionPlan, queryParamNames, ValueConversion.asValues(preparedQuery.extractedParams())) } } } @@ -237,7 +237,7 @@ class Parser3_3[CONTEXT3_3 <: v3_3.phases.CompilerContext](compiler: v3_3.Cypher } } -object Compatibility { +object Cypher33Compiler { def createQueryGraphSolver(n: v3_3.CostBasedPlannerName, monitors: MonitorsV3_3, config: v3_3.CypherCompilerConfiguration): logicalV3_3.QueryGraphSolver = n match { case v3_3.IDPPlannerName => diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_5/Compatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_5/Cypher35Compiler.scala similarity index 96% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_5/Compatibility.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_5/Cypher35Compiler.scala index b650c892e85e2..04bc42030b250 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_5/Compatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_5/Cypher35Compiler.scala @@ -45,7 +45,7 @@ import org.opencypher.v9_0.rewriting.RewriterStepSequencer import org.opencypher.v9_0.util.InputPosition import org.opencypher.v9_0.util.attribution.SequentialIdGen -case class Compatibility[CONTEXT <: CommunityRuntimeContext, +case class Cypher35Compiler[CONTEXT <: CommunityRuntimeContext, T <: Transformer[CONTEXT, LogicalPlanState, CompilationState]](config: CypherPlannerConfiguration, clock: Clock, kernelMonitors: KernelMonitors, @@ -108,7 +108,7 @@ case class Compatibility[CONTEXT <: CommunityRuntimeContext, tracer: CompilationPhaseTracer, preParsingNotifications: Set[org.neo4j.graphdb.Notification], transactionalContext: TransactionalContext - ): CachedExecutableQuery = { + ): CacheableExecutableQuery = { val notificationLogger = new RecordingNotificationLogger(Some(preParsedQuery.offset)) @@ -164,12 +164,12 @@ case class Compatibility[CONTEXT <: CommunityRuntimeContext, createPlan() val executionPlan = new ExecutionPlanWrapper(executionPlan3_5, preParsingNotifications) - CachedExecutableQuery(executionPlan, queryParamNames, ValueConversion.asValues(preparedQuery.extractedParams())) + CacheableExecutableQuery(executionPlan, queryParamNames, ValueConversion.asValues(preparedQuery.extractedParams())) } } } -class Parser3_5[CONTEXT3_5 <: v3_5.phases.CompilerContext](compiler: v3_5.CypherCompiler[CONTEXT3_5], +class Parser3_5[CONTEXT3_5 <: v3_5.phases.PlannerContext](compiler: v3_5.CypherPlanner[CONTEXT3_5], notificationLogger: RecordingNotificationLogger, offset: InputPosition, tracer: CompilationPhaseTracer diff --git a/community/cypher/cypher/src/test/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngineTest.java b/community/cypher/cypher/src/test/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngineTest.java index 802d74df741b2..c3e474adbabf5 100644 --- a/community/cypher/cypher/src/test/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngineTest.java +++ b/community/cypher/cypher/src/test/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngineTest.java @@ -25,7 +25,7 @@ import java.util.Collections; -import org.neo4j.cypher.internal.CompatibilityFactory; +import org.neo4j.cypher.internal.CompilerFactory; import org.neo4j.graphdb.QueryStatistics; import org.neo4j.graphdb.Result; import org.neo4j.io.pagecache.tracing.cursor.context.VersionContext; @@ -52,7 +52,7 @@ public class SnapshotExecutionEngineTest @Rule public final DatabaseRule database = new ImpermanentDatabaseRule(); - private CompatibilityFactory compatibilityFactory; + private CompilerFactory compilerFactory; private TestSnapshotExecutionEngine executionEngine; private VersionContext versionContext; private SnapshotExecutionEngine.ParametrizedQueryExecutor executor; @@ -64,7 +64,7 @@ public void setUp() throws Exception { GraphDatabaseQueryService cypherService = new GraphDatabaseCypherService( this.database.getGraphDatabaseAPI() ); - compatibilityFactory = mock( CompatibilityFactory.class ); + compilerFactory = mock( CompilerFactory.class ); transactionalContext = mock( TransactionalContext.class ); KernelStatement kernelStatement = mock( KernelStatement.class ); executor = mock( SnapshotExecutionEngine.ParametrizedQueryExecutor.class ); @@ -121,7 +121,7 @@ private class TestSnapshotExecutionEngine extends SnapshotExecutionEngine { TestSnapshotExecutionEngine( GraphDatabaseQueryService queryService, Config config, LogProvider logProvider, - CompatibilityFactory compatibilityFactory ) + CompilerFactory compatibilityFactory ) { super( queryService, config, logProvider, compatibilityFactory ); } @@ -137,6 +137,6 @@ public Result executeWithRetries( String query, T parameters, TransactionalC private TestSnapshotExecutionEngine createExecutionEngine( GraphDatabaseQueryService cypherService ) { return new TestSnapshotExecutionEngine( cypherService, config, NullLogProvider.getInstance(), - compatibilityFactory ); + compilerFactory ); } } diff --git a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTestSupport.scala b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTestSupport.scala index c9419f0f9b0cb..ea33084a16113 100644 --- a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTestSupport.scala +++ b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTestSupport.scala @@ -92,7 +92,7 @@ object ExecutionEngineHelper { val resolver = graphDatabaseCypherService.getDependencyResolver val kernelMonitors: KernelMonitors = resolver.resolveDependency(classOf[KernelMonitors]) val cacheTracer = new MonitoringCacheTracer( kernelMonitors.newMonitor( classOf[StringCacheMonitor] ) ) - val compatibilityFactory = resolver.resolveDependency( classOf[CompatibilityFactory] ) + val compilerFactory = resolver.resolveDependency( classOf[CompilerFactory] ) val config = resolver.resolveDependency(classOf[Config]) val tracer = new TimingCompilationTracer(kernelMonitors.newMonitor(classOf[TimingCompilationTracer.EventListener])) @@ -102,7 +102,7 @@ object ExecutionEngineHelper { tracer, cacheTracer, CypherConfiguration.fromConfig(config), - compatibilityFactory, + compilerFactory, logProvider) } }