Skip to content

Commit

Permalink
Removed support for Cypher 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Nov 4, 2016
1 parent 3281202 commit 2842110
Show file tree
Hide file tree
Showing 80 changed files with 2,279 additions and 865 deletions.
Expand Up @@ -22,7 +22,7 @@ package org.neo4j.internal.cypher.acceptance
import java.util

import org.neo4j.cypher._
import org.neo4j.cypher.internal.compatibility.CompatibilityPlanDescriptionFor3_1
import org.neo4j.cypher.internal.compatibility.CompatibilityPlanDescriptionFor3_2
import org.neo4j.cypher.internal.compiler.v3_2.planDescription.InternalPlanDescription
import org.neo4j.cypher.internal.compiler.v3_2.planner.logical.idp.IDPSolverMonitor
import org.neo4j.cypher.internal.compiler.v3_2.{IDPPlannerName, InterpretedRuntimeName}
Expand Down Expand Up @@ -162,7 +162,7 @@ class MatchLongPatternAcceptanceTest extends ExecutionEngineFunSuite with QueryS
}

private def assertMinExpandsAndJoins(plan: InternalPlanDescription, minCounts: Map[String, Int]): Map[String, Int] = {
val externalPlanDescription = CompatibilityPlanDescriptionFor3_1(plan, CypherVersion.v3_1, IDPPlannerName, InterpretedRuntimeName)
val externalPlanDescription = CompatibilityPlanDescriptionFor3_2(plan, CypherVersion.v3_2, IDPPlannerName, InterpretedRuntimeName)
assertMinExpandsAndJoins(externalPlanDescription, minCounts)
}

Expand All @@ -176,7 +176,7 @@ class MatchLongPatternAcceptanceTest extends ExecutionEngineFunSuite with QueryS
}

private def countExpandsAndJoins(plan: InternalPlanDescription): Map[String, Int] = {
val externalPlanDescription = CompatibilityPlanDescriptionFor3_1(plan, CypherVersion.v3_1, IDPPlannerName, InterpretedRuntimeName)
val externalPlanDescription = CompatibilityPlanDescriptionFor3_2(plan, CypherVersion.v3_2, IDPPlannerName, InterpretedRuntimeName)
countExpandsAndJoins(externalPlanDescription)
}

Expand Down
Expand Up @@ -24,11 +24,7 @@
import org.junit.runner.RunWith;
import org.opencypher.tools.tck.TCKCucumberTemplate;

import static cypher.SpecSuiteConstants.BLACKLIST_PLUGIN;
import static cypher.SpecSuiteConstants.DB_CONFIG;
import static cypher.SpecSuiteConstants.GLUE_PATH;
import static cypher.SpecSuiteConstants.HTML_REPORT;
import static cypher.SpecSuiteConstants.JSON_REPORT;
import static cypher.SpecSuiteConstants.*;

@RunWith( CompatibilitySpecSuiteResources.class )
public class CompatibilitySpecSuiteTest
Expand Down Expand Up @@ -114,17 +110,17 @@ public static class Compatibility23
@RunWith( Cucumber.class )
@CucumberOptions(
plugin = {
DB_CONFIG + "compatibility-30.json",
HTML_REPORT + SUITE_NAME + "/compatibility-30",
JSON_REPORT + SUITE_NAME + "/compatibility-30",
BLACKLIST_PLUGIN + "compatibility-30.txt"
DB_CONFIG + "compatibility-31.json",
HTML_REPORT + SUITE_NAME + "/compatibility-31",
JSON_REPORT + SUITE_NAME + "/compatibility-31",
BLACKLIST_PLUGIN + "compatibility-31.txt"
},
glue = { GLUE_PATH },
features = { FEATURE_PATH + FEATURE_TO_RUN },
tags = { "~@pending" },
strict = true
)
public static class Compatibility30
public static class Compatibility31
{
}

Expand Down

This file was deleted.

@@ -0,0 +1,5 @@
// bugged in spec, awaiting update
SKIP with an expression that depends on variables should fail
LIMIT with an expression that depends on variables should fail
Fail when returning type of deleted relationships
Fail when returning properties of deleted relationships

