diff --git a/community/cypher/cypher/pom.xml b/community/cypher/cypher/pom.xml index 695cea97fbd64..433c13df1c14b 100644 --- a/community/cypher/cypher/pom.xml +++ b/community/cypher/cypher/pom.xml @@ -190,7 +190,7 @@ org.neo4j neo4j-cypher-compiler-2.3 - 2.3.8 + 2.3.9 org.neo4j @@ -217,7 +217,7 @@ org.neo4j neo4j-cypher-compiler-3.1 - 3.1.0 + 3.1.1 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 2c517dfe720bb..a1dbe5c23bac5 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,14 +21,13 @@ package org.neo4j.cypher.internal.compatibility.v2_3 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.{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 ExceptionTranslatingQueryContext(inner: QueryContext) extends DelegatingQueryContext(inner) { override def setLabelsOnNode(node: Long, labelIds: Iterator[Int]): Int = diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/ExceptionTranslatingQueryContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/ExceptionTranslatingQueryContext.scala index bdc86aa78ca91..c227588ed1590 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/ExceptionTranslatingQueryContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/ExceptionTranslatingQueryContext.scala @@ -21,13 +21,13 @@ package org.neo4j.cypher.internal.compatibility.v3_1 import java.net.URL +import org.neo4j.cypher.internal.compiler.v3_1.IndexDescriptor import org.neo4j.cypher.internal.compiler.v3_1.commands.expressions.{Expander, KernelPredicate} import org.neo4j.cypher.internal.compiler.v3_1.pipes.matching.PatternNode import org.neo4j.cypher.internal.compiler.v3_1.spi._ import org.neo4j.cypher.internal.frontend.v3_1.SemanticDirection import org.neo4j.cypher.internal.spi.v3_1.ExceptionTranslationSupport import org.neo4j.graphdb.{Node, Path, PropertyContainer, Relationship} -import org.neo4j.kernel.api.index.IndexDescriptor import scala.collection.Iterator 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 new file mode 100644 index 0000000000000..583a2d3c13cc2 --- /dev/null +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/IndexDescriptorCompatibility.scala @@ -0,0 +1,33 @@ +/* + * 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.{ + IndexDescriptor => KernelIndexDescriptor, + IndexDescriptorFactory => KernelIndexDescriptorFactory} + +trait IndexDescriptorCompatibility { + implicit def cypherToKernel(index:CypherIndexDescriptor) = + KernelIndexDescriptorFactory.of( index.label, index.property ) + + implicit def kernelToCypher(index:KernelIndexDescriptor) = + CypherIndexDescriptor( index.getLabelId, index.getPropertyKeyId ) +} 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 35bb9499e507a..6c3f1bbc5da23 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,18 +20,17 @@ package org.neo4j.cypher.internal.spi.v2_3 import org.neo4j.cypher.MissingIndexException +import org.neo4j.cypher.internal.compiler.v2_3 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.IndexDescriptorCompatibility 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.{IndexDescriptor, InternalIndexState} -import org.neo4j.kernel.api.schema.NodePropertyDescriptor -import org.neo4j.kernel.api.schema.{IndexDescriptor => NewIndexDescriptor} +import org.neo4j.kernel.api.index.InternalIndexState +import org.neo4j.kernel.api.schema.{NodePropertyDescriptor, IndexDescriptor => NewIndexDescriptor} import org.neo4j.kernel.impl.transaction.log.TransactionIdStore import scala.collection.JavaConverters._ @@ -40,7 +39,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper) 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[v2_3.IndexDescriptor] = evalOrNone { val labelId = tc.statement.readOperations().labelGetForName(labelName) val propertyKeyId = tc.statement.readOperations().propertyKeyGetForName(propertyKey) @@ -56,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[v2_3.IndexDescriptor] = evalOrNone { val labelId = tc.statement.readOperations().labelGetForName(labelName) val propertyKeyId = tc.statement.readOperations().propertyKeyGetForName(propertyKey) @@ -67,7 +66,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper) private def evalOrNone[T](f: => Option[T]): Option[T] = try { f } catch { case _: SchemaKernelException => None } - private def getOnlineIndex(descriptor: NewIndexDescriptor): Option[IndexDescriptor] = + private def getOnlineIndex(descriptor: NewIndexDescriptor): Option[v2_3.IndexDescriptor] = tc.statement.readOperations().indexGetState(descriptor) match { case InternalIndexState.ONLINE => Some(descriptor) case _ => 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 3364698f9b757..7a0f7c66729ac 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 @@ -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} @@ -35,7 +35,7 @@ import org.neo4j.cypher.internal.compiler.v2_3.helpers.JavaConversionSupport._ import org.neo4j.cypher.internal.compiler.v2_3.pipes.matching.PatternNode import org.neo4j.cypher.internal.compiler.v2_3.spi._ import org.neo4j.cypher.internal.frontend.v2_3.{Bound, EntityNotFoundException, FailedIndexException, SemanticDirection} -import org.neo4j.cypher.internal.spi.{BeansAPIRelationshipIterator, IndexDescriptorCompatibility} +import org.neo4j.cypher.internal.spi.BeansAPIRelationshipIterator import org.neo4j.cypher.internal.spi.v3_2.TransactionalContextWrapper import org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService import org.neo4j.graphalgo.impl.path.ShortestPath @@ -47,7 +47,7 @@ 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 import org.neo4j.kernel.api.schema.{IndexDescriptorFactory, NodePropertyDescriptor, RelationshipPropertyDescriptor} import org.neo4j.kernel.api.{exceptions, _} import org.neo4j.kernel.impl.core.NodeManager @@ -127,10 +127,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) @@ -142,7 +142,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] @@ -190,12 +190,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 { @@ -222,7 +222,7 @@ 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 matchingNodes: PrimitiveLongIterator = range match { @@ -250,10 +250,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)) } @@ -455,7 +455,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(new NodePropertyDescriptor(labelId, propertyKeyId))) } catch { case _: AlreadyIndexedException => diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/ExceptionTranslatingPlanContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/ExceptionTranslatingPlanContext.scala index dbed70f9f97d7..0d8056a0589e0 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/ExceptionTranslatingPlanContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/ExceptionTranslatingPlanContext.scala @@ -19,13 +19,12 @@ */ package org.neo4j.cypher.internal.spi.v3_1 -import org.neo4j.cypher.internal.compiler.v3_1.InternalNotificationLogger +import org.neo4j.cypher.internal.compiler.v3_1.{IndexDescriptor, InternalNotificationLogger} import org.neo4j.cypher.internal.compiler.v3_1.pipes.EntityProducer import org.neo4j.cypher.internal.compiler.v3_1.pipes.matching.{ExpanderStep, TraversalMatcher} import org.neo4j.cypher.internal.compiler.v3_1.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 { diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/IndexDescriptorCompatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/IndexDescriptorCompatibility.scala similarity index 61% rename from community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/IndexDescriptorCompatibility.scala rename to community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/IndexDescriptorCompatibility.scala index e7c5f6ba8c024..90fbf2d7d72ed 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/IndexDescriptorCompatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/IndexDescriptorCompatibility.scala @@ -17,15 +17,15 @@ * 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 +package org.neo4j.cypher.internal.spi.v3_1 -import org.neo4j.kernel.api.index.IndexDescriptor -import org.neo4j.kernel.api.schema.IndexDescriptorFactory +import org.neo4j.cypher.internal.compiler.v3_1.{IndexDescriptor => CypherIndexDescriptor} +import org.neo4j.kernel.api.schema.{IndexDescriptor => KernelIndexDescriptor, IndexDescriptorFactory => KernelIndexDescriptorFactory} trait IndexDescriptorCompatibility { - implicit def toOldIndexDescriptor(index: org.neo4j.kernel.api.schema.IndexDescriptor): IndexDescriptor = - new IndexDescriptor(index.getLabelId(), index.getPropertyKeyId); + implicit def cypherToKernel(index:CypherIndexDescriptor) = + KernelIndexDescriptorFactory.of( index.label, index.property ) - implicit def toNewIndexDescriptor(index: IndexDescriptor): org.neo4j.kernel.api.schema.IndexDescriptor = - IndexDescriptorFactory.of(index.getLabelId(), index.getPropertyKeyId); + implicit def kernelToCypher(index:KernelIndexDescriptor) = + CypherIndexDescriptor( index.getLabelId, index.getPropertyKeyId ) } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundPlanContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundPlanContext.scala index 018dce2a98684..16128a27b66b6 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundPlanContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundPlanContext.scala @@ -23,22 +23,20 @@ import java.util.Optional import org.neo4j.cypher.MissingIndexException import org.neo4j.cypher.internal.LastCommittedTxIdProvider -import org.neo4j.cypher.internal.compiler.v3_1.InternalNotificationLogger import org.neo4j.cypher.internal.compiler.v3_1.pipes.EntityProducer import org.neo4j.cypher.internal.compiler.v3_1.pipes.matching.ExpanderStep import org.neo4j.cypher.internal.compiler.v3_1.spi._ +import org.neo4j.cypher.internal.compiler.v3_1.{InternalNotificationLogger, IndexDescriptor => CypherIndexDescriptor} import org.neo4j.cypher.internal.frontend.v3_1.symbols.CypherType import org.neo4j.cypher.internal.frontend.v3_1.{CypherExecutionException, symbols} -import org.neo4j.cypher.internal.spi.IndexDescriptorCompatibility 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 import org.neo4j.kernel.api.proc.Neo4jTypes.AnyType import org.neo4j.kernel.api.proc.{Neo4jTypes, QualifiedName => KernelQualifiedName} -import org.neo4j.kernel.api.schema.NodePropertyDescriptor -import org.neo4j.kernel.api.schema.{IndexDescriptor => NewIndexDescriptor} +import org.neo4j.kernel.api.schema.{NodePropertyDescriptor, IndexDescriptor => NewIndexDescriptor} import org.neo4j.kernel.impl.proc.Neo4jValue import org.neo4j.procedure.Mode @@ -48,7 +46,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper, logger: Inter 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) @@ -64,7 +62,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper, logger: Inter 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) @@ -75,7 +73,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper, logger: Inter private def evalOrNone[T](f: => Option[T]): Option[T] = try { f } catch { case _: SchemaKernelException => None } - private def getOnlineIndex(descriptor: NewIndexDescriptor): Option[IndexDescriptor] = + private def getOnlineIndex(descriptor: NewIndexDescriptor): Option[CypherIndexDescriptor] = tc.statement.readOperations().indexGetState(descriptor) match { case InternalIndexState.ONLINE => Some(descriptor) case _ => None diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundQueryContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundQueryContext.scala index f44bf75812c56..1473937021c1d 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundQueryContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundQueryContext.scala @@ -26,7 +26,7 @@ import org.neo4j.collection.RawIterator import org.neo4j.collection.primitive.PrimitiveLongIterator import org.neo4j.collection.primitive.base.Empty.EMPTY_PRIMITIVE_LONG_COLLECTION import org.neo4j.cypher.internal.compiler.v3_1.MinMaxOrdering.{BY_NUMBER, BY_STRING, BY_VALUE} -import org.neo4j.cypher.internal.compiler.v3_1._ +import org.neo4j.cypher.internal.compiler.v3_1.{IndexDescriptor => CypherIndexDescriptor,_} import org.neo4j.cypher.internal.compiler.v3_1.ast.convert.commands.DirectionConverter.toGraphDb import org.neo4j.cypher.internal.compiler.v3_1.commands.expressions import org.neo4j.cypher.internal.compiler.v3_1.commands.expressions.{KernelPredicate, OnlyDirectionExpander, TypeAndDirectionExpander} @@ -36,7 +36,7 @@ import org.neo4j.cypher.internal.compiler.v3_1.pipes.matching.PatternNode import org.neo4j.cypher.internal.compiler.v3_1.spi._ import org.neo4j.cypher.internal.frontend.v3_1.{Bound, EntityNotFoundException, FailedIndexException, SemanticDirection} import org.neo4j.cypher.internal.spi.v3_1.TransactionBoundQueryContext.IndexSearchMonitor -import org.neo4j.cypher.internal.spi.{BeansAPIRelationshipIterator, IndexDescriptorCompatibility} +import org.neo4j.cypher.internal.spi.BeansAPIRelationshipIterator import org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService import org.neo4j.cypher.{InternalException, internal} import org.neo4j.graphalgo.impl.path.ShortestPath @@ -51,7 +51,7 @@ import org.neo4j.kernel.api.constraints.{NodePropertyExistenceConstraint, Relati import org.neo4j.kernel.api.dbms.DbmsOperations import org.neo4j.kernel.api.exceptions.ProcedureException import org.neo4j.kernel.api.exceptions.schema.{AlreadyConstrainedException, AlreadyIndexedException} -import org.neo4j.kernel.api.index.{IndexDescriptor, InternalIndexState} +import org.neo4j.kernel.api.index.InternalIndexState import org.neo4j.kernel.api.proc.{QualifiedName => KernelQualifiedName} import org.neo4j.kernel.api.schema.{IndexDescriptorFactory, NodePropertyDescriptor, RelationshipPropertyDescriptor} import org.neo4j.kernel.impl.core.NodeManager @@ -136,12 +136,12 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper) new BeansAPIRelationshipIterator(relationships, entityAccessor) } - override def indexSeek(index: IndexDescriptor, value: Any) = { + override def indexSeek(index: CypherIndexDescriptor, value: Any) = { indexSearchMonitor.indexSeek(index, value) JavaConversionSupport.mapToScalaENFXSafe(txContext.statement.readOperations().nodesGetFromIndexSeek(index, value))(nodeOps.getById) } - override def indexSeekByRange(index: IndexDescriptor, value: Any) = value match { + override def indexSeekByRange(index: CypherIndexDescriptor, value: Any) = value match { case PrefixRange(prefix: String) => indexSeekByPrefixRange(index, prefix) @@ -152,7 +152,7 @@ final class TransactionBoundQueryContext(txContext: 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] @@ -200,12 +200,12 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper) } } - private def indexSeekByPrefixRange(index: IndexDescriptor, prefix: String): scala.Iterator[Node] = { + private def indexSeekByPrefixRange(index: CypherIndexDescriptor, prefix: String): scala.Iterator[Node] = { val indexedNodes = txContext.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 = txContext.statement.readOperations() val matchingNodes: PrimitiveLongIterator = (range match { @@ -232,7 +232,7 @@ final class TransactionBoundQueryContext(txContext: 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 = txContext.statement.readOperations() val matchingNodes: PrimitiveLongIterator = range match { @@ -260,16 +260,16 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper) JavaConversionSupport.mapToScalaENFXSafe(matchingNodes)(nodeOps.getById) } - override def indexScan(index: IndexDescriptor) = + override def indexScan(index: CypherIndexDescriptor) = mapToScalaENFXSafe(txContext.statement.readOperations().nodesGetFromIndexScan(index))(nodeOps.getById) - override def indexScanByContains(index: IndexDescriptor, value: String) = + override def indexScanByContains(index: CypherIndexDescriptor, value: String) = mapToScalaENFXSafe(txContext.statement.readOperations().nodesGetFromIndexContainsScan(index, value))(nodeOps.getById) - override def indexScanByEndsWith(index: IndexDescriptor, value: String) = + override def indexScanByEndsWith(index: CypherIndexDescriptor, value: String) = mapToScalaENFXSafe(txContext.statement.readOperations().nodesGetFromIndexEndsWithScan(index, value))(nodeOps.getById) - override def lockingUniqueIndexSeek(index: IndexDescriptor, value: Any): Option[Node] = { + override def lockingUniqueIndexSeek(index: CypherIndexDescriptor, value: Any): Option[Node] = { indexSearchMonitor.lockingUniqueIndexSeek(index, value) val nodeId = txContext.statement.readOperations().nodeGetFromUniqueIndexSeek(index, value) if (StatementConstants.NO_SUCH_NODE == nodeId) None else Some(nodeOps.getById(nodeId)) @@ -461,7 +461,7 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper) txContext.statement.readOperations().schemaStateGetOrCreate(key, javaCreator) } - override def addIndexRule(labelId: Int, propertyKeyId: Int): IdempotentResult[IndexDescriptor] = try { + override def addIndexRule(labelId: Int, propertyKeyId: Int): IdempotentResult[CypherIndexDescriptor] = try { IdempotentResult(txContext.statement.schemaWriteOperations().indexCreate(new NodePropertyDescriptor(labelId, propertyKeyId))) } catch { case _: AlreadyIndexedException => @@ -717,8 +717,8 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper) object TransactionBoundQueryContext { trait IndexSearchMonitor { - def indexSeek(index: IndexDescriptor, value: Any): Unit + def indexSeek(index: CypherIndexDescriptor, value: Any): Unit - def lockingUniqueIndexSeek(index: IndexDescriptor, value: Any): Unit + def lockingUniqueIndexSeek(index: CypherIndexDescriptor, value: Any): Unit } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexDescriptor.java b/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexDescriptor.java deleted file mode 100644 index 5afc13d454c7e..0000000000000 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexDescriptor.java +++ /dev/null @@ -1,89 +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.kernel.api.index; - -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; - -import static java.lang.String.format; - -/** - * This is a new version of the old IndexDescriptor interface created here only to allow - * older versions of Cypher to run on newer kernels. This is because Cypher supports older - * cypher-compiler modules to be instantiated and run within newer versions of Neo4j, and they - * assume certain kernel API's remain unchanged. However, the IndexDescriptor was refactored - * considerably during the 3.2 development process to allow for composite indexes and constraints. - * We should remove this class as soon as older Cypher compilers are re-released without any - * kernel dependency on this. - *

- * //TODO: Delete this class when 3.1.1 and 2.3.9 are released - */ -@Deprecated -public class IndexDescriptor -{ - private NodePropertyDescriptor descriptor; - - public IndexDescriptor( int labelId, int propertyKeyId ) - { - this.descriptor = new NodePropertyDescriptor( labelId, propertyKeyId ); - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj != null && obj instanceof IndexDescriptor ) - { - IndexDescriptor that = (IndexDescriptor) obj; - return this.descriptor.equals( that.descriptor ); - } - return false; - } - - @Override - public int hashCode() - { - return this.descriptor.hashCode(); - } - - /** - * @return label token id this index is for. - */ - public int getLabelId() - { - return descriptor.getLabelId(); - } - - /** - * @return property key token id this index is for. - */ - public int getPropertyKeyId() - { - return descriptor.getPropertyKeyId(); - } - - @Override - public String toString() - { - return format( ":label[%d](property[%d])", descriptor.getLabelId(), descriptor.getPropertyKeyId() ); - } -}