Skip to content

Commit

Permalink
Merge pull request #9116 from fickludd/3.1-cypher-compiler-3.0.9
Browse files Browse the repository at this point in the history
3.1 Update Cypher compiler dependency to 3.0.9
  • Loading branch information
eebus committed Apr 4, 2017
2 parents ea3d6b7 + c4326db commit 4dd0911
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,14 @@ LIMIT with an expression that does not depend on variables
`toBoolean()` on invalid types

// new parameter syntax $
Delete node from a list
Delete node from a list
Delete relationship from a list
Use dynamic property lookup based on parameters when there is no type information
Use dynamic property lookup based on parameters when there is lhs type information
Use dynamic property lookup based on parameters when there is rhs type information
Use collection lookup based on parameters when there is no type information
Use collection lookup based on parameters when there is lhs type information
Fail at runtime when attempting to index with an Int into a Map
Fail at runtime when trying to index into a map with a non-string
Fail at runtime when attempting to index with a String into a Collection
Fail at runtime when trying to index into a list with a list
Fail at runtime when trying to index something which is not a map or collection
`percentileDisc()`
`percentileCont()`
`percentileCont()` failing on bad arguments
`percentileDisc()` failing on bad arguments
`percentileDisc()` failing in more involved query
Using `keys()` on a parameter map
Use params in pattern matching predicates
Matching with many predicates and larger pattern
ORDER BY with negative parameter for LIMIT should not generate errors
Start the result from the second row by param
Get rows in the middle by param
Using null in AND
Using null in OR
Using null in XOR
Using null in IN
Creating nodes from an unwound parameter list
Unwind with merge

// unsupported pattern comprehensions
Pattern comprehension and ORDER BY
Expand All @@ -76,8 +54,3 @@ Fail when comparing parameters to nodes
Comparing nodes to properties
Fail when comparing nodes to relationships
Fail when comparing relationships to nodes

// error conditions should give null
Handling non-string operands for STARTS WITH
Handling non-string operands for CONTAINS
Handling non-string operands for ENDS WITH
2 changes: 1 addition & 1 deletion community/cypher/cypher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-compiler-3.0</artifactId>
<version>3.0.8</version>
<version>3.0.9</version>
<exclusions>
<exclusion>
<groupId>org.neo4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ object exceptionHandlerFor3_0 extends MapToPublicExceptions[CypherException] {
throw new ProfilerStatisticsNotReadyException(cause)
}

override def incomparableValuesException(lhs: String, rhs: String, cause: Throwable) =
incomparableValuesException(None, lhs, rhs, cause)

def incomparableValuesException(details: Option[String], lhs: String, rhs: String, cause: Throwable) = new IncomparableValuesException(details, lhs, rhs, cause)

def patternException(message: String, cause: Throwable) = new PatternException(message, cause)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import java.net.URL

import org.neo4j.cypher.internal.compiler.v3_0.commands.expressions.{Expander, KernelPredicate}
import org.neo4j.cypher.internal.compiler.v3_0.pipes.matching.PatternNode
import org.neo4j.cypher.internal.compiler.v3_0.spi.SchemaTypes.IndexDescriptor
import org.neo4j.cypher.internal.compiler.v3_0.spi._
import org.neo4j.cypher.internal.frontend.v3_0.SemanticDirection
import org.neo4j.cypher.internal.spi.v3_0.ExceptionTranslationSupport
import org.neo4j.graphdb.{Node, Path, PropertyContainer, Relationship}
import org.neo4j.kernel.api.index.IndexDescriptor

import scala.collection.Iterator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ object wrappersFor3_0 {
config.idpMaxTableSize,
config.idpIterationDuration,
config.errorIfShortestPathFallbackUsedAtRuntime,
config.errorIfShortestPathHasCommonNodesAtRuntime,
config.legacyCsvQuoteEscaping,
config.nonIndexedLabelWarningThreshold)

