Skip to content

Commit

Permalink
Upped cypher compiler dependecy to 2.3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd committed Jan 24, 2017
1 parent 85454c5 commit 93b7b48
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 24 deletions.
2 changes: 1 addition & 1 deletion community/cypher/cypher/pom.xml
Expand Up @@ -185,7 +185,7 @@
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-compiler-2.3</artifactId>
<version>2.3.8</version>
<version>2.3.9</version>
<exclusions>
<exclusion>
<groupId>org.neo4j</groupId>
Expand Down
Expand Up @@ -21,14 +21,13 @@ package org.neo4j.cypher.internal.compatibility

import java.net.URL

import org.neo4j.cypher.internal.compiler.v2_3.spi
import org.neo4j.cypher.internal.compiler.v2_3.{IndexDescriptor, spi}
import org.neo4j.cypher.internal.compiler.v2_3.spi._
import org.neo4j.cypher.internal.frontend.v2_3.SemanticDirection
import org.neo4j.cypher.{ConstraintValidationException, CypherExecutionException}
import org.neo4j.graphdb.{ConstraintViolationException => KernelConstraintViolationException, Node, PropertyContainer, Relationship}
import org.neo4j.graphdb.{Node, PropertyContainer, Relationship, ConstraintViolationException => KernelConstraintViolationException}
import org.neo4j.kernel.api.TokenNameLookup
import org.neo4j.kernel.api.exceptions.KernelException
import org.neo4j.kernel.api.index.IndexDescriptor

