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 index 887b22c423051..bbf10c132327d 100644 --- 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 @@ -20,12 +20,13 @@ 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} +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) = - IndexDescriptorFactory.of(index.label, index.property) + NewIndexDescriptorFactory.forLabel(index.label, index.property) implicit def kernelToCypher(index: KernelIndexDescriptor) = - CypherIndexDescriptor(index.getLabelId, index.getPropertyKeyId) + CypherIndexDescriptor(index.schema().getLabelId, index.schema().getPropertyIds()(0)) } 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 f092faff13f4f..b5d640529636b 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 @@ -30,7 +30,8 @@ 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.{NodePropertyDescriptor, IndexDescriptor => KernelIndexDescriptor} +import org.neo4j.kernel.api.schema.{NodePropertyDescriptor} +import org.neo4j.kernel.api.schema_new.index.{NewIndexDescriptor => KernelIndexDescriptor} import org.neo4j.kernel.impl.transaction.log.TransactionIdStore import scala.collection.JavaConverters._ 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 11d6fb6447d81..9c1fd58d73854 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 @@ -48,7 +48,8 @@ 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.{IndexDescriptorFactory, NodePropertyDescriptor, RelationshipPropertyDescriptor} +import org.neo4j.kernel.api.schema.{NodePropertyDescriptor, RelationshipPropertyDescriptor} +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory import org.neo4j.kernel.api.{exceptions, _} import org.neo4j.kernel.impl.core.NodeManager @@ -212,10 +213,7 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper) case RangeBetween(rangeGreaterThan, rangeLessThan) => rangeGreaterThan.limit(BY_NUMBER).flatMap { greaterThanLimit => rangeLessThan.limit(BY_NUMBER).map { lessThanLimit => - readOps.nodesGetFromIndexRangeSeekByNumber( - index, - greaterThanLimit.endPoint, greaterThanLimit.isInclusive, - lessThanLimit.endPoint, lessThanLimit.isInclusive) + readOps.nodesGetFromIndexRangeSeekByNumber(index, greaterThanLimit.endPoint, greaterThanLimit.isInclusive, lessThanLimit.endPoint, lessThanLimit.isInclusive) } } }).getOrElse(EMPTY_PRIMITIVE_LONG_COLLECTION.iterator) @@ -239,10 +237,7 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper) case RangeBetween(rangeGreaterThan, rangeLessThan) => rangeGreaterThan.limit(BY_STRING).flatMap { greaterThanLimit => rangeLessThan.limit(BY_STRING).map { lessThanLimit => - readOps.nodesGetFromIndexRangeSeekByString( - index, - greaterThanLimit.endPoint.asInstanceOf[String], greaterThanLimit.isInclusive, - lessThanLimit.endPoint.asInstanceOf[String], lessThanLimit.isInclusive) + readOps.nodesGetFromIndexRangeSeekByString(index, greaterThanLimit.endPoint.asInstanceOf[String], greaterThanLimit.isInclusive, lessThanLimit.endPoint.asInstanceOf[String], lessThanLimit.isInclusive) } }.getOrElse(EMPTY_PRIMITIVE_LONG_COLLECTION.iterator) } @@ -468,7 +463,7 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper) } def dropIndexRule(labelId: Int, propertyKeyId: Int) = - tc.statement.schemaWriteOperations().indexDrop(IndexDescriptorFactory.of( labelId, propertyKeyId )) + tc.statement.schemaWriteOperations().indexDrop(NewIndexDescriptorFactory.forLabel( labelId, propertyKeyId )) def createUniqueConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[UniquenessConstraint] = try { IdempotentResult(tc.statement.schemaWriteOperations().uniquePropertyConstraintCreate(new NodePropertyDescriptor(labelId, diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/IndexDescriptorCompatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/IndexDescriptorCompatibility.scala index e05d8c5b0366d..e69870c32b757 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/IndexDescriptorCompatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/IndexDescriptorCompatibility.scala @@ -20,12 +20,13 @@ package org.neo4j.cypher.internal.spi.v3_1 import org.neo4j.cypher.internal.compiler.v3_1.{IndexDescriptor => CypherIndexDescriptor} -import org.neo4j.kernel.api.schema.{IndexDescriptor => KernelIndexDescriptor, IndexDescriptorFactory} +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) = - IndexDescriptorFactory.of(index.label, index.property) + NewIndexDescriptorFactory.forLabel(index.label, index.property) implicit def kernelToCypher(index: KernelIndexDescriptor) = - CypherIndexDescriptor(index.getLabelId, index.getPropertyKeyId) + CypherIndexDescriptor(index.schema().getLabelId, index.schema().getPropertyIds()(0)) } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundGraphStatistics.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundGraphStatistics.scala index d77be047fea1c..2e8763255fb27 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundGraphStatistics.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundGraphStatistics.scala @@ -24,7 +24,7 @@ import org.neo4j.cypher.internal.compiler.v3_1.spi.{GraphStatistics, StatisticsC import org.neo4j.cypher.internal.frontend.v3_1.{LabelId, NameId, PropertyKeyId, RelTypeId} import org.neo4j.kernel.api.ReadOperations import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException -import org.neo4j.kernel.api.schema.IndexDescriptorFactory +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory object TransactionBoundGraphStatistics { def apply(ops: ReadOperations) = new StatisticsCompletingGraphStatistics(new BaseTransactionBoundGraphStatistics(ops)) @@ -35,7 +35,7 @@ object TransactionBoundGraphStatistics { def indexSelectivity(label: LabelId, property: PropertyKeyId): Option[Selectivity] = try { - val indexDescriptor = IndexDescriptorFactory.of( label, property ) + val indexDescriptor = NewIndexDescriptorFactory.forLabel( label, property ) val labeledNodes = operations.countsForNodeWithoutTxState( label ).toDouble // Probability of any node with the given label, to have a property with a given value @@ -51,7 +51,7 @@ object TransactionBoundGraphStatistics { def indexPropertyExistsSelectivity(label: LabelId, property: PropertyKeyId): Option[Selectivity] = try { - val indexDescriptor = IndexDescriptorFactory.of( label, property ) + val indexDescriptor = NewIndexDescriptorFactory.forLabel( label, property ) val labeledNodes = operations.countsForNodeWithoutTxState( label ).toDouble // Probability of any node with the given label, to have a given property 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 7d073d7b0bf0f..f10b755c0deb2 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 @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.LastCommittedTxIdProvider 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} +import org.neo4j.cypher.internal.compiler.v3_1.{IndexDescriptor, InternalNotificationLogger} import org.neo4j.cypher.internal.frontend.v3_1.symbols.CypherType import org.neo4j.cypher.internal.frontend.v3_1.{CypherExecutionException, symbols} import org.neo4j.graphdb.Node @@ -36,7 +36,8 @@ import org.neo4j.kernel.api.exceptions.schema.SchemaKernelException 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, IndexDescriptor => KernelIndexDescriptor} +import org.neo4j.kernel.api.schema.NodePropertyDescriptor +import org.neo4j.kernel.api.schema_new.index.{NewIndexDescriptor => KernelIndexDescriptor} import org.neo4j.kernel.impl.proc.Neo4jValue import org.neo4j.procedure.Mode 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 61abe0025dee2..dcf0817c070cb 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 @@ -35,8 +35,8 @@ import org.neo4j.cypher.internal.compiler.v3_1.helpers.JavaConversionSupport._ 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 +import org.neo4j.cypher.internal.spi.v3_1.TransactionBoundQueryContext.IndexSearchMonitor import org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService import org.neo4j.cypher.{InternalException, internal} import org.neo4j.graphalgo.impl.path.ShortestPath @@ -53,7 +53,8 @@ import org.neo4j.kernel.api.exceptions.ProcedureException import org.neo4j.kernel.api.exceptions.schema.{AlreadyConstrainedException, AlreadyIndexedException} 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.api.schema.{NodePropertyDescriptor, RelationshipPropertyDescriptor} +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory import org.neo4j.kernel.impl.core.NodeManager import org.neo4j.kernel.impl.locking.ResourceTypes @@ -211,21 +212,18 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper) case rangeLessThan: RangeLessThan[Number] => rangeLessThan.limit(BY_NUMBER).map { limit => - readOps.nodesGetFromIndexRangeSeekByNumber( index, null, false, limit.endPoint, limit.isInclusive ) + readOps.nodesGetFromIndexRangeSeekByNumber(index, null, false, limit.endPoint, limit.isInclusive) } case rangeGreaterThan: RangeGreaterThan[Number] => rangeGreaterThan.limit(BY_NUMBER).map { limit => - readOps.nodesGetFromIndexRangeSeekByNumber( index, limit.endPoint, limit.isInclusive, null, false ) + readOps.nodesGetFromIndexRangeSeekByNumber(index, limit.endPoint, limit.isInclusive, null, false) } case RangeBetween(rangeGreaterThan, rangeLessThan) => rangeGreaterThan.limit(BY_NUMBER).flatMap { greaterThanLimit => rangeLessThan.limit(BY_NUMBER).map { lessThanLimit => - readOps.nodesGetFromIndexRangeSeekByNumber( - index, - greaterThanLimit.endPoint, greaterThanLimit.isInclusive, - lessThanLimit.endPoint, lessThanLimit.isInclusive ) + readOps.nodesGetFromIndexRangeSeekByNumber(index, greaterThanLimit.endPoint, greaterThanLimit.isInclusive, lessThanLimit.endPoint, lessThanLimit.isInclusive) } } }).getOrElse(EMPTY_PRIMITIVE_LONG_COLLECTION.iterator) @@ -238,21 +236,18 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper) case rangeLessThan: RangeLessThan[String] => rangeLessThan.limit(BY_STRING).map { limit => - readOps.nodesGetFromIndexRangeSeekByString( index, null, false, limit.endPoint.asInstanceOf[String], limit.isInclusive ) + readOps.nodesGetFromIndexRangeSeekByString(index, 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.nodesGetFromIndexRangeSeekByString( index, limit.endPoint.asInstanceOf[String], limit.isInclusive, null, false ) + readOps.nodesGetFromIndexRangeSeekByString(index, 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.nodesGetFromIndexRangeSeekByString( - index, - greaterThanLimit.endPoint.asInstanceOf[String], greaterThanLimit.isInclusive, - lessThanLimit.endPoint.asInstanceOf[String], lessThanLimit.isInclusive ) + readOps.nodesGetFromIndexRangeSeekByString(index, greaterThanLimit.endPoint.asInstanceOf[String], greaterThanLimit.isInclusive, lessThanLimit.endPoint.asInstanceOf[String], lessThanLimit.isInclusive) } }.getOrElse(EMPTY_PRIMITIVE_LONG_COLLECTION.iterator) } @@ -472,7 +467,7 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper) } override def dropIndexRule(labelId: Int, propertyKeyId: Int) = - txContext.statement.schemaWriteOperations().indexDrop(IndexDescriptorFactory.of( labelId, propertyKeyId )) + txContext.statement.schemaWriteOperations().indexDrop(NewIndexDescriptorFactory.forLabel( labelId, propertyKeyId )) override def createUniqueConstraint(labelId: Int, propertyKeyId: Int): IdempotentResult[UniquenessConstraint] = try { IdempotentResult(txContext.statement.schemaWriteOperations().uniquePropertyConstraintCreate(new NodePropertyDescriptor(labelId, propertyKeyId))) diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/IndexDescriptorCompatibility.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/IndexDescriptorCompatibility.scala index 6ef5fce2700ce..7dc04497756d4 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/IndexDescriptorCompatibility.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/IndexDescriptorCompatibility.scala @@ -20,12 +20,13 @@ package org.neo4j.cypher.internal.spi.v3_2 import org.neo4j.cypher.internal.compiler.v3_2.{IndexDescriptor => CypherIndexDescriptor} -import org.neo4j.kernel.api.schema.{IndexDescriptor => KernelIndexDescriptor, NodeMultiPropertyDescriptor, NodePropertyDescriptor, IndexDescriptorFactory} +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) = - IndexDescriptorFactory.of(index.label, index.property) + NewIndexDescriptorFactory.forLabel(index.label, index.property) implicit def kernelToCypher(index: KernelIndexDescriptor) = - CypherIndexDescriptor(index.getLabelId, index.getPropertyKeyId) + CypherIndexDescriptor(index.schema().getLabelId, index.schema().getPropertyIds()(0)) } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundGraphStatistics.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundGraphStatistics.scala index 4ab30ffebc47b..7b1dd326fe407 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundGraphStatistics.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundGraphStatistics.scala @@ -24,7 +24,7 @@ import org.neo4j.cypher.internal.frontend.v3_2.{LabelId, NameId, PropertyKeyId, import org.neo4j.cypher.internal.ir.v3_2.{Cardinality, Selectivity} import org.neo4j.kernel.api.ReadOperations import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException -import org.neo4j.kernel.api.schema.IndexDescriptorFactory +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory object TransactionBoundGraphStatistics { def apply(ops: ReadOperations) = new StatisticsCompletingGraphStatistics(new BaseTransactionBoundGraphStatistics(ops)) @@ -35,7 +35,7 @@ object TransactionBoundGraphStatistics { def indexSelectivity(label: LabelId, property: PropertyKeyId): Option[Selectivity] = try { - val indexDescriptor = IndexDescriptorFactory.of( label, property ) + val indexDescriptor = NewIndexDescriptorFactory.forLabel( label, property ) val labeledNodes = operations.countsForNodeWithoutTxState( label ).toDouble // Probability of any node with the given label, to have a property with a given value @@ -51,7 +51,7 @@ object TransactionBoundGraphStatistics { def indexPropertyExistsSelectivity(label: LabelId, property: PropertyKeyId): Option[Selectivity] = try { - val indexDescriptor = IndexDescriptorFactory.of( label, property ) + val indexDescriptor = NewIndexDescriptorFactory.forLabel( label, property ) val labeledNodes = operations.countsForNodeWithoutTxState( label ).toDouble // Probability of any node with the given label, to have a given property diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundPlanContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundPlanContext.scala index 1dedd0091c0eb..5e89ff1f88ace 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundPlanContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundPlanContext.scala @@ -35,7 +35,7 @@ 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 => KernelIndexDescriptor} +import org.neo4j.kernel.api.schema_new.index.{NewIndexDescriptor => KernelIndexDescriptor} import org.neo4j.kernel.impl.proc.Neo4jValue import org.neo4j.procedure.Mode @@ -67,7 +67,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper, logger: Inter // here we do not need to use getOnlineIndex method because uniqueness constraint creation is synchronous val index = tc.statement.readOperations().uniqueIndexGetForLabelAndPropertyKey(new NodePropertyDescriptor(labelId, propertyKeyId)) - Some(IndexDescriptor(index.getLabelId, index.getPropertyKeyId)) + Some(IndexDescriptor(index.schema().getLabelId, index.schema().getPropertyIds()(0))) } private def evalOrNone[T](f: => Option[T]): Option[T] = @@ -79,7 +79,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper, logger: Inter private def getOnlineIndex(descriptor: KernelIndexDescriptor): Option[IndexDescriptor] = tc.statement.readOperations().indexGetState(descriptor) match { - case InternalIndexState.ONLINE => Some(IndexDescriptor(descriptor.getLabelId, descriptor.getPropertyKeyId)) + case InternalIndexState.ONLINE => Some(IndexDescriptor(descriptor.schema().getLabelId, descriptor.schema().getPropertyIds()(0))) case _ => None } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContext.scala index d0e1868309bf2..11d37d78a7a33 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContext.scala @@ -22,10 +22,10 @@ package org.neo4j.cypher.internal.spi.v3_2 import java.net.URL import java.util.function.Predicate -import org.neo4j.cypher.internal.compiler.v3_2.IndexDescriptor.toKernelEncode 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_2.IndexDescriptor.toKernelEncode import org.neo4j.cypher.internal.compiler.v3_2.MinMaxOrdering.{BY_NUMBER, BY_STRING, BY_VALUE} import org.neo4j.cypher.internal.compiler.v3_2._ import org.neo4j.cypher.internal.compiler.v3_2.ast.convert.commands.DirectionConverter.toGraphDb @@ -54,7 +54,7 @@ import org.neo4j.kernel.api.exceptions.schema.{AlreadyConstrainedException, Alre import org.neo4j.kernel.api.index.InternalIndexState import org.neo4j.kernel.api.proc.CallableUserAggregationFunction.Aggregator import org.neo4j.kernel.api.proc.{QualifiedName => KernelQualifiedName} -import org.neo4j.kernel.api.schema.{IndexDescriptorFactory, NodeMultiPropertyDescriptor, NodePropertyDescriptor, RelationshipPropertyDescriptor} +import org.neo4j.kernel.api.schema.{NodeMultiPropertyDescriptor, NodePropertyDescriptor, RelationshipPropertyDescriptor} import org.neo4j.kernel.impl.core.NodeManager import org.neo4j.kernel.impl.locking.ResourceTypes @@ -212,21 +212,18 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional case rangeLessThan: RangeLessThan[Number] => rangeLessThan.limit(BY_NUMBER).map { limit => - readOps.nodesGetFromIndexRangeSeekByNumber( index, null, false, limit.endPoint, limit.isInclusive ) + readOps.nodesGetFromIndexRangeSeekByNumber(index, null, false, limit.endPoint, limit.isInclusive) } case rangeGreaterThan: RangeGreaterThan[Number] => rangeGreaterThan.limit(BY_NUMBER).map { limit => - readOps.nodesGetFromIndexRangeSeekByNumber( index, limit.endPoint, limit.isInclusive, null, false ) + readOps.nodesGetFromIndexRangeSeekByNumber(index, limit.endPoint, limit.isInclusive, null, false) } case RangeBetween(rangeGreaterThan, rangeLessThan) => rangeGreaterThan.limit(BY_NUMBER).flatMap { greaterThanLimit => rangeLessThan.limit(BY_NUMBER).map { lessThanLimit => - readOps.nodesGetFromIndexRangeSeekByNumber( - index, - greaterThanLimit.endPoint, greaterThanLimit.isInclusive, - lessThanLimit.endPoint, lessThanLimit.isInclusive ) + readOps.nodesGetFromIndexRangeSeekByNumber(index, greaterThanLimit.endPoint, greaterThanLimit.isInclusive, lessThanLimit.endPoint, lessThanLimit.isInclusive) } } }).getOrElse(EMPTY_PRIMITIVE_LONG_COLLECTION.iterator) @@ -239,21 +236,18 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional case rangeLessThan: RangeLessThan[String] => rangeLessThan.limit(BY_STRING).map { limit => - readOps.nodesGetFromIndexRangeSeekByString( index, null, false, limit.endPoint.asInstanceOf[String], limit.isInclusive ) + readOps.nodesGetFromIndexRangeSeekByString(index, 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.nodesGetFromIndexRangeSeekByString( index, limit.endPoint.asInstanceOf[String], limit.isInclusive, null, false ) + readOps.nodesGetFromIndexRangeSeekByString(index, 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.nodesGetFromIndexRangeSeekByString( - index, - greaterThanLimit.endPoint.asInstanceOf[String], greaterThanLimit.isInclusive, - lessThanLimit.endPoint.asInstanceOf[String], lessThanLimit.isInclusive ) + readOps.nodesGetFromIndexRangeSeekByString(index, greaterThanLimit.endPoint.asInstanceOf[String], greaterThanLimit.isInclusive, lessThanLimit.endPoint.asInstanceOf[String], lessThanLimit.isInclusive) } }.getOrElse(EMPTY_PRIMITIVE_LONG_COLLECTION.iterator) } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java index f9501f9ce64ff..d05113aed072e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java @@ -46,7 +46,6 @@ import org.neo4j.kernel.api.proc.ProcedureSignature; import org.neo4j.kernel.api.proc.QualifiedName; import org.neo4j.kernel.api.proc.UserFunctionSignature; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema.RelationshipPropertyDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; @@ -122,7 +121,7 @@ public interface ReadOperations * * @throws org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexSeek( IndexDescriptor index, Object value ) + PrimitiveLongIterator nodesGetFromIndexSeek( NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException; /** @@ -130,7 +129,7 @@ PrimitiveLongIterator nodesGetFromIndexSeek( IndexDescriptor index, Object value * * @throws org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( IndexDescriptor index, String prefix ) + PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( NewIndexDescriptor index, String prefix ) throws IndexNotFoundKernelException; /** @@ -138,7 +137,7 @@ PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( IndexDescriptor index, * * @throws org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( IndexDescriptor index, Number lower, boolean includeLower, Number upper, boolean includeUpper ) + PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( NewIndexDescriptor index, Number lower, boolean includeLower, Number upper, boolean includeUpper ) throws IndexNotFoundKernelException; /** @@ -146,7 +145,7 @@ PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( IndexDescriptor index, * * @throws org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( IndexDescriptor index, String lower, boolean includeLower, String upper, boolean includeUpper ) + PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( NewIndexDescriptor index, String lower, boolean includeLower, String upper, boolean includeUpper ) throws IndexNotFoundKernelException; /** @@ -154,7 +153,7 @@ PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( IndexDescriptor index, * * @throws org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexScan( IndexDescriptor index ) + PrimitiveLongIterator nodesGetFromIndexScan( NewIndexDescriptor index ) throws IndexNotFoundKernelException; /** @@ -162,7 +161,7 @@ PrimitiveLongIterator nodesGetFromIndexScan( IndexDescriptor index ) * * @throws org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexContainsScan( IndexDescriptor index, String term ) + PrimitiveLongIterator nodesGetFromIndexContainsScan( NewIndexDescriptor index, String term ) throws IndexNotFoundKernelException; /** @@ -170,7 +169,7 @@ PrimitiveLongIterator nodesGetFromIndexContainsScan( IndexDescriptor index, Stri * * @throws org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexEndsWithScan( IndexDescriptor index, String suffix ) + PrimitiveLongIterator nodesGetFromIndexEndsWithScan( NewIndexDescriptor index, String suffix ) throws IndexNotFoundKernelException; /** @@ -201,10 +200,10 @@ RelationshipIterator nodeGetRelationships( long nodeId, * * @throws org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException if no such index found. */ - long nodeGetFromUniqueIndexSeek( IndexDescriptor index, Object value ) throws IndexNotFoundKernelException, + long nodeGetFromUniqueIndexSeek( NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException; - long nodesCountIndexed( IndexDescriptor index, long nodeId, Object value ) + long nodesCountIndexed( NewIndexDescriptor index, long nodeId, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException; boolean nodeExists( long nodeId ); @@ -526,10 +525,10 @@ LegacyIndexHits relationshipLegacyIndexQuery( String indexName, Object queryOrQu */ long countsForRelationshipWithoutTxState( int startLabelId, int typeId, int endLabelId ); - DoubleLongRegister indexUpdatesAndSize( IndexDescriptor index, DoubleLongRegister target ) + DoubleLongRegister indexUpdatesAndSize( NewIndexDescriptor index, DoubleLongRegister target ) throws IndexNotFoundKernelException; - DoubleLongRegister indexSample( IndexDescriptor index, DoubleLongRegister target ) + DoubleLongRegister indexSample( NewIndexDescriptor index, DoubleLongRegister target ) throws IndexNotFoundKernelException; //=========================================== diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/ConstraintEnforcingEntityOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/ConstraintEnforcingEntityOperations.java index afffb7d033ed6..6e455215af367 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/ConstraintEnforcingEntityOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/ConstraintEnforcingEntityOperations.java @@ -151,7 +151,7 @@ private void validateNoExistingNodeWithLabelAndProperty( KernelStatement state, indexEntryResourceId( index.getLabelId(), index.getPropertyKeyId(), Strings.prettyPrint( value ) ) ); - long existing = entityReadOperations.nodeGetFromUniqueIndexSeek( state, index, value ); + long existing = entityReadOperations.nodeGetFromUniqueIndexSeek( state, IndexBoundary.map( index ), value ); if ( existing != NO_SUCH_NODE && existing != modifiedNode ) { throw new UniquePropertyConstraintViolationKernelException( index.getLabelId(), @@ -263,7 +263,7 @@ public PrimitiveLongIterator nodesGetForLabel( KernelStatement state, int labelI } @Override - public PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement state, IndexDescriptor index, Object value ) + public PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement state, NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException { return entityReadOperations.nodesGetFromIndexSeek( state, index, value ); @@ -271,7 +271,7 @@ public PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement state, Index @Override public PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( KernelStatement statement, - IndexDescriptor index, + NewIndexDescriptor index, Number lower, boolean includeLower, Number upper, boolean includeUpper ) throws IndexNotFoundKernelException @@ -282,7 +282,7 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( KernelStatement @Override public PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( KernelStatement statement, - IndexDescriptor index, + NewIndexDescriptor index, String lower, boolean includeLower, String upper, boolean includeUpper ) throws IndexNotFoundKernelException @@ -293,14 +293,14 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( KernelStatement @Override public PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( KernelStatement state, - IndexDescriptor index, String prefix ) + NewIndexDescriptor index, String prefix ) throws IndexNotFoundKernelException { return entityReadOperations.nodesGetFromIndexRangeSeekByPrefix( state, index, prefix ); } @Override - public PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement state, IndexDescriptor index ) + public PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement state, NewIndexDescriptor index ) throws IndexNotFoundKernelException { return entityReadOperations.nodesGetFromIndexScan( state, index ); @@ -309,15 +309,15 @@ public PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement state, Index @Override public long nodeGetFromUniqueIndexSeek( KernelStatement state, - IndexDescriptor index, + NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException { - assertIndexOnline( state, IndexBoundary.map( index ) ); + assertIndexOnline( state, index ); // TODO: Support composite index, either by allowing value to be an array, or by creating a new method - int labelId = index.getLabelId(); - int propertyKeyId = index.getPropertyKeyId(); + int labelId = index.schema().getLabelId(); + int propertyKeyId = index.schema().getPropertyIds()[0]; String stringVal = ""; if ( null != value ) { @@ -351,21 +351,21 @@ public long nodeGetFromUniqueIndexSeek( } @Override - public long nodesCountIndexed( KernelStatement statement, IndexDescriptor index, long nodeId, Object value ) + public long nodesCountIndexed( KernelStatement statement, NewIndexDescriptor index, long nodeId, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException { return entityReadOperations.nodesCountIndexed( statement, index, nodeId, value ); } @Override - public PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement state, IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement state, NewIndexDescriptor index, String term ) throws IndexNotFoundKernelException { return entityReadOperations.nodesGetFromIndexContainsScan( state, index, term ); } @Override - public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement state, IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement state, NewIndexDescriptor index, String suffix ) throws IndexNotFoundKernelException { return entityReadOperations.nodesGetFromIndexEndsWithScan( state, index, suffix ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/GuardingStatementOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/GuardingStatementOperations.java index 8c143f00e2841..08cccedf34d90 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/GuardingStatementOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/GuardingStatementOperations.java @@ -29,9 +29,9 @@ import org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException; import org.neo4j.kernel.api.exceptions.schema.ConstraintValidationKernelException; import org.neo4j.kernel.api.exceptions.schema.IndexBrokenKernelException; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.properties.DefinedProperty; import org.neo4j.kernel.api.properties.Property; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.guard.Guard; import org.neo4j.kernel.impl.api.operations.EntityReadOperations; import org.neo4j.kernel.impl.api.operations.EntityWriteOperations; @@ -169,7 +169,7 @@ public PrimitiveLongIterator nodesGetForLabel( KernelStatement statement, int la } @Override - public PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement statement, IndexDescriptor index, Object value ) + public PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement statement, NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException { guard.check( statement ); @@ -178,7 +178,7 @@ public PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement statement, I @Override public PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( KernelStatement statement, - IndexDescriptor index, + NewIndexDescriptor index, Number lower, boolean includeLower, Number upper, boolean includeUpper ) throws IndexNotFoundKernelException @@ -191,7 +191,7 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( KernelStatement @Override public PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( KernelStatement statement, - IndexDescriptor index, + NewIndexDescriptor index, String lower, boolean includeLower, String upper, boolean includeUpper ) throws IndexNotFoundKernelException @@ -203,7 +203,7 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( KernelStatement } @Override - public PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( KernelStatement statement, IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( KernelStatement statement, NewIndexDescriptor index, String prefix ) throws IndexNotFoundKernelException { guard.check( statement ); @@ -211,7 +211,7 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( KernelStatement } @Override - public PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement statement, IndexDescriptor index ) + public PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement statement, NewIndexDescriptor index ) throws IndexNotFoundKernelException { guard.check( statement ); @@ -219,7 +219,7 @@ public PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement statement, I } @Override - public PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement statement, IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement statement, NewIndexDescriptor index, String term ) throws IndexNotFoundKernelException { guard.check( statement ); @@ -227,7 +227,7 @@ public PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement stat } @Override - public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement statement, IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement statement, NewIndexDescriptor index, String suffix ) throws IndexNotFoundKernelException { guard.check( statement ); @@ -235,7 +235,7 @@ public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement stat } @Override - public long nodeGetFromUniqueIndexSeek( KernelStatement statement, IndexDescriptor index, Object value ) + public long nodeGetFromUniqueIndexSeek( KernelStatement statement, NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException { guard.check( statement ); @@ -243,7 +243,7 @@ public long nodeGetFromUniqueIndexSeek( KernelStatement statement, IndexDescript } @Override - public long nodesCountIndexed( KernelStatement statement, IndexDescriptor index, long nodeId, Object value ) + public long nodesCountIndexed( KernelStatement statement, NewIndexDescriptor index, long nodeId, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException { guard.check( statement ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java index f080a10f237b0..4351582fdded3 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java @@ -227,7 +227,7 @@ public PrimitiveLongIterator nodesGetForLabel( int labelId ) } @Override - public PrimitiveLongIterator nodesGetFromIndexSeek( IndexDescriptor index, Object value ) + public PrimitiveLongIterator nodesGetFromIndexSeek( NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException { statement.assertOpen(); @@ -235,7 +235,7 @@ public PrimitiveLongIterator nodesGetFromIndexSeek( IndexDescriptor index, Objec } @Override - public PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( NewIndexDescriptor index, Number lower, boolean includeLower, Number upper, @@ -248,7 +248,7 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( IndexDescriptor } @Override - public PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( NewIndexDescriptor index, String lower, boolean includeLower, String upper, @@ -261,7 +261,7 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( IndexDescriptor } @Override - public PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( IndexDescriptor index, String prefix ) + public PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( NewIndexDescriptor index, String prefix ) throws IndexNotFoundKernelException { statement.assertOpen(); @@ -269,7 +269,7 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( IndexDescriptor } @Override - public PrimitiveLongIterator nodesGetFromIndexScan( IndexDescriptor index ) + public PrimitiveLongIterator nodesGetFromIndexScan( NewIndexDescriptor index ) throws IndexNotFoundKernelException { statement.assertOpen(); @@ -277,7 +277,7 @@ public PrimitiveLongIterator nodesGetFromIndexScan( IndexDescriptor index ) } @Override - public PrimitiveLongIterator nodesGetFromIndexContainsScan( IndexDescriptor index, String term ) + public PrimitiveLongIterator nodesGetFromIndexContainsScan( NewIndexDescriptor index, String term ) throws IndexNotFoundKernelException { statement.assertOpen(); @@ -285,7 +285,7 @@ public PrimitiveLongIterator nodesGetFromIndexContainsScan( IndexDescriptor inde } @Override - public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( IndexDescriptor index, String suffix ) + public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( NewIndexDescriptor index, String suffix ) throws IndexNotFoundKernelException { statement.assertOpen(); @@ -293,7 +293,7 @@ public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( IndexDescriptor inde } @Override - public long nodeGetFromUniqueIndexSeek( IndexDescriptor index, Object value ) + public long nodeGetFromUniqueIndexSeek( NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException { statement.assertOpen(); @@ -588,7 +588,7 @@ public Set proceduresGetAll() } @Override - public long nodesCountIndexed( IndexDescriptor index, long nodeId, Object value ) + public long nodesCountIndexed( NewIndexDescriptor index, long nodeId, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException { statement.assertOpen(); @@ -1383,7 +1383,7 @@ public long countsForRelationshipWithoutTxState( int startLabelId, int typeId, i } @Override - public DoubleLongRegister indexUpdatesAndSize( IndexDescriptor index, DoubleLongRegister target ) + public DoubleLongRegister indexUpdatesAndSize( NewIndexDescriptor index, DoubleLongRegister target ) throws IndexNotFoundKernelException { statement.assertOpen(); @@ -1391,7 +1391,7 @@ public DoubleLongRegister indexUpdatesAndSize( IndexDescriptor index, DoubleLong } @Override - public DoubleLongRegister indexSample( IndexDescriptor index, DoubleLongRegister target ) + public DoubleLongRegister indexSample( NewIndexDescriptor index, DoubleLongRegister target ) throws IndexNotFoundKernelException { statement.assertOpen(); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StateHandlingStatementOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StateHandlingStatementOperations.java index 9a3e2760911bd..3785e36fc41a2 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StateHandlingStatementOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StateHandlingStatementOperations.java @@ -63,7 +63,6 @@ import org.neo4j.kernel.api.properties.Property; import org.neo4j.kernel.api.properties.PropertyKeyIdIterator; import org.neo4j.kernel.api.schema.IndexDescriptor; -import org.neo4j.kernel.api.schema.IndexDescriptorFactory; import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema.RelationshipPropertyDescriptor; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; @@ -644,7 +643,7 @@ public Iterator uniqueIndexesGetAll( KernelStatement state ) } @Override - public long nodeGetFromUniqueIndexSeek( KernelStatement state, IndexDescriptor index, Object value ) + public long nodeGetFromUniqueIndexSeek( KernelStatement state, NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException { StorageStatement storeStatement = state.getStoreStatement(); @@ -663,7 +662,7 @@ public long nodeGetFromUniqueIndexSeek( KernelStatement state, IndexDescriptor i } @Override - public PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement state, IndexDescriptor index, Object value ) + public PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement state, NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException { StorageStatement storeStatement = state.getStoreStatement(); @@ -674,7 +673,7 @@ public PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement state, Index } @Override - public PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( KernelStatement state, IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( KernelStatement state, NewIndexDescriptor index, Number lower, boolean includeLower, Number upper, boolean includeUpper ) throws IndexNotFoundKernelException @@ -690,7 +689,7 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( KernelStatement } @Override - public PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( KernelStatement state, IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( KernelStatement state, NewIndexDescriptor index, String lower, boolean includeLower, String upper, boolean includeUpper ) throws IndexNotFoundKernelException @@ -703,7 +702,7 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( KernelStatement } @Override - public PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( KernelStatement state, IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( KernelStatement state, NewIndexDescriptor index, String prefix ) throws IndexNotFoundKernelException { StorageStatement storeStatement = state.getStoreStatement(); @@ -713,7 +712,7 @@ public PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( KernelStatement } @Override - public PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement state, IndexDescriptor index ) + public PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement state, NewIndexDescriptor index ) throws IndexNotFoundKernelException { StorageStatement storeStatement = state.getStoreStatement(); @@ -723,7 +722,7 @@ public PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement state, Index } @Override - public long nodesCountIndexed( KernelStatement statement, IndexDescriptor index, long nodeId, Object value ) + public long nodesCountIndexed( KernelStatement statement, NewIndexDescriptor index, long nodeId, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException { IndexReader reader = statement.getStoreStatement().getIndexReader( index ); @@ -731,7 +730,7 @@ public long nodesCountIndexed( KernelStatement statement, IndexDescriptor index, } @Override - public PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement state, IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement state, NewIndexDescriptor index, String term ) throws IndexNotFoundKernelException { @@ -742,7 +741,7 @@ public PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement stat } @Override - public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement state, IndexDescriptor index, + public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement state, NewIndexDescriptor index, String suffix ) throws IndexNotFoundKernelException { StorageStatement storeStatement = state.getStoreStatement(); @@ -751,12 +750,13 @@ public PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement stat return filterIndexStateChangesForScanOrSeek( state, index, null, committed ); } - private PrimitiveLongIterator filterExactIndexMatches( final KernelStatement state, IndexDescriptor index, + private PrimitiveLongIterator filterExactIndexMatches( final KernelStatement state, NewIndexDescriptor index, Object value, PrimitiveLongIterator committed ) { - if ( !index.isComposite() ) + // TODO: composite index + if ( index.schema().getPropertyIds().length == 1 ) { - return LookupFilter.exactIndexMatches( this, state, committed, index.getPropertyKeyId(), value ); + return LookupFilter.exactIndexMatches( this, state, committed, index.schema().getPropertyIds()[0], value ); } else { @@ -764,13 +764,14 @@ private PrimitiveLongIterator filterExactIndexMatches( final KernelStatement sta } } - private PrimitiveLongIterator filterExactRangeMatches( final KernelStatement state, IndexDescriptor index, + private PrimitiveLongIterator filterExactRangeMatches( final KernelStatement state, NewIndexDescriptor index, PrimitiveLongIterator committed, Number lower, boolean includeLower, Number upper, boolean includeUpper ) { - if ( !index.isComposite() ) + // TODO: composite index + if ( index.schema().getPropertyIds().length == 1 ) { return LookupFilter - .exactRangeMatches( this, state, committed, index.getPropertyKeyId(), lower, includeLower, + .exactRangeMatches( this, state, committed, index.schema().getPropertyIds()[0], lower, includeLower, upper, includeUpper ); } else @@ -779,14 +780,13 @@ private PrimitiveLongIterator filterExactRangeMatches( final KernelStatement sta } } - private PrimitiveLongIterator filterIndexStateChangesForScanOrSeek( KernelStatement state, IndexDescriptor index, + private PrimitiveLongIterator filterIndexStateChangesForScanOrSeek( KernelStatement state, NewIndexDescriptor index, Object value, PrimitiveLongIterator nodeIds ) { if ( state.hasTxStateWithChanges() ) { ReadableDiffSets labelPropertyChanges = - state.txState().indexUpdatesForScanOrSeek( - IndexBoundary.map( index ), value ); + state.txState().indexUpdatesForScanOrSeek( index, value ); ReadableDiffSets nodes = state.txState().addedAndRemovedNodes(); // Apply to actual index lookup @@ -796,7 +796,7 @@ private PrimitiveLongIterator filterIndexStateChangesForScanOrSeek( KernelStatem } private PrimitiveLongIterator filterIndexStateChangesForRangeSeekByNumber( KernelStatement state, - IndexDescriptor index, + NewIndexDescriptor index, Number lower, boolean includeLower, Number upper, boolean includeUpper, PrimitiveLongIterator nodeIds ) @@ -805,7 +805,7 @@ private PrimitiveLongIterator filterIndexStateChangesForRangeSeekByNumber( Kerne { ReadableDiffSets labelPropertyChangesForNumber = state.txState().indexUpdatesForRangeSeekByNumber( - IndexBoundary.map( index ), lower, includeLower, upper, includeUpper ); + index, lower, includeLower, upper, includeUpper ); ReadableDiffSets nodes = state.txState().addedAndRemovedNodes(); // Apply to actual index lookup @@ -816,7 +816,7 @@ private PrimitiveLongIterator filterIndexStateChangesForRangeSeekByNumber( Kerne } private PrimitiveLongIterator filterIndexStateChangesForRangeSeekByString( KernelStatement state, - IndexDescriptor index, + NewIndexDescriptor index, String lower, boolean includeLower, String upper, boolean includeUpper, PrimitiveLongIterator nodeIds ) @@ -825,7 +825,7 @@ private PrimitiveLongIterator filterIndexStateChangesForRangeSeekByString( Kerne { ReadableDiffSets labelPropertyChangesForString = state.txState().indexUpdatesForRangeSeekByString( - IndexBoundary.map( index ), lower, includeLower, upper, includeUpper ); + index, lower, includeLower, upper, includeUpper ); ReadableDiffSets nodes = state.txState().addedAndRemovedNodes(); // Apply to actual index lookup @@ -836,14 +836,14 @@ private PrimitiveLongIterator filterIndexStateChangesForRangeSeekByString( Kerne } private PrimitiveLongIterator filterIndexStateChangesForRangeSeekByPrefix( KernelStatement state, - IndexDescriptor index, + NewIndexDescriptor index, String prefix, PrimitiveLongIterator nodeIds ) { if ( state.hasTxStateWithChanges() ) { ReadableDiffSets labelPropertyChangesForPrefix = - state.txState().indexUpdatesForRangeSeekByPrefix( IndexBoundary.map( index ), prefix ); + state.txState().indexUpdatesForRangeSeekByPrefix( index, prefix ); ReadableDiffSets nodes = state.txState().addedAndRemovedNodes(); // Apply to actual index lookup @@ -1143,17 +1143,17 @@ public double indexUniqueValuesPercentage( KernelStatement statement, NewIndexDe } @Override - public DoubleLongRegister indexUpdatesAndSize( KernelStatement statement, IndexDescriptor index, + public DoubleLongRegister indexUpdatesAndSize( KernelStatement statement, NewIndexDescriptor index, DoubleLongRegister target ) throws IndexNotFoundKernelException { - return storeLayer.indexUpdatesAndSize( SchemaBoundary.map( index.descriptor() ), target ); + return storeLayer.indexUpdatesAndSize( index.schema(), target ); } @Override - public DoubleLongRegister indexSample( KernelStatement statement, IndexDescriptor index, DoubleLongRegister target ) + public DoubleLongRegister indexSample( KernelStatement statement, NewIndexDescriptor index, DoubleLongRegister target ) throws IndexNotFoundKernelException { - return storeLayer.indexSample( SchemaBoundary.map( index.descriptor() ), target ); + return storeLayer.indexSample( index.schema(), target ); } // diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/CountsOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/CountsOperations.java index 6c7e520c62ced..5e3937c36cd4e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/CountsOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/CountsOperations.java @@ -20,7 +20,7 @@ package org.neo4j.kernel.impl.api.operations; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; -import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.KernelStatement; import org.neo4j.register.Register.DoubleLongRegister; @@ -38,9 +38,9 @@ public interface CountsOperations /** @see org.neo4j.kernel.api.CountsRead#countsForRelationshipWithoutTxState(int, int, int) */ long countsForRelationshipWithoutTxState( KernelStatement statement, int startLabelId, int typeId, int endLabelId ); - DoubleLongRegister indexUpdatesAndSize( KernelStatement statement, IndexDescriptor index, + DoubleLongRegister indexUpdatesAndSize( KernelStatement statement, NewIndexDescriptor index, DoubleLongRegister target ) throws IndexNotFoundKernelException; - DoubleLongRegister indexSample( KernelStatement statement, IndexDescriptor index, DoubleLongRegister target ) + DoubleLongRegister indexSample( KernelStatement statement, NewIndexDescriptor index, DoubleLongRegister target ) throws IndexNotFoundKernelException; } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/EntityReadOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/EntityReadOperations.java index b0db9315bf118..91822479afaaa 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/EntityReadOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/EntityReadOperations.java @@ -25,7 +25,7 @@ import org.neo4j.kernel.api.exceptions.EntityNotFoundException; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.schema.IndexBrokenKernelException; -import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.KernelStatement; import org.neo4j.kernel.impl.api.RelationshipVisitor; import org.neo4j.storageengine.api.NodeItem; @@ -44,7 +44,7 @@ public interface EntityReadOperations * * @throws IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement state, IndexDescriptor index, Object value ) + PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement state, NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException; /** @@ -53,7 +53,7 @@ PrimitiveLongIterator nodesGetFromIndexSeek( KernelStatement state, IndexDescrip * @throws IndexNotFoundKernelException if no such index found. */ PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( KernelStatement state, - IndexDescriptor index, + NewIndexDescriptor index, Number lower, boolean includeLower, Number upper, @@ -66,7 +66,7 @@ PrimitiveLongIterator nodesGetFromIndexRangeSeekByNumber( KernelStatement state, * @throws IndexNotFoundKernelException if no such index found. */ PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( KernelStatement state, - IndexDescriptor index, + NewIndexDescriptor index, String lower, boolean includeLower, String upper, @@ -79,7 +79,7 @@ PrimitiveLongIterator nodesGetFromIndexRangeSeekByString( KernelStatement state, * @throws IndexNotFoundKernelException if no such index found. */ PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( KernelStatement state, - IndexDescriptor index, + NewIndexDescriptor index, String prefix ) throws IndexNotFoundKernelException; @@ -88,7 +88,7 @@ PrimitiveLongIterator nodesGetFromIndexRangeSeekByPrefix( KernelStatement state, * * @throws IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement state, IndexDescriptor index ) + PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement state, NewIndexDescriptor index ) throws IndexNotFoundKernelException; /** @@ -96,7 +96,7 @@ PrimitiveLongIterator nodesGetFromIndexScan( KernelStatement state, IndexDescrip * * @throws IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement state, IndexDescriptor index, String term ) + PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement state, NewIndexDescriptor index, String term ) throws IndexNotFoundKernelException; /** @@ -104,7 +104,7 @@ PrimitiveLongIterator nodesGetFromIndexContainsScan( KernelStatement state, Inde * * @throws IndexNotFoundKernelException if no such index found. */ - PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement state, IndexDescriptor index, String suffix ) + PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement state, NewIndexDescriptor index, String suffix ) throws IndexNotFoundKernelException; /** @@ -113,10 +113,10 @@ PrimitiveLongIterator nodesGetFromIndexEndsWithScan( KernelStatement state, Inde * @throws IndexNotFoundKernelException if no such index found. * @throws IndexBrokenKernelException if we found an index that was corrupt or otherwise in a failed state. */ - long nodeGetFromUniqueIndexSeek( KernelStatement state, IndexDescriptor index, Object value ) + long nodeGetFromUniqueIndexSeek( KernelStatement state, NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException; - long nodesCountIndexed( KernelStatement statement, IndexDescriptor index, long nodeId, Object value ) + long nodesCountIndexed( KernelStatement statement, NewIndexDescriptor index, long nodeId, Object value ) throws IndexNotFoundKernelException, IndexBrokenKernelException; boolean graphHasProperty( KernelStatement state, int propertyKeyId ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/StoreStatement.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/StoreStatement.java index d05ff90df9b5e..918e0b293f7ba 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/StoreStatement.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/StoreStatement.java @@ -23,7 +23,8 @@ import org.neo4j.cursor.Cursor; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; -import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.IndexBoundary; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.IndexReaderFactory; import org.neo4j.kernel.impl.locking.LockService; import org.neo4j.kernel.impl.store.NeoStores; @@ -176,15 +177,15 @@ private IndexReaderFactory indexReaderFactory() } @Override - public IndexReader getIndexReader( IndexDescriptor descriptor ) throws IndexNotFoundKernelException + public IndexReader getIndexReader( NewIndexDescriptor descriptor ) throws IndexNotFoundKernelException { - return indexReaderFactory().newReader( descriptor ); + return indexReaderFactory().newReader( IndexBoundary.map( descriptor ) ); } @Override - public IndexReader getFreshIndexReader( IndexDescriptor descriptor ) throws IndexNotFoundKernelException + public IndexReader getFreshIndexReader( NewIndexDescriptor descriptor ) throws IndexNotFoundKernelException { - return indexReaderFactory().newUnCachedReader( descriptor ); + return indexReaderFactory().newUnCachedReader( IndexBoundary.map( descriptor ) ); } @Override diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java index d43d38f39a690..c24ff0f32632e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java @@ -592,7 +592,7 @@ private ResourceIterator nodesByLabelAndProperty( Label myLabel, String ke return emptyIterator(); } - IndexDescriptor descriptor = findAnyIndexByLabelAndProperty( readOps, propertyId, labelId ); + NewIndexDescriptor descriptor = findAnyIndexByLabelAndProperty( readOps, propertyId, labelId ); try { @@ -610,7 +610,7 @@ private ResourceIterator nodesByLabelAndProperty( Label myLabel, String ke return getNodesByLabelAndPropertyWithoutIndex( propertyId, value, statement, labelId ); } - private IndexDescriptor findAnyIndexByLabelAndProperty( ReadOperations readOps, int propertyId, int labelId ) + private NewIndexDescriptor findAnyIndexByLabelAndProperty( ReadOperations readOps, int propertyId, int labelId ) { try { @@ -620,7 +620,7 @@ private IndexDescriptor findAnyIndexByLabelAndProperty( ReadOperations readOps, if ( readOps.indexGetState( descriptor ) == InternalIndexState.ONLINE ) { // Ha! We found an index - let's use it to find matching nodes - return IndexBoundary.map( descriptor ); + return descriptor; } } catch ( SchemaRuleNotFoundException | IndexNotFoundKernelException e ) diff --git a/community/kernel/src/main/java/org/neo4j/storageengine/api/StorageStatement.java b/community/kernel/src/main/java/org/neo4j/storageengine/api/StorageStatement.java index ec34a04211a71..b9a5e53c8761b 100644 --- a/community/kernel/src/main/java/org/neo4j/storageengine/api/StorageStatement.java +++ b/community/kernel/src/main/java/org/neo4j/storageengine/api/StorageStatement.java @@ -21,9 +21,8 @@ import org.neo4j.cursor.Cursor; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; -import org.neo4j.kernel.api.schema.IndexDescriptor; -import org.neo4j.kernel.impl.store.RecordCursor; import org.neo4j.kernel.impl.store.RecordCursors; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.LabelScanReader; @@ -107,11 +106,11 @@ public interface StorageStatement extends AutoCloseable * Reader returned from this method should not be closed. All such readers will be closed during {@link #close()} * of the current statement. * - * @param index {@link IndexDescriptor} to get reader for. + * @param index {@link NewIndexDescriptor} to get reader for. * @return {@link IndexReader} capable of searching entity ids given property values. * @throws IndexNotFoundKernelException if no such index exists. */ - IndexReader getIndexReader( IndexDescriptor index ) throws IndexNotFoundKernelException; + IndexReader getIndexReader( NewIndexDescriptor index ) throws IndexNotFoundKernelException; /** * Returns an {@link IndexReader} for searching entity ids given property values. A new reader is allocated @@ -121,11 +120,11 @@ public interface StorageStatement extends AutoCloseable * NOTE: * It is caller's responsibility to close the returned reader. * - * @param index {@link IndexDescriptor} to get reader for. + * @param index {@link NewIndexDescriptor} to get reader for. * @return {@link IndexReader} capable of searching entity ids given property values. * @throws IndexNotFoundKernelException if no such index exists. */ - IndexReader getFreshIndexReader( IndexDescriptor index ) throws IndexNotFoundKernelException; + IndexReader getFreshIndexReader( NewIndexDescriptor index ) throws IndexNotFoundKernelException; /** * Access to low level record cursors diff --git a/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java b/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java index fc1e654d6ab28..d290b74ac883b 100644 --- a/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java +++ b/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java @@ -488,7 +488,7 @@ public void shouldSupportIndexSeekByPrefix() { Statement statement = getStatement( (GraphDatabaseAPI) db ); ReadOperations ops = statement.readOperations(); - IndexDescriptor descriptor = indexDescriptor( ops, index ); + NewIndexDescriptor descriptor = indexDescriptor( ops, index ); found.addAll( ops.nodesGetFromIndexRangeSeekByPrefix( descriptor, "Karl" ) ); } @@ -513,7 +513,7 @@ public void shouldIncludeNodesCreatedInSameTxInIndexSeekByPrefix() createNode( db, map( "name", "Karla" ), LABEL1 ); Statement statement = getStatement( (GraphDatabaseAPI) db ); ReadOperations readOperations = statement.readOperations(); - IndexDescriptor descriptor = indexDescriptor( readOperations, index ); + NewIndexDescriptor descriptor = indexDescriptor( readOperations, index ); found.addAll( readOperations.nodesGetFromIndexRangeSeekByPrefix( descriptor, "Carl" ) ); } // THEN @@ -543,7 +543,7 @@ public void shouldNotIncludeNodesDeletedInSameTxInIndexSeekByPrefix() } Statement statement = getStatement( (GraphDatabaseAPI) db ); ReadOperations readOperations = statement.readOperations(); - IndexDescriptor descriptor = indexDescriptor( readOperations, index ); + NewIndexDescriptor descriptor = indexDescriptor( readOperations, index ); found.addAll( readOperations.nodesGetFromIndexRangeSeekByPrefix( descriptor, "Karl" ) ); } // THEN @@ -582,7 +582,7 @@ public void shouldConsiderNodesChangedInSameTxInIndexPrefixSearch() } Statement statement = getStatement( (GraphDatabaseAPI) db ); ReadOperations readOperations = statement.readOperations(); - IndexDescriptor descriptor = indexDescriptor( readOperations, index ); + NewIndexDescriptor descriptor = indexDescriptor( readOperations, index ); found.addAll( readOperations.nodesGetFromIndexRangeSeekByPrefix( descriptor, prefix ) ); } // THEN @@ -603,11 +603,11 @@ private PrimitiveLongSet createNodes( GraphDatabaseService db, Label label, Stri return expected; } - private IndexDescriptor indexDescriptor(ReadOperations readOperations, IndexDefinition index) + private NewIndexDescriptor indexDescriptor(ReadOperations readOperations, IndexDefinition index) throws SchemaRuleNotFoundException { NodePropertyDescriptor descriptor = IndexDescriptorFactory.getTokens( readOperations, index ); - return IndexBoundary.map( readOperations.indexGetForLabelAndPropertyKey( descriptor ) ); + return readOperations.indexGetForLabelAndPropertyKey( descriptor ); } private Statement getStatement( GraphDatabaseAPI db ) diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/NodeGetUniqueFromIndexSeekIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/NodeGetUniqueFromIndexSeekIT.java index c219fa4b9f886..5c441bb8ba2b5 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/NodeGetUniqueFromIndexSeekIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/NodeGetUniqueFromIndexSeekIT.java @@ -84,7 +84,7 @@ public void shouldFindMatchingNode() throws Exception // when looking for it ReadOperations readOperations = readOperationsInNewTransaction(); - long foundId = readOperations.nodeGetFromUniqueIndexSeek( IndexBoundary.map( index ), value ); + long foundId = readOperations.nodeGetFromUniqueIndexSeek( index, value ); commit(); // then @@ -101,7 +101,7 @@ public void shouldNotFindNonMatchingNode() throws Exception // when looking for it ReadOperations readOperations = readOperationsInNewTransaction(); - long foundId = readOperations.nodeGetFromUniqueIndexSeek( IndexBoundary.map( index ), value ); + long foundId = readOperations.nodeGetFromUniqueIndexSeek( index, value ); commit(); // then @@ -145,7 +145,7 @@ public void shouldBlockUniqueIndexSeekFromCompetingTransaction() throws Exceptio { try ( Statement statement1 = statementContextSupplier.get() ) { - statement1.readOperations().nodeGetFromUniqueIndexSeek( IndexBoundary.map( index ), value ); + statement1.readOperations().nodeGetFromUniqueIndexSeek( index, value ); } tx.success(); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationIT.java index 4a7f42326a13e..247b671d7f4a5 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationIT.java @@ -336,7 +336,7 @@ public void unrelatedNodesWithSamePropertyShouldNotInterfereWithUniquenessCheck( createLabeledNode( statement, "Item", "id", 2 ); // then I should find the original node - assertThat( readOps.nodeGetFromUniqueIndexSeek( IndexBoundary.map( idx ), 1 ), equalTo( ourNode ) ); + assertThat( readOps.nodeGetFromUniqueIndexSeek( idx, 1 ), equalTo( ourNode ) ); } @Test @@ -363,7 +363,7 @@ public void addingUniqueNodeWithUnrelatedValueShouldNotAffectLookup() throws Exc createLabeledNode( statement, "Person", "id", 2 ); // then I should find the original node - assertThat( readOps.nodeGetFromUniqueIndexSeek( IndexBoundary.map( idx ), 1 ), equalTo( ourNode )); + assertThat( readOps.nodeGetFromUniqueIndexSeek( idx, 1 ), equalTo( ourNode )); } private long constrainedNode( String labelName, String propertyKey, Object propertyValue ) diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/operations/ConstraintEnforcingEntityOperationsTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/operations/ConstraintEnforcingEntityOperationsTest.java index 1c817399aae8f..fd38ff496fca4 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/operations/ConstraintEnforcingEntityOperationsTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/operations/ConstraintEnforcingEntityOperationsTest.java @@ -22,9 +22,6 @@ import org.junit.Before; import org.junit.Test; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; -import org.neo4j.kernel.api.schema.IndexDescriptor; -import org.neo4j.kernel.api.schema.IndexDescriptorFactory; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.schema_new.index.IndexBoundary; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; @@ -51,8 +48,7 @@ public class ConstraintEnforcingEntityOperationsTest private final int labelId = 1; private final int propertyKeyId = 2; private final String value = "value"; - private final IndexDescriptor indexDescriptor = - IndexDescriptorFactory.of( labelId, propertyKeyId ); + private final NewIndexDescriptor index = NewIndexDescriptorFactory.uniqueForLabel( labelId, propertyKeyId ); private EntityReadOperations readOps; private KernelStatement state; private Locks.Client locks; @@ -65,8 +61,7 @@ public void given_ConstraintEnforcingEntityOperations_with_OnlineIndex() throws SchemaReadOperations schemaReadOps = mock( SchemaReadOperations.class ); SchemaWriteOperations schemaWriteOps = mock( SchemaWriteOperations.class ); this.state = mock( KernelStatement.class ); - when( schemaReadOps.indexGetState( state, IndexBoundary.map( indexDescriptor ) ) ) - .thenReturn( InternalIndexState.ONLINE ); + when( schemaReadOps.indexGetState( state, index ) ).thenReturn( InternalIndexState.ONLINE ); this.locks = mock( Locks.Client.class ); when( state.locks() ).thenReturn( new SimpleStatementLocks( locks ) ); when( state.lockTracer() ).thenReturn( LockTracer.NONE ); @@ -79,10 +74,10 @@ public void shouldHoldIndexReadLockIfNodeIsExists() throws Exception { // given long expectedNodeId = 15; - when( readOps.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ) ).thenReturn( expectedNodeId ); + when( readOps.nodeGetFromUniqueIndexSeek( state, index, value ) ).thenReturn( expectedNodeId ); // when - long nodeId = ops.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ); + long nodeId = ops.nodeGetFromUniqueIndexSeek( state, index, value ); // then assertEquals( expectedNodeId, nodeId ); @@ -96,10 +91,10 @@ public void shouldHoldIndexReadLockIfNodeIsExists() throws Exception public void shouldHoldIndexWriteLockIfNodeDoesNotExist() throws Exception { // given - when( readOps.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ) ).thenReturn( NO_SUCH_NODE ); + when( readOps.nodeGetFromUniqueIndexSeek( state, index, value ) ).thenReturn( NO_SUCH_NODE ); // when - long nodeId = ops.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ); + long nodeId = ops.nodeGetFromUniqueIndexSeek( state, index, value ); // then assertEquals( NO_SUCH_NODE, nodeId ); @@ -118,12 +113,12 @@ public void shouldHoldIndexReadLockIfNodeIsConcurrentlyCreated() throws Exceptio { // given long expectedNodeId = 15; - when( readOps.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ) ) + when( readOps.nodeGetFromUniqueIndexSeek( state, index, value ) ) .thenReturn( NO_SUCH_NODE ) .thenReturn( expectedNodeId ); // when - long nodeId = ops.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ); + long nodeId = ops.nodeGetFromUniqueIndexSeek( state, index, value ); // then assertEquals( expectedNodeId, nodeId ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/IndexQueryTransactionStateTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/IndexQueryTransactionStateTest.java index b7ff01796a7f1..aff184755349c 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/IndexQueryTransactionStateTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/IndexQueryTransactionStateTest.java @@ -74,7 +74,8 @@ public class IndexQueryTransactionStateTest String value = "My Value"; NodePropertyDescriptor descriptor = new NodePropertyDescriptor( labelId, propertyKeyId ); IndexDescriptor indexDescriptor = IndexDescriptorFactory.of( descriptor ); - List indexes = Collections.singletonList( IndexBoundary.map( indexDescriptor ) ); + private final NewIndexDescriptor newIndexDescriptor = IndexBoundary.map( indexDescriptor ); + List indexes = Collections.singletonList( newIndexDescriptor ); private StoreReadLayer store; private StoreStatement statement; @@ -98,14 +99,13 @@ public void before() throws Exception .emptyList() ) ); when( store.indexesGetAll() ).then( answerAsIteratorFrom( Collections.emptyList() ) ); when( store.constraintsGetForLabel( labelId ) ).thenReturn( Collections.emptyIterator() ); - when( store.indexGetForLabelAndPropertyKey( SchemaBoundary.map( descriptor ) ) ).thenReturn( - IndexBoundary.map( indexDescriptor ) ); + when( store.indexGetForLabelAndPropertyKey( SchemaBoundary.map( descriptor ) ) ).thenReturn( newIndexDescriptor ); statement = mock( StoreStatement.class ); when( state.getStoreStatement() ).thenReturn( statement ); indexReader = mock( IndexReader.class ); - when( statement.getIndexReader( indexDescriptor ) ).thenReturn( indexReader ); - when( statement.getFreshIndexReader( indexDescriptor ) ).thenReturn( indexReader ); + when( statement.getIndexReader( newIndexDescriptor ) ).thenReturn( indexReader ); + when( statement.getFreshIndexReader( newIndexDescriptor ) ).thenReturn( indexReader ); StateHandlingStatementOperations stateHandlingOperations = new StateHandlingStatementOperations( store, @@ -128,7 +128,7 @@ public void shouldExcludeRemovedNodesFromIndexQuery() throws Exception txContext.nodeDelete( state, nodeId ); // When - PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, indexDescriptor, value ); + PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, newIndexDescriptor, value ); // Then assertThat( PrimitiveLongCollections.toSet( result ), equalTo( asSet( 1L, 3L ) ) ); @@ -146,7 +146,7 @@ public void shouldExcludeRemovedNodeFromUniqueIndexQuery() throws Exception txContext.nodeDelete( state, nodeId ); // When - long result = txContext.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ); + long result = txContext.nodeGetFromUniqueIndexSeek( state, newIndexDescriptor, value ); // Then assertNoSuchNode( result ); @@ -162,7 +162,7 @@ public void shouldExcludeChangedNodesWithMissingLabelFromIndexQuery() throws Exc Property.intProperty( propertyKeyId, 10 ) ); // When - PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, indexDescriptor, value ); + PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, newIndexDescriptor, value ); // Then assertThat( PrimitiveLongCollections.toSet( result ), equalTo( asSet( 2L, 3L ) ) ); @@ -177,7 +177,7 @@ public void shouldExcludeChangedNodeWithMissingLabelFromUniqueIndexQuery() throw Property.intProperty( propertyKeyId, 10 ) ); // When - long result = txContext.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ); + long result = txContext.nodeGetFromUniqueIndexSeek( state, newIndexDescriptor, value ); // Then assertNoSuchNode( result ); @@ -200,7 +200,7 @@ public void shouldIncludeCreatedNodesWithCorrectLabelAndProperty() throws Except txContext.nodeAddLabel( state, nodeId, labelId ); // When - PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, indexDescriptor, value ); + PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, newIndexDescriptor, value ); // Then assertThat( PrimitiveLongCollections.toSet( result ), equalTo( asSet( nodeId, 2L, 3L ) ) ); @@ -223,7 +223,7 @@ public void shouldIncludeUniqueCreatedNodeWithCorrectLabelAndProperty() throws E txContext.nodeAddLabel( state, nodeId, labelId ); // When - long result = txContext.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ); + long result = txContext.nodeGetFromUniqueIndexSeek( state, newIndexDescriptor, value ); // Then assertThat( result, equalTo( nodeId ) ); @@ -244,7 +244,7 @@ public void shouldIncludeExistingNodesWithCorrectPropertyAfterAddingLabel() thro txContext.nodeAddLabel( state, nodeId, labelId ); // When - PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, indexDescriptor, value ); + PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, newIndexDescriptor, value ); // Then assertThat( PrimitiveLongCollections.toSet( result ), equalTo( asSet( nodeId, 2L, 3L ) ) ); @@ -266,7 +266,7 @@ public void shouldIncludeExistingUniqueNodeWithCorrectPropertyAfterAddingLabel() txContext.nodeAddLabel( state, nodeId, labelId ); // When - long result = txContext.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ); + long result = txContext.nodeGetFromUniqueIndexSeek( state, newIndexDescriptor, value ); // Then assertThat( result, equalTo( nodeId ) ); @@ -287,7 +287,7 @@ public void shouldExcludeExistingNodesWithCorrectPropertyAfterRemovingLabel() th txContext.nodeRemoveLabel( state, nodeId, labelId ); // When - PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, indexDescriptor, value ); + PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, newIndexDescriptor, value ); // Then assertThat( PrimitiveLongCollections.toSet( result ), equalTo( asSet( 2L, 3L ) ) ); @@ -308,7 +308,7 @@ public void shouldExcludeExistingUniqueNodeWithCorrectPropertyAfterRemovingLabel txContext.nodeRemoveLabel( state, nodeId, labelId ); // When - long result = txContext.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ); + long result = txContext.nodeGetFromUniqueIndexSeek( state, newIndexDescriptor, value ); // Then assertNoSuchNode( result ); @@ -332,7 +332,7 @@ public void shouldExcludeNodesWithRemovedProperty() throws Exception txContext.nodeAddLabel( state, nodeId, labelId ); // When - PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, indexDescriptor, value ); + PrimitiveLongIterator result = txContext.nodesGetFromIndexSeek( state, newIndexDescriptor, value ); // Then assertThat( PrimitiveLongCollections.toSet( result ), equalTo( asSet( 2L, 3L ) ) ); @@ -353,7 +353,7 @@ public void shouldExcludeUniqueNodeWithRemovedProperty() throws Exception txContext.nodeRemoveProperty( state, nodeId, propertyKeyId ); // When - long result = txContext.nodeGetFromUniqueIndexSeek( state, indexDescriptor, value ); + long result = txContext.nodeGetFromUniqueIndexSeek( state, newIndexDescriptor, value ); // Then assertNoSuchNode( result ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/StateHandlingStatementOperationsTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/StateHandlingStatementOperationsTest.java index 4be47dcf5aae2..2aa7a24cdda81 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/StateHandlingStatementOperationsTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/StateHandlingStatementOperationsTest.java @@ -224,7 +224,7 @@ public void shouldConsiderTransactionStateDuringIndexScan() throws Exception StateHandlingStatementOperations context = newTxStateOps( storeReadLayer ); // When - PrimitiveLongIterator results = context.nodesGetFromIndexScan( statement, IndexBoundary.map( index ) ); + PrimitiveLongIterator results = context.nodesGetFromIndexScan( statement, index ); // Then assertEquals( asSet( 42L, 43L ), PrimitiveLongCollections.toSet( results ) ); @@ -253,7 +253,7 @@ public void shouldConsiderTransactionStateDuringIndexSeek() throws Exception StateHandlingStatementOperations context = newTxStateOps( storeReadLayer ); // When - PrimitiveLongIterator results = context.nodesGetFromIndexSeek( statement, IndexBoundary.map( index ), "value" ); + PrimitiveLongIterator results = context.nodesGetFromIndexSeek( statement, index, "value" ); // Then assertEquals( asSet( 42L, 43L ), PrimitiveLongCollections.toSet( results ) ); @@ -282,7 +282,7 @@ public void shouldConsiderTransactionStateDuringIndexRangeSeekByPrefix() throws StateHandlingStatementOperations context = newTxStateOps( storeReadLayer ); // When - PrimitiveLongIterator results = context.nodesGetFromIndexRangeSeekByPrefix( statement, IndexBoundary.map( index ), "prefix" ); + PrimitiveLongIterator results = context.nodesGetFromIndexRangeSeekByPrefix( statement, index, "prefix" ); // Then assertEquals( asSet( 42L, 43L ), PrimitiveLongCollections.toSet( results ) ); @@ -331,7 +331,7 @@ public void shouldConsiderTransactionStateDuringIndexBetweenRangeSeekByNumber() // When PrimitiveLongIterator results = context.nodesGetFromIndexRangeSeekByNumber( - statement, IndexBoundary.map( index ), lower, true, upper, false ); + statement, index, lower, true, upper, false ); // Then assertEquals( asSet( 42L, 43L ), PrimitiveLongCollections.toSet( results ) ); @@ -362,7 +362,7 @@ public void shouldConsiderTransactionStateDuringIndexBetweenRangeSeekByString() // When PrimitiveLongIterator results = context.nodesGetFromIndexRangeSeekByString( - statement, IndexBoundary.map( index ), "Anne", true, "Bill", false ); + statement, index, "Anne", true, "Bill", false ); // Then assertEquals( asSet( 42L, 43L ), PrimitiveLongCollections.toSet( results ) ); @@ -381,7 +381,7 @@ public void nodeGetFromUniqueIndexSeekClosesIndexReader() throws Exception StateHandlingStatementOperations operations = newTxStateOps( mock( StoreReadLayer.class ) ); - operations.nodeGetFromUniqueIndexSeek( kernelStatement, IndexDescriptorFactory.of( 1, 1 ), "foo" ); + operations.nodeGetFromUniqueIndexSeek( kernelStatement, NewIndexDescriptorFactory.uniqueForLabel( 1, 1 ), "foo" ); verify( indexReader ).close(); } @@ -404,7 +404,7 @@ private IndexReader addMockedIndexReader( StorageStatement storeStatement ) throws IndexNotFoundKernelException { IndexReader indexReader = mock( IndexReader.class ); - when( storeStatement.getIndexReader( any( IndexDescriptor.class ) ) ).thenReturn( indexReader ); + when( storeStatement.getIndexReader( any( NewIndexDescriptor.class ) ) ).thenReturn( indexReader ); return indexReader; } } diff --git a/community/lucene-index/src/test/java/org/neo4j/concurrencytest/ConstraintIndexConcurrencyTest.java b/community/lucene-index/src/test/java/org/neo4j/concurrencytest/ConstraintIndexConcurrencyTest.java index 7882b5fd46059..ac9e99c05d7d3 100644 --- a/community/lucene-index/src/test/java/org/neo4j/concurrencytest/ConstraintIndexConcurrencyTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/concurrencytest/ConstraintIndexConcurrencyTest.java @@ -28,8 +28,8 @@ import org.neo4j.graphdb.Transaction; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.schema.UniquePropertyConstraintViolationKernelException; -import org.neo4j.kernel.api.schema.IndexDescriptor; -import org.neo4j.kernel.api.schema.IndexDescriptorFactory; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.test.rule.DatabaseRule; @@ -75,7 +75,7 @@ public void shouldNotAllowConcurrentViolationOfConstraint() throws Exception Statement statement = statementSupplier.get(); int labelId = statement.readOperations().labelGetForName( label.name() ); int propertyKeyId = statement.readOperations().propertyKeyGetForName( propertyKey ); - IndexDescriptor index = IndexDescriptorFactory.of( labelId, propertyKeyId ); + NewIndexDescriptor index = NewIndexDescriptorFactory.uniqueForLabel( labelId, propertyKeyId ); statement.readOperations().nodesGetFromIndexSeek( index, "The value is irrelevant, we just want to perform some sort of lookup against this index" ); diff --git a/community/neo4j/src/test/java/schema/IndexPopulationFlipRaceIT.java b/community/neo4j/src/test/java/schema/IndexPopulationFlipRaceIT.java index f219cd98d7892..e91a06782fc98 100644 --- a/community/neo4j/src/test/java/schema/IndexPopulationFlipRaceIT.java +++ b/community/neo4j/src/test/java/schema/IndexPopulationFlipRaceIT.java @@ -29,8 +29,8 @@ import org.neo4j.kernel.api.KernelAPI; import org.neo4j.kernel.api.KernelTransaction; import org.neo4j.kernel.api.Statement; -import org.neo4j.kernel.api.schema.IndexDescriptor; -import org.neo4j.kernel.api.schema.IndexDescriptorFactory; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.api.security.AnonymousContext; import org.neo4j.test.rule.DatabaseRule; import org.neo4j.test.rule.EmbeddedDatabaseRule; @@ -144,8 +144,8 @@ private void verifyThatThereAreExactlyOneIndexEntryPerNodeInTheIndexes( int i, P int keyAId = statement.readOperations().propertyKeyGetForName( keyA( i ) ); int labelBId = statement.readOperations().labelGetForName( labelB( i ).name() ); int keyBId = statement.readOperations().propertyKeyGetForName( keyB( i ) ); - IndexDescriptor indexA = IndexDescriptorFactory.of( labelAId, keyAId ); - IndexDescriptor indexB = IndexDescriptorFactory.of( labelBId, keyBId ); + NewIndexDescriptor indexA = NewIndexDescriptorFactory.forLabel( labelAId, keyAId ); + NewIndexDescriptor indexB = NewIndexDescriptorFactory.forLabel( labelBId, keyBId ); for ( int j = 0; j < NODES_PER_INDEX; j++ ) { diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaCountsIT.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaCountsIT.java index 7b8220466fd47..9f2c79ef5c309 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaCountsIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaCountsIT.java @@ -28,10 +28,11 @@ import org.neo4j.graphdb.Relationship; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.schema.IndexDefinition; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.KernelException; -import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.schema.NodePropertyDescriptor; +import org.neo4j.kernel.api.schema_new.index.IndexBoundary; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.IndexingService; import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge; import org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster; @@ -42,7 +43,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; - import static org.neo4j.register.Registers.newDoubleLongRegister; public class HaCountsIT @@ -130,7 +130,7 @@ public void shouldUpdateCountsOnSlavesWhenCreatingAnIndexOnMaster() throws Excep { // when creating a node on the master createANode( master, LABEL, PROPERTY_VALUE, PROPERTY_NAME ); - IndexDescriptor indexDescriptor = createAnIndex( master, LABEL, PROPERTY_NAME ); + NewIndexDescriptor indexDescriptor = createAnIndex( master, LABEL, PROPERTY_NAME ); long indexId = awaitOnline( master, indexDescriptor ); // and the slaves got the updates @@ -150,7 +150,7 @@ public void shouldUpdateCountsOnClusterWhenCreatingANodeOnSlaveAndAnIndexOnMaste { // when creating a node on the master createANode( slave1, LABEL, PROPERTY_VALUE, PROPERTY_NAME ); - IndexDescriptor indexDescriptor = createAnIndex( master, LABEL, PROPERTY_NAME ); + NewIndexDescriptor indexDescriptor = createAnIndex( master, LABEL, PROPERTY_NAME ); long indexId = awaitOnline( master, indexDescriptor ); // and the updates are propagate in the cluster @@ -175,7 +175,7 @@ private void createANode( HighlyAvailableGraphDatabase db, Label label, String v } } - private IndexDescriptor createAnIndex( HighlyAvailableGraphDatabase db, Label label, String propertyName ) + private NewIndexDescriptor createAnIndex( HighlyAvailableGraphDatabase db, Label label, String propertyName ) throws KernelException { try ( Transaction tx = db.beginTx() ) @@ -183,7 +183,7 @@ private IndexDescriptor createAnIndex( HighlyAvailableGraphDatabase db, Label la Statement statement = statement( db ); int labelId = statement.tokenWriteOperations().labelGetOrCreateForName( label.name() ); int propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName( propertyName ); - IndexDescriptor index = statement.schemaWriteOperations() + NewIndexDescriptor index = statement.schemaWriteOperations() .indexCreate( new NodePropertyDescriptor( labelId, propertyKeyId ) ); tx.success(); return index; @@ -238,7 +238,7 @@ private IndexingService indexingService( HighlyAvailableGraphDatabase db ) return db.getDependencyResolver().resolveDependency( IndexingService.class ); } - private long awaitOnline( HighlyAvailableGraphDatabase db, IndexDescriptor index ) + private long awaitOnline( HighlyAvailableGraphDatabase db, NewIndexDescriptor index ) throws KernelException { long start = System.currentTimeMillis(); @@ -250,7 +250,7 @@ private long awaitOnline( HighlyAvailableGraphDatabase db, IndexDescriptor index switch ( statement( db ).readOperations().indexGetState( index ) ) { case ONLINE: - return indexingService( db ).getIndexId( index ); + return indexingService( db ).getIndexId( IndexBoundary.map( index ) ); case FAILED: throw new IllegalStateException( "Index failed instead of becoming ONLINE" ); diff --git a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintCreationIT.java b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintCreationIT.java index 478f76114b9fa..de194f0e05013 100644 --- a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintCreationIT.java +++ b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintCreationIT.java @@ -49,6 +49,8 @@ import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptorFactory; import org.neo4j.kernel.api.security.AnonymousContext; import org.neo4j.kernel.api.security.SecurityContext; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine; import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.SchemaStorage; @@ -68,6 +70,7 @@ public class UniquenessConstraintCreationIT extends AbstractConstraintCreationIT { private static final String DUPLICATED_VALUE = "apa"; + private NewIndexDescriptor uniqueIndex; @Override int initializeLabelOrRelType( TokenWriteOperations tokenWriteOperations, String name ) throws KernelException @@ -121,6 +124,7 @@ void removeOffendingDataInRunningTx( GraphDatabaseService db ) @Override NodePropertyDescriptor makeDescriptor( int typeId, int propertyKeyId ) { + uniqueIndex = NewIndexDescriptorFactory.uniqueForLabel( typeId, propertyKeyId ); return new NodePropertyDescriptor( typeId, propertyKeyId ); } @@ -179,7 +183,7 @@ public void shouldCreateAnIndexToGoAlongWithAUniquePropertyConstraint() throws E // then ReadOperations readOperations = readOperationsInNewTransaction(); - assertEquals( asSet( IndexDescriptorFactory.of( descriptor ) ), asSet( readOperations.uniqueIndexesGetAll() ) ); + assertEquals( asSet( uniqueIndex ), asSet( readOperations.uniqueIndexesGetAll() ) ); } @Test @@ -188,7 +192,7 @@ public void shouldDropCreatedConstraintIndexWhenRollingBackConstraintCreation() // given Statement statement = statementInNewTransaction( SecurityContext.AUTH_DISABLED ); statement.schemaWriteOperations().uniquePropertyConstraintCreate( descriptor ); - assertEquals( asSet( IndexDescriptorFactory.of( descriptor ) ), + assertEquals( asSet( uniqueIndex ), asSet( statement.readOperations().uniqueIndexesGetAll() ) ); // when @@ -196,7 +200,7 @@ public void shouldDropCreatedConstraintIndexWhenRollingBackConstraintCreation() // then ReadOperations readOperations = readOperationsInNewTransaction(); - assertEquals( emptySetOf( IndexDescriptor.class ), asSet( readOperations.uniqueIndexesGetAll() ) ); + assertEquals( emptySetOf( NewIndexDescriptor.class ), asSet( readOperations.uniqueIndexesGetAll() ) ); commit(); } @@ -268,7 +272,7 @@ public void shouldDropConstraintIndexWhenDroppingConstraint() throws Exception Statement statement = statementInNewTransaction( SecurityContext.AUTH_DISABLED ); UniquenessConstraint constraint = statement.schemaWriteOperations().uniquePropertyConstraintCreate( descriptor ); - assertEquals( asSet( IndexDescriptorFactory.of( descriptor ) ), + assertEquals( asSet( uniqueIndex ), asSet( statement.readOperations().uniqueIndexesGetAll() ) ); commit(); @@ -279,7 +283,7 @@ public void shouldDropConstraintIndexWhenDroppingConstraint() throws Exception // then ReadOperations readOperations = readOperationsInNewTransaction(); - assertEquals( emptySetOf( IndexDescriptor.class ), asSet( readOperations.uniqueIndexesGetAll() ) ); + assertEquals( emptySetOf( NewIndexDescriptor.class ), asSet( readOperations.uniqueIndexesGetAll() ) ); commit(); } diff --git a/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIntegrationTest.java b/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIntegrationTest.java index 782aff1b89781..68d5f8b91fe32 100644 --- a/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIntegrationTest.java +++ b/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIntegrationTest.java @@ -55,6 +55,7 @@ import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.KernelException; import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.security.AnonymousContext; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.HttpConnector; @@ -452,14 +453,14 @@ private static void checkIndexCounts( Store store, GraphDatabaseAPI db ) throws try ( KernelTransaction tx = kernel.newTransaction( KernelTransaction.Type.implicit, AnonymousContext.read() ); Statement statement = tx.acquireStatement() ) { - Iterator indexes = getAllIndexes( db ); + Iterator indexes = getAllIndexes( db ); DoubleLongRegister register = Registers.newDoubleLongRegister(); for ( int i = 0; indexes.hasNext(); i++ ) { - IndexDescriptor descriptor = indexes.next(); + NewIndexDescriptor descriptor = indexes.next(); // wait index to be online since sometimes we need to rebuild the indexes on migration - awaitOnline( db, statement.readOperations(), descriptor ); + awaitOnline( statement.readOperations(), descriptor ); assertDoubleLongEquals( store.indexCounts[i][0], store.indexCounts[i][1], statement.readOperations().indexUpdatesAndSize( descriptor, register ) ); @@ -471,7 +472,7 @@ private static void checkIndexCounts( Store store, GraphDatabaseAPI db ) throws } } - private static Iterator getAllIndexes( GraphDatabaseAPI db ) + private static Iterator getAllIndexes( GraphDatabaseAPI db ) { try ( Transaction ignored = db.beginTx() ) { @@ -585,8 +586,8 @@ private static long[] counts( long upgrade, long size, long unique, long sampleS return new long[]{upgrade, size, unique, sampleSize}; } - private static IndexDescriptor awaitOnline( GraphDatabaseAPI db, - ReadOperations readOperations, IndexDescriptor index ) throws KernelException + private static NewIndexDescriptor awaitOnline( ReadOperations readOperations, NewIndexDescriptor index ) + throws KernelException { long start = System.currentTimeMillis(); long end = start + 20_000;