/** This is awful but needed until 3_0 is updated no to send in the tracer here */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ package org.neo4j.cypher.internal.spi.v3_0

import org.neo4j.cypher.internal.compiler.v3_0.pipes.EntityProducer
import org.neo4j.cypher.internal.compiler.v3_0.pipes.matching.{ExpanderStep, TraversalMatcher}
import org.neo4j.cypher.internal.compiler.v3_0.spi.{GraphStatistics, PlanContext, ProcedureSignature, QualifiedProcedureName}
import org.neo4j.cypher.internal.compiler.v3_0.spi.SchemaTypes.{IndexDescriptor, UniquenessConstraint}
import org.neo4j.cypher.internal.compiler.v3_0.spi._
import org.neo4j.graphdb.Node
import org.neo4j.kernel.api.constraints.UniquenessConstraint
import org.neo4j.kernel.api.index.IndexDescriptor

class ExceptionTranslatingPlanContext(inner: PlanContext) extends PlanContext with ExceptionTranslationSupport {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2002-2017 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.cypher.internal.spi.v3_0

import org.neo4j.cypher.internal.compiler.v3_0.spi.SchemaTypes
import org.neo4j.kernel.api.constraints.{
RelationshipPropertyExistenceConstraint => KernelRPEC,
NodePropertyExistenceConstraint => KernelNPEC,
UniquenessConstraint => KernelUniquenessConstraint}
import org.neo4j.kernel.api.index.{IndexDescriptor => KernelIndexDescriptor}

trait SchemaDescriptionTranslation {
implicit def toKernel( index: SchemaTypes.IndexDescriptor ): KernelIndexDescriptor =
new KernelIndexDescriptor(index.labelId, index.propertyId)

implicit def toCypher( index: KernelIndexDescriptor ): SchemaTypes.IndexDescriptor =
SchemaTypes.IndexDescriptor(index.getLabelId, index.getPropertyKeyId)

implicit def toKernel( constraint: SchemaTypes.UniquenessConstraint ): KernelUniquenessConstraint =
new KernelUniquenessConstraint(constraint.labelId, constraint.propertyId)

implicit def toCypher( constraint: KernelUniquenessConstraint ): SchemaTypes.UniquenessConstraint =
SchemaTypes.UniquenessConstraint(constraint.label, constraint.propertyKey)

implicit def toKernel( constraint: SchemaTypes.NodePropertyExistenceConstraint ): KernelNPEC =
new KernelNPEC(constraint.labelId, constraint.propertyId)

implicit def toCypher( constraint: KernelNPEC ): SchemaTypes.NodePropertyExistenceConstraint =
SchemaTypes.NodePropertyExistenceConstraint(constraint.label, constraint.propertyKey)

implicit def toKernel( constraint: SchemaTypes.RelationshipPropertyExistenceConstraint ): KernelRPEC =
new KernelRPEC(constraint.relTypeId, constraint.propertyId)

implicit def toCypher( constraint: KernelRPEC ): SchemaTypes.RelationshipPropertyExistenceConstraint =
SchemaTypes.RelationshipPropertyExistenceConstraint(constraint.relationshipType, constraint.propertyKey)

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ import org.neo4j.cypher.internal.frontend.v3_0.symbols.CypherType
import org.neo4j.cypher.internal.frontend.v3_0.{CypherExecutionException, symbols}
import org.neo4j.cypher.internal.spi.TransactionalContextWrapperv3_1
import org.neo4j.graphdb.Node
import org.neo4j.kernel.api.constraints.UniquenessConstraint
import org.neo4j.kernel.api.constraints.{UniquenessConstraint => KernelUniquenessConstraint}
import org.neo4j.kernel.api.exceptions.KernelException
import org.neo4j.kernel.api.exceptions.schema.SchemaKernelException
import org.neo4j.kernel.api.index.{IndexDescriptor, InternalIndexState}
import org.neo4j.kernel.api.index.{IndexDescriptor => KernelIndexDescriptor, InternalIndexState}
import org.neo4j.kernel.api.proc.Neo4jTypes.AnyType
import org.neo4j.kernel.api.proc.{ QualifiedName, Neo4jTypes}
import org.neo4j.procedure.Mode

import scala.collection.JavaConverters._

class TransactionBoundPlanContext(tc: TransactionalContextWrapperv3_1)
extends TransactionBoundTokenContext(tc.statement) with PlanContext {
extends TransactionBoundTokenContext(tc.statement) with PlanContext with SchemaDescriptionTranslation {

@Deprecated
def getIndexRule(labelName: String, propertyKey: String): Option[IndexDescriptor] = evalOrNone {
def getIndexRule(labelName: String, propertyKey: String): Option[SchemaTypes.IndexDescriptor] = evalOrNone {
val labelId = tc.statement.readOperations().labelGetForName(labelName)
val propertyKeyId = tc.statement.readOperations().propertyKeyGetForName(propertyKey)

Expand All @@ -58,7 +58,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapperv3_1)
onlineIndexDescriptors.nonEmpty
}

def getUniqueIndexRule(labelName: String, propertyKey: String): Option[IndexDescriptor] = evalOrNone {
def getUniqueIndexRule(labelName: String, propertyKey: String): Option[SchemaTypes.IndexDescriptor] = evalOrNone {
val labelId = tc.statement.readOperations().labelGetForName(labelName)
val propertyKeyId = tc.statement.readOperations().propertyKeyGetForName(propertyKey)

Expand All @@ -69,19 +69,19 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapperv3_1)
private def evalOrNone[T](f: => Option[T]): Option[T] =
try { f } catch { case _: SchemaKernelException => None }

private def getOnlineIndex(descriptor: IndexDescriptor): Option[IndexDescriptor] =
private def getOnlineIndex(descriptor: KernelIndexDescriptor): Option[SchemaTypes.IndexDescriptor] =
tc.statement.readOperations().indexGetState(descriptor) match {
case InternalIndexState.ONLINE => Some(descriptor)
case _ => None
}

def getUniquenessConstraint(labelName: String, propertyKey: String): Option[UniquenessConstraint] = try {
def getUniquenessConstraint(labelName: String, propertyKey: String): Option[SchemaTypes.UniquenessConstraint] = try {
val labelId = tc.statement.readOperations().labelGetForName(labelName)
val propertyKeyId = tc.statement.readOperations().propertyKeyGetForName(propertyKey)

import scala.collection.JavaConverters._
tc.statement.readOperations().constraintsGetForLabelAndPropertyKey(labelId, propertyKeyId).asScala.collectFirst {
case unique: UniquenessConstraint => unique
case unique: KernelUniquenessConstraint => unique
}
} catch {
case _: KernelException => None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import scala.collection.Iterator
import scala.collection.JavaConverters._

final class TransactionBoundQueryContext(val transactionalContext: TransactionalContextWrapperv3_0)(implicit indexSearchMonitor: IndexSearchMonitor)
extends TransactionBoundTokenContext(transactionalContext.statement) with QueryContext {
extends TransactionBoundTokenContext(transactionalContext.statement) with QueryContext with SchemaDescriptionTranslation {

type EntityAccessor = NodeManager

Expand Down Expand Up @@ -134,17 +134,19 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
new BeansAPIRelationshipIterator(relationships, entityAccessor)
}

override def indexSeek(index: IndexDescriptor, value: Any) = {
indexSearchMonitor.indexSeek(index, value)
JavaConversionSupport.mapToScalaENFXSafe(transactionalContext.statement.readOperations().nodesGetFromIndexSeek(index, value))(nodeOps.getById)
override def indexSeek(index: SchemaTypes.IndexDescriptor, value: Any) = {
indexSearchMonitor.indexSeek(toKernel(index), value)
JavaConversionSupport.mapToScalaENFXSafe(
transactionalContext.statement.readOperations().nodesGetFromIndexSeek(toKernel(index), value)
)(nodeOps.getById)
}

override def indexSeekByRange(index: IndexDescriptor, value: Any) = value match {
override def indexSeekByRange(index: SchemaTypes.IndexDescriptor, value: Any) = value match {

case PrefixRange(prefix: String) =>
indexSeekByPrefixRange(index, prefix)
indexSeekByPrefixRange(toKernel(index), prefix)
case range: InequalitySeekRange[Any] =>
indexSeekByPrefixRange(index, range)
indexSeekByPrefixRange(toKernel(index), range)

case range =>
throw new InternalException(s"Unsupported index seek by range: $range")
Expand Down Expand Up @@ -259,16 +261,16 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
JavaConversionSupport.mapToScalaENFXSafe(matchingNodes)(nodeOps.getById)
}

override def indexScan(index: IndexDescriptor) =
override def indexScan(index: SchemaTypes.IndexDescriptor) =
mapToScalaENFXSafe(transactionalContext.statement.readOperations().nodesGetFromIndexScan(index))(nodeOps.getById)

override def indexScanByContains(index: IndexDescriptor, value: String) =
override def indexScanByContains(index: SchemaTypes.IndexDescriptor, value: String) =
mapToScalaENFXSafe(transactionalContext.statement.readOperations().nodesGetFromIndexContainsScan(index, value))(nodeOps.getById)

override def indexScanByEndsWith(index: IndexDescriptor, value: String) =
override def indexScanByEndsWith(index: SchemaTypes.IndexDescriptor, value: String) =
mapToScalaENFXSafe(transactionalContext.statement.readOperations().nodesGetFromIndexEndsWithScan(index, value))(nodeOps.getById)

override def lockingUniqueIndexSeek(index: IndexDescriptor, value: Any): Option[Node] = {
override def lockingUniqueIndexSeek(index: SchemaTypes.IndexDescriptor, value: Any): Option[Node] = {
indexSearchMonitor.lockingUniqueIndexSeek(index, value)
val nodeId = transactionalContext.statement.readOperations().nodeGetFromUniqueIndexSeek(index, value)
if (StatementConstants.NO_SUCH_NODE == nodeId) None else Some(nodeOps.getById(nodeId))
Expand Down Expand Up @@ -492,7 +494,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
transactionalContext.statement.readOperations().schemaStateGetOrCreate(key, javaCreator)
}

override def addIndexRule(labelId: Int, propertyKeyId: Int): IdempotentResult[IndexDescriptor] = try {
override def addIndexRule(labelId: Int, propertyKeyId: Int): IdempotentResult[SchemaTypes.IndexDescriptor] = try {
IdempotentResult(transactionalContext.statement.schemaWriteOperations().indexCreate(labelId, propertyKeyId))
} catch {
case _: AlreadyIndexedException =>
Expand All @@ -505,7 +507,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
override def dropIndexRule(labelId: Int, propertyKeyId: Int) =
transactionalContext.statement.schemaWriteOperations().indexDrop(new IndexDescriptor(labelId, propertyKeyId))

override def createUniqueConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[UniquenessConstraint] = try {
override def createUniqueConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[SchemaTypes.UniquenessConstraint] = try {
IdempotentResult(transactionalContext.statement.schemaWriteOperations().uniquePropertyConstraintCreate(labelId, propertyKeyId))
} catch {
case existing: AlreadyConstrainedException =>
Expand All @@ -515,7 +517,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
override def dropUniqueConstraint(labelId: Int, propertyKeyId: Int) =
transactionalContext.statement.schemaWriteOperations().constraintDrop(new UniquenessConstraint(labelId, propertyKeyId))

override def createNodePropertyExistenceConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[NodePropertyExistenceConstraint] =
override def createNodePropertyExistenceConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[SchemaTypes.NodePropertyExistenceConstraint] =
try {
IdempotentResult(transactionalContext.statement.schemaWriteOperations().nodePropertyExistenceConstraintCreate(labelId, propertyKeyId))
} catch {
Expand All @@ -526,7 +528,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
override def dropNodePropertyExistenceConstraint(labelId: Int, propertyKeyId: Int) =
transactionalContext.statement.schemaWriteOperations().constraintDrop(new NodePropertyExistenceConstraint(labelId, propertyKeyId))

override def createRelationshipPropertyExistenceConstraint(relTypeId: Int, propertyKeyId: Int): IdempotentResult[RelationshipPropertyExistenceConstraint] =
override def createRelationshipPropertyExistenceConstraint(relTypeId: Int, propertyKeyId: Int): IdempotentResult[SchemaTypes.RelationshipPropertyExistenceConstraint] =
try {
IdempotentResult(transactionalContext.statement.schemaWriteOperations().relationshipPropertyExistenceConstraintCreate(relTypeId, propertyKeyId))
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
*/
package org.neo4j.cypher.internal.spi.v3_1

import org.neo4j.cypher.internal.compiler.v3_1.spi.SchemaTypes.IndexDescriptor
import org.neo4j.cypher.internal.compiler.v3_1.spi.SchemaTypes
import org.neo4j.kernel.api.index.{IndexDescriptor => KernelIndexDescriptor}

trait IndexDescriptorCompatibility {
implicit def toKernelIndexDescriptor(descriptor: IndexDescriptor): KernelIndexDescriptor =
trait SchemaDescriptorTranslation {
implicit def toKernel(descriptor: SchemaTypes.IndexDescriptor): KernelIndexDescriptor =
new KernelIndexDescriptor(descriptor.labelId, descriptor.propertyId)

implicit def toCypherIndexDescriptor(descriptor: KernelIndexDescriptor): IndexDescriptor =
new IndexDescriptor(descriptor.getLabelId, descriptor.getPropertyKeyId)
implicit def toCypher(descriptor: KernelIndexDescriptor): SchemaTypes.IndexDescriptor =
SchemaTypes.IndexDescriptor(descriptor.getLabelId, descriptor.getPropertyKeyId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.neo4j.kernel.api.{ReadOperations, Statement => KernelStatement}
object TransactionBoundGraphStatistics {
def apply(ops: ReadOperations) = new StatisticsCompletingGraphStatistics(new BaseTransactionBoundGraphStatistics(ops))

private class BaseTransactionBoundGraphStatistics(operations: ReadOperations) extends GraphStatistics with IndexDescriptorCompatibility {
private class BaseTransactionBoundGraphStatistics(operations: ReadOperations) extends GraphStatistics with SchemaDescriptorTranslation {

import NameId._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import org.neo4j.procedure.Mode
import scala.collection.JavaConverters._

class TransactionBoundPlanContext(tc: TransactionalContextWrapperv3_1, logger: InternalNotificationLogger)
extends TransactionBoundTokenContext(tc.statement) with PlanContext with IndexDescriptorCompatibility {
extends TransactionBoundTokenContext(tc.statement) with PlanContext with SchemaDescriptorTranslation {

@Deprecated
def getIndexRule(labelName: String, propertyKey: String): Option[IndexDescriptor] = evalOrNone {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import scala.collection.Iterator
import scala.collection.JavaConverters._

final class TransactionBoundQueryContext(val transactionalContext: TransactionalContextWrapperv3_1)(implicit indexSearchMonitor: IndexSearchMonitor)
extends TransactionBoundTokenContext(transactionalContext.statement) with QueryContext with IndexDescriptorCompatibility {
extends TransactionBoundTokenContext(transactionalContext.statement) with QueryContext with SchemaDescriptorTranslation {

type EntityAccessor = NodeManager

Expand Down

0 comments on commit 4dd0911

Please sign in to comment.