This file was deleted.

@@ -0,0 +1,3 @@
{
"language": "3.1"
}
4 changes: 2 additions & 2 deletions community/cypher/cypher/pom.xml
Expand Up @@ -215,8 +215,8 @@
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-compiler-3.0</artifactId>
<version>3.0.6</version>
<artifactId>neo4j-cypher-compiler-3.1</artifactId>
<version>3.1.0-M12-beta2</version>
<exclusions>
<exclusion>
<groupId>org.neo4j</groupId>
Expand Down
Expand Up @@ -23,9 +23,9 @@ sealed abstract class CypherVersion(versionName: String) extends CypherOption(ve

case object CypherVersion extends CypherOptionCompanion[CypherVersion] {
case object v2_3 extends CypherVersion("2.3")
case object v3_0 extends CypherVersion("3.0")
case object v3_1 extends CypherVersion("3.1")
case object v3_2 extends CypherVersion("3.2")

val default = v3_1
val all: Set[CypherVersion] = Set(v2_3, v3_0, v3_1)
val default = v3_2
val all: Set[CypherVersion] = Set(v2_3, v3_1, v3_2)
}
Expand Up @@ -21,7 +21,7 @@ package org.neo4j.cypher.internal

import java.time.Clock

import org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_1
import org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_2
import org.neo4j.cypher.internal.compiler.v3_2._
import org.neo4j.cypher.internal.frontend.v3_2.InputPosition
import org.neo4j.cypher.{InvalidArgumentException, SyntaxException, _}
Expand Down Expand Up @@ -95,7 +95,7 @@ class CypherCompiler(graph: GraphDatabaseQueryService,
private final val ILLEGAL_PLANNER_RUNTIME_COMBINATIONS: Set[(CypherPlanner, CypherRuntime)] = Set((CypherPlanner.rule, CypherRuntime.compiled))

@throws(classOf[SyntaxException])
def preParseQuery(queryText: String): PreParsedQuery = exceptionHandlerFor3_1.runSafely {
def preParseQuery(queryText: String): PreParsedQuery = exceptionHandlerFor3_2.runSafely {
val preParsedStatement = CypherPreParser(queryText)
val CypherStatementWithOptions(statement, offset, version, planner, runtime, updateStrategy, mode) =
CypherStatementWithOptions(preParsedStatement)
Expand Down Expand Up @@ -128,14 +128,14 @@ class CypherCompiler(graph: GraphDatabaseQueryService,
@throws(classOf[SyntaxException])
def parseQuery(preParsedQuery: PreParsedQuery, tracer: CompilationPhaseTracer): ParsedQuery = {
import helpers.wrappersFor2_3._
import helpers.wrappersFor3_0._
import helpers.wrappersFor3_1._

val planner = preParsedQuery.planner
val runtime = preParsedQuery.runtime
val updateStrategy = preParsedQuery.updateStrategy
preParsedQuery.version match {
case CypherVersion.v3_1 => planners(PlannerSpec_v3_1(planner, runtime, updateStrategy)).produceParsedQuery(preParsedQuery, tracer)
case CypherVersion.v3_0 => planners(PlannerSpec_v3_0(planner, runtime, updateStrategy)).produceParsedQuery(preParsedQuery, as3_0(tracer))
case CypherVersion.v3_2 => planners(PlannerSpec_v3_2(planner, runtime, updateStrategy)).produceParsedQuery(preParsedQuery, tracer)
case CypherVersion.v3_1 => planners(PlannerSpec_v3_1(planner, runtime, updateStrategy)).produceParsedQuery(preParsedQuery, as3_1(tracer))
case CypherVersion.v2_3 => planners(PlannerSpec_v2_3(planner, runtime)).produceParsedQuery(preParsedQuery, as2_3(tracer))
}
}
Expand Down
Expand Up @@ -22,15 +22,15 @@ package org.neo4j.cypher.internal
import java.util.{Map => JavaMap}

import org.neo4j.cypher._
import org.neo4j.cypher.internal.compiler.v3_2._
import org.neo4j.cypher.internal.compiler.v3_2.helpers.{RuntimeJavaValueConverter, RuntimeScalaValueConverter}
import org.neo4j.cypher.internal.compiler.v3_2.prettifier.Prettifier
import org.neo4j.cypher.internal.compiler.v3_2.{LFUCache => LRUCachev3_1, _}
import org.neo4j.cypher.internal.spi.TransactionalContextWrapperv3_1
import org.neo4j.cypher.internal.spi.TransactionalContextWrapperv3_2
import org.neo4j.cypher.internal.tracing.{CompilationTracer, TimingCompilationTracer}
import org.neo4j.graphdb.config.Setting
import org.neo4j.graphdb.factory.GraphDatabaseSettings
import org.neo4j.kernel.api.ReadOperations
import org.neo4j.kernel.api.security.{AccessMode, SecurityContext}
import org.neo4j.kernel.api.security.AccessMode
import org.neo4j.kernel.configuration.Config
import org.neo4j.kernel.impl.query.{QueryExecutionMonitor, TransactionalContext}
import org.neo4j.kernel.{GraphDatabaseQueryService, api, monitoring}
Expand Down Expand Up @@ -71,8 +71,8 @@ class ExecutionEngine(val queryService: GraphDatabaseQueryService, logProvider:

private val cacheAccessor = new MonitoringCacheAccessor[String, (ExecutionPlan, Map[String, Any])](cacheMonitor)

private val preParsedQueries = new LRUCachev3_1[String, PreParsedQuery](getPlanCacheSize)
private val parsedQueries = new LRUCachev3_1[String, ParsedQuery](getPlanCacheSize)
private val preParsedQueries = new LFUCache[String, PreParsedQuery](getPlanCacheSize)
private val parsedQueries = new LFUCache[String, ParsedQuery](getPlanCacheSize)

private val javaValues = new RuntimeJavaValueConverter(isGraphKernelResultValue, identity)
private val scalaValues = new RuntimeScalaValueConverter(isGraphKernelResultValue, identity)
Expand Down Expand Up @@ -126,14 +126,14 @@ class ExecutionEngine(val queryService: GraphDatabaseQueryService, logProvider:
preParsedQueries.getOrElseUpdate(queryText, compiler.preParseQuery(queryText))

@throws(classOf[SyntaxException])
protected def planQuery(transactionalContext: TransactionalContext): (PreparedPlanExecution, TransactionalContextWrapperv3_1) = {
protected def planQuery(transactionalContext: TransactionalContext): (PreparedPlanExecution, TransactionalContextWrapperv3_2) = {
val executingQuery = transactionalContext.executingQuery()
val queryText = executingQuery.queryText()
executionMonitor.startQueryExecution(executingQuery)
val phaseTracer = compilationTracer.compileQuery(queryText)
try {

val externalTransactionalContext = new TransactionalContextWrapperv3_1(transactionalContext)
val externalTransactionalContext = new TransactionalContextWrapperv3_2(transactionalContext)
val preParsedQuery = try {
preParseQuery(queryText)
} catch {
Expand All @@ -157,7 +157,7 @@ class ExecutionEngine(val queryService: GraphDatabaseQueryService, logProvider:
// fetch plan cache
val cache = getOrCreateFromSchemaState(tc.readOperations, {
cacheMonitor.cacheFlushDetected(tc.statement)
val lruCache = new LRUCachev3_1[String, (ExecutionPlan, Map[String, Any])](getPlanCacheSize)
val lruCache = new LFUCache[String, (ExecutionPlan, Map[String, Any])](getPlanCacheSize)
new QueryCache(cacheAccessor, lruCache)
})

Expand Down Expand Up @@ -223,7 +223,7 @@ class ExecutionEngine(val queryService: GraphDatabaseQueryService, logProvider:
queryService, GraphDatabaseSettings.forbid_exhaustive_shortestpath,
GraphDatabaseSettings.forbid_exhaustive_shortestpath.getDefaultValue.toBoolean
)
if (((version != CypherVersion.v2_3) || (version != CypherVersion.v3_0) || (version != CypherVersion.v3_1)) &&
if (((version != CypherVersion.v2_3) || (version != CypherVersion.v3_1) || (version != CypherVersion.v3_2)) &&
(planner == CypherPlanner.greedy || planner == CypherPlanner.idp || planner == CypherPlanner.dp)) {
val message = s"Cannot combine configurations: ${GraphDatabaseSettings.cypher_parser_version.name}=${version.name} " +
s"with ${GraphDatabaseSettings.cypher_planner.name} = ${planner.name}"
Expand Down
Expand Up @@ -19,17 +19,17 @@
*/
package org.neo4j.cypher.internal

import org.neo4j.cypher.internal.spi.TransactionalContextWrapperv3_1
import org.neo4j.cypher.internal.spi.TransactionalContextWrapperv3_2
import org.neo4j.graphdb.Transaction
import org.neo4j.kernel.api.Statement

final case class TransactionInfo(tx: Transaction, isTopLevelTx: Boolean, statement: Statement)

trait ExecutionPlan {

def run(transactionalContext: TransactionalContextWrapperv3_1, executionMode: CypherExecutionMode, params: Map[String, Any]): ExecutionResult
def run(transactionalContext: TransactionalContextWrapperv3_2, executionMode: CypherExecutionMode, params: Map[String, Any]): ExecutionResult

def isPeriodicCommit: Boolean

def isStale(lastCommittedTxId: LastCommittedTxIdProvider, ctx: TransactionalContextWrapperv3_1): Boolean
def isStale(lastCommittedTxId: LastCommittedTxIdProvider, ctx: TransactionalContextWrapperv3_2): Boolean
}
Expand Up @@ -20,11 +20,10 @@
package org.neo4j.cypher.internal

import org.neo4j.cypher.internal.compiler.v3_2.CompilationPhaseTracer
import org.neo4j.cypher.internal.spi.TransactionalContextWrapperv3_1
import org.neo4j.kernel.api.Statement
import org.neo4j.cypher.internal.spi.TransactionalContextWrapperv3_2

trait ParsedQuery {
def isPeriodicCommit: Boolean
def plan(transactionContext: TransactionalContextWrapperv3_1, tracer: CompilationPhaseTracer): (ExecutionPlan, Map[String, Any])
def plan(transactionContext: TransactionalContextWrapperv3_2, tracer: CompilationPhaseTracer): (ExecutionPlan, Map[String, Any])
def hasErrors: Boolean
}
Expand Up @@ -27,48 +27,51 @@ import org.neo4j.kernel.GraphDatabaseQueryService
import org.neo4j.kernel.api.KernelAPI
import org.neo4j.kernel.monitoring.{Monitors => KernelMonitors}
import org.neo4j.logging.Log
import helpers.wrappersFor2_3._
import helpers.wrappersFor3_1._

import scala.collection.mutable

sealed trait PlannerSpec
final case class PlannerSpec_v2_3(planner: CypherPlanner, runtime: CypherRuntime) extends PlannerSpec
final case class PlannerSpec_v3_0(planner: CypherPlanner, runtime: CypherRuntime, updateStrategy: CypherUpdateStrategy) extends PlannerSpec
final case class PlannerSpec_v3_1(planner: CypherPlanner, runtime: CypherRuntime, updateStrategy: CypherUpdateStrategy) extends PlannerSpec

final case class PlannerSpec_v3_2(planner: CypherPlanner, runtime: CypherRuntime, updateStrategy: CypherUpdateStrategy) extends PlannerSpec

class PlannerFactory(graph: GraphDatabaseQueryService, kernelAPI: KernelAPI, kernelMonitors: KernelMonitors, log: Log,
config: CypherCompilerConfiguration) {

import helpers.wrappersFor2_3._
import helpers.wrappersFor3_0._

def create(spec: PlannerSpec_v2_3) = spec.planner match {
case CypherPlanner.rule => CompatibilityFor2_3Rule(graph, as2_3(config), Clock.SYSTEM_CLOCK, kernelMonitors, kernelAPI)
case _ => CompatibilityFor2_3Cost(graph, as2_3(config),
Clock.SYSTEM_CLOCK, kernelMonitors, kernelAPI, log, spec.planner, spec.runtime)
}

def create(spec: PlannerSpec_v3_0) = spec.planner match {
case CypherPlanner.rule => CompatibilityFor3_0Rule(graph, as3_0(config),CypherCompiler.CLOCK, kernelMonitors, kernelAPI)
case _ => CompatibilityFor3_0Cost(graph, as3_0(config),
CypherCompiler.CLOCK, kernelMonitors, kernelAPI, log, spec.planner, spec.runtime, spec.updateStrategy)
}

def create(spec: PlannerSpec_v3_1) = spec.planner match {
case CypherPlanner.rule => CompatibilityFor3_1Rule(graph, config, CypherCompiler.CLOCK, kernelMonitors, kernelAPI)
case _ => CompatibilityFor3_1Cost(graph, config,
case CypherPlanner.rule => CompatibilityFor3_1Rule(graph, as3_1(config), CypherCompiler.CLOCK, kernelMonitors, kernelAPI)
case _ => CompatibilityFor3_1Cost(graph, as3_1(config),
CypherCompiler.CLOCK, kernelMonitors, kernelAPI, log, spec.planner, spec.runtime,
spec.updateStrategy)
}

def create(spec: PlannerSpec_v3_2) = spec.planner match {
case CypherPlanner.rule => CompatibilityFor3_2Rule(graph, config, CypherCompiler.CLOCK, kernelMonitors, kernelAPI)
case _ => CompatibilityFor3_2Cost(graph, config, CypherCompiler.CLOCK, kernelMonitors, kernelAPI, log, spec.planner,
spec.runtime, spec.updateStrategy)
}

}

class PlannerCache(factory: PlannerFactory) {
private val cache_v2_3 = new mutable.HashMap[PlannerSpec_v2_3, CompatibilityFor2_3]
private val cache_v3_0 = new mutable.HashMap[PlannerSpec_v3_0, CompatibilityFor3_0]
private val cache_v3_1 = new mutable.HashMap[PlannerSpec_v3_1, CompatibilityFor3_1]
private val cache_v3_2 = new mutable.HashMap[PlannerSpec_v3_2, CompatibilityFor3_2]

def apply(spec: PlannerSpec_v2_3) = cache_v2_3.getOrElseUpdate(spec, factory.create(spec))
def apply(spec: PlannerSpec_v3_0) = cache_v3_0.getOrElseUpdate(spec, factory.create(spec))
def apply(spec: PlannerSpec_v3_1) = cache_v3_1.getOrElseUpdate(spec, factory.create(spec))

def apply(spec: PlannerSpec_v3_2) = cache_v3_2.getOrElseUpdate(spec, factory.create(spec))
}

class CachingValue[T]() {
Expand Down
Expand Up @@ -19,12 +19,12 @@
*/
package org.neo4j.cypher.internal

import org.neo4j.cypher.internal.spi.TransactionalContextWrapperv3_1
import org.neo4j.cypher.internal.spi.TransactionalContextWrapperv3_2

case class PreparedPlanExecution(plan: ExecutionPlan, executionMode: CypherExecutionMode, extractedParams: Map[String, Any]) {
def execute(transactionalContext: TransactionalContextWrapperv3_1, params: Map[String, Any]): ExecutionResult =
def execute(transactionalContext: TransactionalContextWrapperv3_2, params: Map[String, Any]): ExecutionResult =
plan.run(transactionalContext, executionMode, params ++ extractedParams)

def profile(transactionalContext: TransactionalContextWrapperv3_1, params: Map[String, Any]): ExecutionResult =
def profile(transactionalContext: TransactionalContextWrapperv3_2, params: Map[String, Any]): ExecutionResult =
plan.run(transactionalContext, CypherExecutionMode.profile, params ++ extractedParams)
}

0 comments on commit 2842110

Please sign in to comment.