From 0cf9d0d504d4f35f507d4beeaad93bc03c6bb831 Mon Sep 17 00:00:00 2001 From: fickludd Date: Tue, 4 Apr 2017 13:22:19 +0200 Subject: [PATCH] Update cypher compatibility compiler to 2.3.10 --- community/cypher/cypher/pom.xml | 2 +- .../ExceptionTranslatingQueryContext.scala | 7 +- .../compatibility/v2_3/exceptionHandler.scala | 2 +- .../v2_3/IndexDescriptorCompatibility.scala | 35 --------- .../v2_3/SchemaDescriptorTranslation.scala | 54 +++++++++++++ .../v2_3/TransactionBoundPlanContext.scala | 16 ++-- .../v2_3/TransactionBoundQueryContext.scala | 75 +++++++++---------- enterprise/cypher/cypher/pom.xml | 2 +- 8 files changed, 104 insertions(+), 89 deletions(-) delete mode 100644 community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/IndexDescriptorCompatibility.scala create mode 100644 community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/SchemaDescriptorTranslation.scala diff --git a/community/cypher/cypher/pom.xml b/community/cypher/cypher/pom.xml index 0f4e7ac9a6867..4de38f77e01c0 100644 --- a/community/cypher/cypher/pom.xml +++ b/community/cypher/cypher/pom.xml @@ -185,7 +185,7 @@ org.neo4j neo4j-cypher-compiler-2.3 - 2.3.9 + 2.3.10 org.neo4j diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/ExceptionTranslatingQueryContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/ExceptionTranslatingQueryContext.scala index a1dbe5c23bac5..d650deebdb00f 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/ExceptionTranslatingQueryContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/ExceptionTranslatingQueryContext.scala @@ -21,7 +21,6 @@ package org.neo4j.cypher.internal.compatibility.v2_3 import java.net.URL -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} @@ -90,7 +89,7 @@ class ExceptionTranslatingQueryContext(inner: QueryContext) extends DelegatingQu override def dropIndexRule(labelId: Int, propertyKeyId: Int) = translateException(super.dropIndexRule(labelId, propertyKeyId)) - override def indexSeek(index: IndexDescriptor, value: Any): Iterator[Node] = + override def indexSeek(index: SchemaTypes.IndexDescriptor, value: Any): Iterator[Node] = translateException(super.indexSeek(index, value)) override def getNodesByLabel(id: Int): Iterator[Node] = @@ -105,7 +104,7 @@ class ExceptionTranslatingQueryContext(inner: QueryContext) extends DelegatingQu override def getOrCreateFromSchemaState[K, V](key: K, creator: => V): V = translateException(super.getOrCreateFromSchemaState(key, creator)) - override def upgrade(context: spi.QueryContext): LockingQueryContext = + override def upgrade(context: QueryContext): LockingQueryContext = translateException(super.upgrade(context)) override def createUniqueConstraint(labelId: Int, propertyKeyId: Int) = @@ -141,7 +140,7 @@ class ExceptionTranslatingQueryContext(inner: QueryContext) extends DelegatingQu override def getRelTypeName(id: Int) = translateException(super.getRelTypeName(id)) - override def lockingExactUniqueIndexSearch(index: IndexDescriptor, value: Any) = + override def lockingExactUniqueIndexSearch(index: SchemaTypes.IndexDescriptor, value: Any) = translateException(super.lockingExactUniqueIndexSearch(index, value)) override def commitAndRestartTx() = diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/exceptionHandler.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/exceptionHandler.scala index b62d366476315..d6fd5774bdc88 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/exceptionHandler.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/exceptionHandler.scala @@ -33,7 +33,7 @@ object exceptionHandler extends MapToPublicExceptions[CypherException] { throw new ProfilerStatisticsNotReadyException(cause) } - def incomparableValuesException(lhs: String, rhs: String, cause: Throwable) = new IncomparableValuesException(lhs, rhs, cause) + def incomparableValuesException(details:Option[String], lhs: String, rhs: String, cause: Throwable) = new IncomparableValuesException(details, lhs, rhs, cause) def unknownLabelException(s: String, cause: Throwable) = new UnknownLabelException(s, cause) diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/IndexDescriptorCompatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/IndexDescriptorCompatibility.scala deleted file mode 100644 index 31e8dcc04e8d9..0000000000000 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/IndexDescriptorCompatibility.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 . - */ -package org.neo4j.cypher.internal.spi.v2_3 - -import org.neo4j.cypher.internal.compiler.v2_3.{IndexDescriptor => CypherIndexDescriptor} -import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory -import org.neo4j.kernel.api.schema_new.index.{NewIndexDescriptor => KernelIndexDescriptor} - -trait IndexDescriptorCompatibility { - implicit def cypherToKernel(index: CypherIndexDescriptor): KernelIndexDescriptor = - NewIndexDescriptorFactory.forLabel(index.label, index.property) - - implicit def kernelToCypher(index: KernelIndexDescriptor): CypherIndexDescriptor = - if (index.schema().getPropertyIds().length == 1) - CypherIndexDescriptor(index.schema().getLabelId, index.schema().getPropertyIds()(0)) - else - throw new UnsupportedOperationException("Cypher 2.3 does not support composite indexes") -} diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/SchemaDescriptorTranslation.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/SchemaDescriptorTranslation.scala new file mode 100644 index 0000000000000..664435f34c672 --- /dev/null +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/SchemaDescriptorTranslation.scala @@ -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 . + */ +package org.neo4j.cypher.internal.spi.v2_3 + +import org.neo4j.cypher.internal.compiler.v2_3.spi.SchemaTypes +import org.neo4j.kernel.api.schema_new.constaints.{NodeExistenceConstraintDescriptor, RelExistenceConstraintDescriptor, UniquenessConstraintDescriptor} +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory +import org.neo4j.kernel.api.schema_new.index.{NewIndexDescriptor => KernelIndexDescriptor} + +trait SchemaDescriptorTranslation { + implicit def cypherToKernel(index: SchemaTypes.IndexDescriptor): KernelIndexDescriptor = + NewIndexDescriptorFactory.forLabel(index.labelId, index.propertyId) + + implicit def kernelToCypher(index: KernelIndexDescriptor): SchemaTypes.IndexDescriptor = + if (index.schema().getPropertyIds.length == 1) + SchemaTypes.IndexDescriptor(index.schema().getLabelId, index.schema().getPropertyIds()(0)) + else + throw new UnsupportedOperationException("Cypher 2.3 does not support composite indexes") + + implicit def kernelToCypher(index: UniquenessConstraintDescriptor): SchemaTypes.UniquenessConstraint = + if (index.schema().getPropertyIds.length == 1) + SchemaTypes.UniquenessConstraint(index.schema().getLabelId, index.schema().getPropertyIds()(0)) + else + throw new UnsupportedOperationException("Cypher 2.3 does not support composite constraints") + + implicit def kernelToCypher(index: NodeExistenceConstraintDescriptor): SchemaTypes.NodePropertyExistenceConstraint = + if (index.schema().getPropertyIds.length == 1) + SchemaTypes.NodePropertyExistenceConstraint(index.schema().getLabelId, index.schema().getPropertyIds()(0)) + else + throw new UnsupportedOperationException("Cypher 2.3 does not support composite constraints") + + implicit def kernelToCypher(index: RelExistenceConstraintDescriptor): SchemaTypes.RelationshipPropertyExistenceConstraint = + if (index.schema().getPropertyIds.length == 1) + SchemaTypes.RelationshipPropertyExistenceConstraint(index.schema().getRelTypeId, index.schema().getPropertyIds()(0)) + else + throw new UnsupportedOperationException("Cypher 2.3 does not support composite constraints") +} diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundPlanContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundPlanContext.scala index b92d4bdf6d115..d7426495478d2 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundPlanContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundPlanContext.scala @@ -20,28 +20,26 @@ package org.neo4j.cypher.internal.spi.v2_3 import org.neo4j.cypher.MissingIndexException -import org.neo4j.cypher.internal.compiler.v2_3.IndexDescriptor 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.v3_2.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.InternalIndexState import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory -import org.neo4j.kernel.api.schema_new.constaints.{ConstraintBoundary, ConstraintDescriptor} +import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor import org.neo4j.kernel.api.schema_new.index.{NewIndexDescriptor => KernelIndexDescriptor} import org.neo4j.kernel.impl.transaction.log.TransactionIdStore import scala.collection.JavaConverters._ class TransactionBoundPlanContext(tc: TransactionalContextWrapper) - 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 { + def getIndexRule(labelName: String, propertyKey: String): Option[SchemaTypes.IndexDescriptor] = evalOrNone { val labelId = tc.statement.readOperations().labelGetForName(labelName) val propertyKeyId = tc.statement.readOperations().propertyKeyGetForName(propertyKey) @@ -57,7 +55,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper) 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) @@ -68,13 +66,13 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper) private def evalOrNone[T](f: => Option[T]): Option[T] = try { f } catch { case _: SchemaKernelException => None } - private def getOnlineIndex(descriptor: KernelIndexDescriptor): 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) @@ -83,7 +81,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper) SchemaDescriptorFactory.forLabel(labelId, propertyKeyId) ).asScala.collectFirst { case constraint: ConstraintDescriptor if constraint.`type`() == ConstraintDescriptor.Type.UNIQUE => - ConstraintBoundary.map( constraint ).asInstanceOf[UniquenessConstraint] + SchemaTypes.UniquenessConstraint(labelId, propertyKeyId) } } catch { case _: KernelException => None diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundQueryContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundQueryContext.scala index 6205d62499997..7da6aaf0f6af3 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundQueryContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundQueryContext.scala @@ -45,12 +45,10 @@ import org.neo4j.graphdb._ import org.neo4j.graphdb.security.URLAccessValidationError 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.InternalIndexState -import org.neo4j.kernel.api.schema_new.IndexQuery -import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory -import org.neo4j.kernel.api.schema_new.constaints.{ConstraintBoundary, ConstraintDescriptorFactory} +import org.neo4j.kernel.api.schema_new.{IndexQuery, SchemaDescriptorFactory} +import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptorFactory import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory import org.neo4j.kernel.api.{exceptions, _} import org.neo4j.kernel.impl.core.NodeManager @@ -59,7 +57,7 @@ import scala.collection.JavaConverters._ import scala.collection.{Iterator, mutable} final class TransactionBoundQueryContext(tc: TransactionalContextWrapper) - extends TransactionBoundTokenContext(tc.statement) with QueryContext with IndexDescriptorCompatibility { + extends TransactionBoundTokenContext(tc.statement) with QueryContext with SchemaDescriptorTranslation { override val nodeOps = new NodeOperations override val relationshipOps = new RelationshipOperations @@ -130,10 +128,11 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper) new BeansAPIRelationshipIterator(relationships, nodeManager) } - def indexSeek(index: IndexDescriptor, value: Any) = - JavaConversionSupport.mapToScalaENFXSafe(tc.statement.readOperations().indexQuery(index, IndexQuery.exact(index.property, value)))(nodeOps.getById) + def indexSeek(index: SchemaTypes.IndexDescriptor, value: Any) = + JavaConversionSupport.mapToScalaENFXSafe( + tc.statement.readOperations().indexQuery(index, IndexQuery.exact(index.propertyId, value)))(nodeOps.getById) - def indexSeekByRange(index: IndexDescriptor, value: Any) = value match { + def indexSeekByRange(index: SchemaTypes.IndexDescriptor, value: Any) = value match { case PrefixRange(prefix: String) => indexSeekByPrefixRange(index, prefix) @@ -145,7 +144,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: SchemaTypes.IndexDescriptor, range: InequalitySeekRange[Any]): scala.Iterator[Node] = { val groupedRanges = range.groupBy { (bound: Bound[Any]) => bound.endPoint match { case n: Number => classOf[Number] @@ -193,53 +192,53 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper) } } - private def indexSeekByPrefixRange(index: IndexDescriptor, prefix: String): scala.Iterator[Node] = { - val indexedNodes = tc.statement.readOperations().indexQuery(index, IndexQuery.stringPrefix(index.property, prefix)) + private def indexSeekByPrefixRange(index: SchemaTypes.IndexDescriptor, prefix: String): scala.Iterator[Node] = { + val indexedNodes = tc.statement.readOperations().indexQuery(index, IndexQuery.stringPrefix(index.propertyId, prefix)) JavaConversionSupport.mapToScalaENFXSafe(indexedNodes)(nodeOps.getById) } - private def indexSeekByNumericalRange(index: IndexDescriptor, range: InequalitySeekRange[Number]): scala.Iterator[Node] = { + private def indexSeekByNumericalRange(index: SchemaTypes.IndexDescriptor, range: InequalitySeekRange[Number]): scala.Iterator[Node] = { val readOps = tc.statement.readOperations() val matchingNodes: PrimitiveLongIterator = (range match { case rangeLessThan: RangeLessThan[Number] => rangeLessThan.limit(BY_NUMBER).map { limit => - readOps.indexQuery(index, IndexQuery.range(index.property, null, false, limit.endPoint, limit.isInclusive)) + readOps.indexQuery(index, IndexQuery.range(index.propertyId, null, false, limit.endPoint, limit.isInclusive)) } case rangeGreaterThan: RangeGreaterThan[Number] => rangeGreaterThan.limit(BY_NUMBER).map { limit => - readOps.indexQuery(index, IndexQuery.range(index.property, limit.endPoint, limit.isInclusive, null, false)) + readOps.indexQuery(index, IndexQuery.range(index.propertyId, limit.endPoint, limit.isInclusive, null, false)) } case RangeBetween(rangeGreaterThan, rangeLessThan) => rangeGreaterThan.limit(BY_NUMBER).flatMap { greaterThanLimit => rangeLessThan.limit(BY_NUMBER).map { lessThanLimit => - readOps.indexQuery(index, IndexQuery.range(index.property, greaterThanLimit.endPoint, greaterThanLimit.isInclusive, lessThanLimit.endPoint, lessThanLimit.isInclusive)) + readOps.indexQuery(index, IndexQuery.range(index.propertyId, greaterThanLimit.endPoint, greaterThanLimit.isInclusive, lessThanLimit.endPoint, lessThanLimit.isInclusive)) } } }).getOrElse(EMPTY_PRIMITIVE_LONG_COLLECTION.iterator) JavaConversionSupport.mapToScalaENFXSafe(matchingNodes)(nodeOps.getById) } - private def indexSeekByStringRange(index: IndexDescriptor, range: InequalitySeekRange[String]): scala.Iterator[Node] = { + private def indexSeekByStringRange(index: SchemaTypes.IndexDescriptor, range: InequalitySeekRange[String]): scala.Iterator[Node] = { val readOps = tc.statement.readOperations() val matchingNodes: PrimitiveLongIterator = range match { case rangeLessThan: RangeLessThan[String] => rangeLessThan.limit(BY_STRING).map { limit => - readOps.indexQuery(index, IndexQuery.range(index.property, null, false, limit.endPoint.asInstanceOf[String], limit.isInclusive)) + readOps.indexQuery(index, IndexQuery.range(index.propertyId, null, false, limit.endPoint.asInstanceOf[String], limit.isInclusive)) }.getOrElse(EMPTY_PRIMITIVE_LONG_COLLECTION.iterator) case rangeGreaterThan: RangeGreaterThan[String] => rangeGreaterThan.limit(BY_STRING).map { limit => - readOps.indexQuery(index, IndexQuery.range(index.property, limit.endPoint.asInstanceOf[String], limit.isInclusive, null, false)) + readOps.indexQuery(index, IndexQuery.range(index.propertyId, limit.endPoint.asInstanceOf[String], limit.isInclusive, null, false)) }.getOrElse(EMPTY_PRIMITIVE_LONG_COLLECTION.iterator) case RangeBetween(rangeGreaterThan, rangeLessThan) => rangeGreaterThan.limit(BY_STRING).flatMap { greaterThanLimit => rangeLessThan.limit(BY_STRING).map { lessThanLimit => - readOps.indexQuery(index, IndexQuery.range(index.property, greaterThanLimit.endPoint.asInstanceOf[String], greaterThanLimit.isInclusive, lessThanLimit.endPoint.asInstanceOf[String], lessThanLimit.isInclusive)) + readOps.indexQuery(index, IndexQuery.range(index.propertyId, greaterThanLimit.endPoint.asInstanceOf[String], greaterThanLimit.isInclusive, lessThanLimit.endPoint.asInstanceOf[String], lessThanLimit.isInclusive)) } }.getOrElse(EMPTY_PRIMITIVE_LONG_COLLECTION.iterator) } @@ -247,11 +246,11 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper) JavaConversionSupport.mapToScalaENFXSafe(matchingNodes)(nodeOps.getById) } - def indexScan(index: IndexDescriptor) = - mapToScalaENFXSafe(tc.statement.readOperations().indexQuery(index, IndexQuery.exists(index.property)))(nodeOps.getById) + def indexScan(index: SchemaTypes.IndexDescriptor) = + mapToScalaENFXSafe(tc.statement.readOperations().indexQuery(index, IndexQuery.exists(index.propertyId)))(nodeOps.getById) - override def lockingExactUniqueIndexSearch(index: IndexDescriptor, value: Any): Option[Node] = { - val nodeId: Long = tc.statement.readOperations().nodeGetFromUniqueIndexSeek(index, IndexQuery.exact(index.property, value)) + override def lockingExactUniqueIndexSearch(index: SchemaTypes.IndexDescriptor, value: Any): Option[Node] = { + val nodeId: Long = tc.statement.readOperations().nodeGetFromUniqueIndexSeek(index, IndexQuery.exact(index.propertyId, value)) if (StatementConstants.NO_SUCH_NODE == nodeId) None else Some(nodeOps.getById(nodeId)) } @@ -452,7 +451,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[SchemaTypes.IndexDescriptor] = try { IdempotentResult(tc.statement.schemaWriteOperations().indexCreate(SchemaDescriptorFactory.forLabel(labelId, propertyKeyId))) } catch { case _: AlreadyIndexedException => @@ -467,42 +466,42 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper) def dropIndexRule(labelId: Int, propertyKeyId: Int) = tc.statement.schemaWriteOperations().indexDrop(NewIndexDescriptorFactory.forLabel( labelId, propertyKeyId )) - def createUniqueConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[UniquenessConstraint] = try { - IdempotentResult(ConstraintBoundary.mapUnique( - tc.statement.schemaWriteOperations().uniquePropertyConstraintCreate( - SchemaDescriptorFactory.forLabel(labelId, propertyKeyId) - ))) + def createUniqueConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[SchemaTypes.UniquenessConstraint] = try { + IdempotentResult( + tc.statement.schemaWriteOperations().uniquePropertyConstraintCreate( + SchemaDescriptorFactory.forLabel(labelId, propertyKeyId) + )) } catch { case existing: AlreadyConstrainedException => - IdempotentResult(existing.constraint().asInstanceOf[UniquenessConstraint], wasCreated = false) + IdempotentResult(SchemaTypes.UniquenessConstraint(labelId, propertyKeyId), wasCreated = false) } def dropUniqueConstraint(labelId: Int, propertyKeyId: Int) = tc.statement.schemaWriteOperations().constraintDrop(ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyKeyId)) - def createNodePropertyExistenceConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[NodePropertyExistenceConstraint] = + def createNodePropertyExistenceConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[SchemaTypes.NodePropertyExistenceConstraint] = try { - IdempotentResult(ConstraintBoundary.mapNode( + IdempotentResult( tc.statement.schemaWriteOperations().nodePropertyExistenceConstraintCreate( SchemaDescriptorFactory.forLabel(labelId, propertyKeyId) - )).asInstanceOf[NodePropertyExistenceConstraint]) // this cast can be resolved with 2.3.10 + )) } catch { case existing: AlreadyConstrainedException => - IdempotentResult(existing.constraint().asInstanceOf[NodePropertyExistenceConstraint], wasCreated = false) + IdempotentResult(SchemaTypes.NodePropertyExistenceConstraint(labelId, propertyKeyId), wasCreated = false) } def dropNodePropertyExistenceConstraint(labelId: Int, propertyKeyId: Int) = tc.statement.schemaWriteOperations().constraintDrop(ConstraintDescriptorFactory.existsForLabel(labelId, propertyKeyId)) - def createRelationshipPropertyExistenceConstraint(relTypeId: Int, propertyKeyId: Int): IdempotentResult[RelationshipPropertyExistenceConstraint] = + def createRelationshipPropertyExistenceConstraint(relTypeId: Int, propertyKeyId: Int): IdempotentResult[SchemaTypes.RelationshipPropertyExistenceConstraint] = try { - IdempotentResult(ConstraintBoundary.mapRelationship( + IdempotentResult( tc.statement.schemaWriteOperations().relationshipPropertyExistenceConstraintCreate( SchemaDescriptorFactory.forRelType(relTypeId, propertyKeyId) - )).asInstanceOf[RelationshipPropertyExistenceConstraint]) + )) } catch { case existing: AlreadyConstrainedException => - IdempotentResult(existing.constraint().asInstanceOf[RelationshipPropertyExistenceConstraint], wasCreated = false) + IdempotentResult(SchemaTypes.RelationshipPropertyExistenceConstraint(relTypeId, propertyKeyId), wasCreated = false) } def dropRelationshipPropertyExistenceConstraint(relTypeId: Int, propertyKeyId: Int) = diff --git a/enterprise/cypher/cypher/pom.xml b/enterprise/cypher/cypher/pom.xml index 9709d670acbce..654621ce86d1c 100644 --- a/enterprise/cypher/cypher/pom.xml +++ b/enterprise/cypher/cypher/pom.xml @@ -175,7 +175,7 @@ org.neo4j neo4j-cypher-compiler-2.3 - 2.3.9 + 2.3.10 org.neo4j