class ExceptionTranslatingQueryContextFor2_3(inner: QueryContext) extends DelegatingQueryContext(inner) {
override def setLabelsOnNode(node: Long, labelIds: Iterator[Int]): Int =
Expand Down
@@ -0,0 +1,31 @@
/*
* 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.v2_3

import org.neo4j.cypher.internal.compiler.v2_3.{IndexDescriptor => CypherIndexDescriptor}
import org.neo4j.kernel.api.index.{IndexDescriptor => KernelIndexDescriptor}

trait IndexDescriptorCompatibility {
implicit def cypherToKernel(index:CypherIndexDescriptor) =
new KernelIndexDescriptor( index.label, index.property )

implicit def kernelToCypher(index:KernelIndexDescriptor) =
CypherIndexDescriptor( index.getLabelId, index.getPropertyKeyId )
}
Expand Up @@ -20,25 +20,25 @@
package org.neo4j.cypher.internal.spi.v2_3

import org.neo4j.cypher.MissingIndexException
import org.neo4j.cypher.internal.compiler.v2_3.{IndexDescriptor => CypherIndexDescriptor}
import org.neo4j.cypher.internal.compiler.v2_3.pipes.EntityProducer
import org.neo4j.cypher.internal.compiler.v2_3.pipes.matching.ExpanderStep
import org.neo4j.cypher.internal.compiler.v2_3.spi._

import org.neo4j.cypher.internal.spi.TransactionalContextWrapper
import org.neo4j.graphdb.Node
import org.neo4j.kernel.api.constraints.UniquenessConstraint
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.{InternalIndexState, IndexDescriptor => KernelIndexDescriptor}
import org.neo4j.kernel.impl.transaction.log.TransactionIdStore

import scala.collection.JavaConverters._

class TransactionBoundPlanContext(tc: TransactionalContextWrapper)
extends TransactionBoundTokenContext(tc.statement) with PlanContext {
extends TransactionBoundTokenContext(tc.statement) with PlanContext with IndexDescriptorCompatibility {

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

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

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

Expand All @@ -65,7 +65,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper)
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[CypherIndexDescriptor] =
tc.statement.readOperations().indexGetState(descriptor) match {
case InternalIndexState.ONLINE => Some(descriptor)
case _ => None
Expand Down
Expand Up @@ -26,7 +26,7 @@ import org.neo4j.collection.primitive.PrimitiveLongIterator
import org.neo4j.collection.primitive.base.Empty.EMPTY_PRIMITIVE_LONG_COLLECTION
import org.neo4j.cypher.InternalException
import org.neo4j.cypher.internal.compiler.v2_3.MinMaxOrdering.{BY_NUMBER, BY_STRING, BY_VALUE}
import org.neo4j.cypher.internal.compiler.v2_3._
import org.neo4j.cypher.internal.compiler.v2_3.{IndexDescriptor => CypherIndexDescriptor, _}
import org.neo4j.cypher.internal.compiler.v2_3.ast.convert.commands.DirectionConverter.toGraphDb
import org.neo4j.cypher.internal.compiler.v2_3.commands.expressions
import org.neo4j.cypher.internal.compiler.v2_3.commands.expressions.{KernelPredicate, OnlyDirectionExpander, TypeAndDirectionExpander}
Expand All @@ -46,15 +46,15 @@ import org.neo4j.graphdb.traversal.{Evaluators, TraversalDescription, Uniqueness
import org.neo4j.kernel.GraphDatabaseQueryService
import org.neo4j.kernel.api.constraints.{NodePropertyExistenceConstraint, RelationshipPropertyExistenceConstraint, UniquenessConstraint}
import org.neo4j.kernel.api.exceptions.schema.{AlreadyConstrainedException, AlreadyIndexedException}
import org.neo4j.kernel.api.index.{IndexDescriptor, InternalIndexState}
import org.neo4j.kernel.api.index.{InternalIndexState, IndexDescriptor => KernelIndexDescriptor}
import org.neo4j.kernel.api.{exceptions, _}
import org.neo4j.kernel.impl.core.NodeManager

import scala.collection.JavaConverters._
import scala.collection.{Iterator, mutable}

final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
extends TransactionBoundTokenContext(tc.statement) with QueryContext {
extends TransactionBoundTokenContext(tc.statement) with QueryContext with IndexDescriptorCompatibility {

override val nodeOps = new NodeOperations
override val relationshipOps = new RelationshipOperations
Expand Down Expand Up @@ -125,10 +125,10 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
new BeansAPIRelationshipIterator(relationships, nodeManager)
}

def indexSeek(index: IndexDescriptor, value: Any) =
def indexSeek(index: CypherIndexDescriptor, value: Any) =
JavaConversionSupport.mapToScalaENFXSafe(tc.statement.readOperations().nodesGetFromIndexSeek(index, value))(nodeOps.getById)

def indexSeekByRange(index: IndexDescriptor, value: Any) = value match {
def indexSeekByRange(index: CypherIndexDescriptor, value: Any) = value match {

case PrefixRange(prefix: String) =>
indexSeekByPrefixRange(index, prefix)
Expand All @@ -140,7 +140,7 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
throw new InternalException(s"Unsupported index seek by range: $range")
}

private def indexSeekByPrefixRange(index: IndexDescriptor, range: InequalitySeekRange[Any]): scala.Iterator[Node] = {
private def indexSeekByPrefixRange(index: CypherIndexDescriptor, range: InequalitySeekRange[Any]): scala.Iterator[Node] = {
val groupedRanges = range.groupBy { (bound: Bound[Any]) =>
bound.endPoint match {
case n: Number => classOf[Number]
Expand Down Expand Up @@ -188,12 +188,12 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
}
}

private def indexSeekByPrefixRange(index: IndexDescriptor, prefix: String): scala.Iterator[Node] = {
private def indexSeekByPrefixRange(index: CypherIndexDescriptor, prefix: String): scala.Iterator[Node] = {
val indexedNodes = tc.statement.readOperations().nodesGetFromIndexRangeSeekByPrefix(index, prefix)
JavaConversionSupport.mapToScalaENFXSafe(indexedNodes)(nodeOps.getById)
}

private def indexSeekByNumericalRange(index: IndexDescriptor, range: InequalitySeekRange[Number]): scala.Iterator[Node] = {
private def indexSeekByNumericalRange(index: CypherIndexDescriptor, range: InequalitySeekRange[Number]): scala.Iterator[Node] = {
val readOps = tc.statement.readOperations()
val matchingNodes: PrimitiveLongIterator = (range match {

Expand All @@ -220,9 +220,9 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
JavaConversionSupport.mapToScalaENFXSafe(matchingNodes)(nodeOps.getById)
}

private def indexSeekByStringRange(index: IndexDescriptor, range: InequalitySeekRange[String]): scala.Iterator[Node] = {
private def indexSeekByStringRange(index: CypherIndexDescriptor, range: InequalitySeekRange[String]): scala.Iterator[Node] = {
val readOps = tc.statement.readOperations()
val propertyKeyId = index.getPropertyKeyId
val propertyKeyId = index.property
val matchingNodes: PrimitiveLongIterator = range match {

case rangeLessThan: RangeLessThan[String] =>
Expand All @@ -249,10 +249,10 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
JavaConversionSupport.mapToScalaENFXSafe(matchingNodes)(nodeOps.getById)
}

def indexScan(index: IndexDescriptor) =
def indexScan(index: CypherIndexDescriptor) =
mapToScalaENFXSafe(tc.statement.readOperations().nodesGetFromIndexScan(index))(nodeOps.getById)

override def lockingExactUniqueIndexSearch(index: IndexDescriptor, value: Any): Option[Node] = {
override def lockingExactUniqueIndexSearch(index: CypherIndexDescriptor, value: Any): Option[Node] = {
val nodeId: Long = tc.statement.readOperations().nodeGetFromUniqueIndexSeek(index, value)
if (StatementConstants.NO_SUCH_NODE == nodeId) None else Some(nodeOps.getById(nodeId))
}
Expand Down Expand Up @@ -454,7 +454,7 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
tc.statement.readOperations().schemaStateGetOrCreate(key, javaCreator)
}

def addIndexRule(labelId: Int, propertyKeyId: Int): IdempotentResult[IndexDescriptor] = try {
def addIndexRule(labelId: Int, propertyKeyId: Int): IdempotentResult[CypherIndexDescriptor] = try {
IdempotentResult(tc.statement.schemaWriteOperations().indexCreate(labelId, propertyKeyId))
} catch {
case _: AlreadyIndexedException =>
Expand All @@ -465,7 +465,7 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
}

def dropIndexRule(labelId: Int, propertyKeyId: Int) =
tc.statement.schemaWriteOperations().indexDrop(new IndexDescriptor(labelId, propertyKeyId))
tc.statement.schemaWriteOperations().indexDrop(new KernelIndexDescriptor(labelId, propertyKeyId))

def createUniqueConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[UniquenessConstraint] = try {
IdempotentResult(tc.statement.schemaWriteOperations().uniquePropertyConstraintCreate(labelId, propertyKeyId))
Expand Down

0 comments on commit 93b7b48

Please sign in to comment.