diff --git a/community/consistency-check/src/test/java/org/neo4j/consistency/checking/SchemaRecordCheckTest.java b/community/consistency-check/src/test/java/org/neo4j/consistency/checking/SchemaRecordCheckTest.java index 5537b5bc66541..a4a2e62996b22 100644 --- a/community/consistency-check/src/test/java/org/neo4j/consistency/checking/SchemaRecordCheckTest.java +++ b/community/consistency-check/src/test/java/org/neo4j/consistency/checking/SchemaRecordCheckTest.java @@ -23,7 +23,6 @@ import org.neo4j.consistency.report.ConsistencyReport; import org.neo4j.consistency.store.RecordAccessStub; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException; import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.impl.store.SchemaStorage; 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 a8a186580efd7..975a517341130 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,6 @@ 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 import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory import org.neo4j.kernel.api.schema_new.constaints.{ConstraintBoundary, ConstraintDescriptor} import org.neo4j.kernel.api.schema_new.index.{NewIndexDescriptor => KernelIndexDescriptor} @@ -46,7 +45,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper) val labelId = tc.statement.readOperations().labelGetForName(labelName) val propertyKeyId = tc.statement.readOperations().propertyKeyGetForName(propertyKey) - getOnlineIndex(tc.statement.readOperations().indexGetForLabelAndPropertyKey(new NodePropertyDescriptor(labelId, propertyKeyId))) + getOnlineIndex(tc.statement.readOperations().indexGetForLabelAndPropertyKey(SchemaDescriptorFactory.forLabel(labelId, propertyKeyId))) } def hasIndexRule(labelName: String): Boolean = { @@ -63,7 +62,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper) val propertyKeyId = tc.statement.readOperations().propertyKeyGetForName(propertyKey) // here we do not need to use getOnlineIndex method because uniqueness constraint creation is synchronous - Some(tc.statement.readOperations().uniqueIndexGetForLabelAndPropertyKey(new NodePropertyDescriptor(labelId, propertyKeyId))) + Some(tc.statement.readOperations().uniqueIndexGetForLabelAndPropertyKey(SchemaDescriptorFactory.forLabel(labelId, propertyKeyId))) } private def evalOrNone[T](f: => Option[T]): Option[T] = 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 0e15a75c745a5..515855c4dc3cd 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 @@ -49,7 +49,6 @@ import org.neo4j.kernel.api.constraints.{NodePropertyExistenceConstraint, Relati import org.neo4j.kernel.api.exceptions.schema.{AlreadyConstrainedException, AlreadyIndexedException} import org.neo4j.kernel.api.index.InternalIndexState import org.neo4j.kernel.api.schema_new.IndexQuery -import org.neo4j.kernel.api.schema.NodePropertyDescriptor import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory import org.neo4j.kernel.api.schema_new.constaints.{ConstraintBoundary, ConstraintDescriptorFactory} import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory @@ -458,7 +457,7 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper) } catch { case _: AlreadyIndexedException => - val indexDescriptor = tc.statement.readOperations().indexGetForLabelAndPropertyKey(new NodePropertyDescriptor(labelId, propertyKeyId)) + val indexDescriptor = tc.statement.readOperations().indexGetForLabelAndPropertyKey( SchemaDescriptorFactory.forLabel(labelId, propertyKeyId)) if (tc.statement.readOperations().indexGetState(indexDescriptor) == InternalIndexState.FAILED) throw new FailedIndexException(indexDescriptor.userDescription(tokenNameLookup)) 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 5bf373e2f35bd..4c88a62561cfa 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 @@ -36,7 +36,6 @@ 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 import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory import org.neo4j.kernel.api.schema_new.constaints.{ConstraintBoundary, ConstraintDescriptor} import org.neo4j.kernel.api.schema_new.index.{NewIndexDescriptor => KernelIndexDescriptor} @@ -53,7 +52,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper, logger: Inter val labelId = tc.statement.readOperations().labelGetForName(labelName) val propertyKeyId = tc.statement.readOperations().propertyKeyGetForName(propertyKey) - getOnlineIndex(tc.statement.readOperations().indexGetForLabelAndPropertyKey(new NodePropertyDescriptor(labelId, propertyKeyId))) + getOnlineIndex(tc.statement.readOperations().indexGetForLabelAndPropertyKey(SchemaDescriptorFactory.forLabel(labelId, propertyKeyId))) } def hasIndexRule(labelName: String): Boolean = { @@ -70,7 +69,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapper, logger: Inter val propertyKeyId = tc.statement.readOperations().propertyKeyGetForName(propertyKey) // here we do not need to use getOnlineIndex method because uniqueness constraint creation is synchronous - Some(tc.statement.readOperations().uniqueIndexGetForLabelAndPropertyKey(new NodePropertyDescriptor(labelId, propertyKeyId))) + Some(tc.statement.readOperations().uniqueIndexGetForLabelAndPropertyKey(SchemaDescriptorFactory.forLabel(labelId, propertyKeyId))) } private def evalOrNone[T](f: => Option[T]): Option[T] = 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 04383d5bddb07..d64793423a8f1 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 @@ -54,7 +54,6 @@ import org.neo4j.kernel.api.exceptions.schema.{AlreadyConstrainedException, Alre import org.neo4j.kernel.api.index.InternalIndexState import org.neo4j.kernel.api.proc.{QualifiedName => KernelQualifiedName} import org.neo4j.kernel.api.schema_new.IndexQuery -import org.neo4j.kernel.api.schema.NodePropertyDescriptor import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory import org.neo4j.kernel.api.schema_new.constaints.{ConstraintBoundary, ConstraintDescriptorFactory} import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory @@ -463,7 +462,7 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper) IdempotentResult(txContext.statement.schemaWriteOperations().indexCreate( SchemaDescriptorFactory.forLabel(labelId, propertyKeyId))) } catch { case _: AlreadyIndexedException => - val indexDescriptor = txContext.statement.readOperations().indexGetForLabelAndPropertyKey(new NodePropertyDescriptor(labelId, propertyKeyId)) + val indexDescriptor = txContext.statement.readOperations().indexGetForLabelAndPropertyKey(SchemaDescriptorFactory.forLabel(labelId, propertyKeyId)) if(txContext.statement.readOperations().indexGetState(indexDescriptor) == InternalIndexState.FAILED) throw new FailedIndexException(indexDescriptor.userDescription(tokenNameLookup)) IdempotentResult(indexDescriptor, wasCreated = false) 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 6f8fb7a62bfb2..6dfc7154f2d9f 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 @@ -53,7 +53,8 @@ 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.NodePropertyDescriptor +import org.neo4j.kernel.api.schema_new.IndexQuery +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptorFactory import org.neo4j.kernel.api.schema_new.{IndexQuery, SchemaDescriptorFactory} import org.neo4j.kernel.impl.core.NodeManager @@ -470,7 +471,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional IdempotentResult(transactionalContext.statement.schemaWriteOperations().indexCreate( descriptor )) } catch { case _: AlreadyIndexedException => - val indexDescriptor = transactionalContext.statement.readOperations().indexGetForLabelAndPropertyKey(new NodePropertyDescriptor( descriptor.label, descriptor.property)) + val indexDescriptor = transactionalContext.statement.readOperations().indexGetForLabelAndPropertyKey (SchemaDescriptorFactory.forLabel(descriptor.getLabelId, descriptor.getPropertyId)); if(transactionalContext.statement.readOperations().indexGetState(indexDescriptor) == InternalIndexState.FAILED) throw new FailedIndexException(indexDescriptor.userDescription(tokenNameLookup)) IdempotentResult(indexDescriptor, wasCreated = false) 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 c749740a55357..cf342e3c7f994 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 @@ -29,9 +29,6 @@ import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.cursor.Cursor; import org.neo4j.graphdb.Direction; -import org.neo4j.kernel.api.constraints.NodePropertyConstraint; -import org.neo4j.kernel.api.constraints.PropertyConstraint; -import org.neo4j.kernel.api.constraints.RelationshipPropertyConstraint; import org.neo4j.kernel.api.exceptions.EntityNotFoundException; import org.neo4j.kernel.api.exceptions.LabelNotFoundKernelException; import org.neo4j.kernel.api.exceptions.ProcedureException; @@ -47,8 +44,8 @@ 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.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.IndexQuery; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptor; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; @@ -228,7 +225,7 @@ void relationshipVisit( long relId, RelationshipVi //=========================================== /** Returns the index rule for the given labelId and propertyKey. */ - NewIndexDescriptor indexGetForLabelAndPropertyKey( NodePropertyDescriptor descriptor ) + NewIndexDescriptor indexGetForLabelAndPropertyKey( LabelSchemaDescriptor descriptor ) throws SchemaRuleNotFoundException; /** Get all indexes for a label. */ @@ -238,7 +235,7 @@ NewIndexDescriptor indexGetForLabelAndPropertyKey( NodePropertyDescriptor descri Iterator indexesGetAll(); /** Returns the constraint index for the given labelId and propertyKey. */ - NewIndexDescriptor uniqueIndexGetForLabelAndPropertyKey( NodePropertyDescriptor descriptor ) + NewIndexDescriptor uniqueIndexGetForLabelAndPropertyKey( LabelSchemaDescriptor descriptor ) throws SchemaRuleNotFoundException, DuplicateSchemaRuleException; /** Get all constraint indexes for a label. */ diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/NodePropertyConstraint.java b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/NodePropertyConstraint.java index 5baacddda4003..ff515b70409c0 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/NodePropertyConstraint.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/NodePropertyConstraint.java @@ -20,7 +20,6 @@ package org.neo4j.kernel.api.constraints; import org.neo4j.kernel.api.TokenNameLookup; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; /** @@ -28,9 +27,9 @@ */ public abstract class NodePropertyConstraint implements PropertyConstraint { - protected final NodePropertyDescriptor descriptor; + protected final LabelSchemaDescriptor descriptor; - public NodePropertyConstraint( NodePropertyDescriptor descriptor ) + public NodePropertyConstraint( LabelSchemaDescriptor descriptor ) { this.descriptor = descriptor; } @@ -40,21 +39,16 @@ public final int label() return descriptor.getLabelId(); } - public NodePropertyDescriptor descriptor() + public LabelSchemaDescriptor descriptor() { return descriptor; } - public boolean matches( NodePropertyDescriptor descriptor ) - { - return this.descriptor.equals( descriptor ); - } - public boolean matches( LabelSchemaDescriptor other ) { return other != null && descriptor.getLabelId() == other.getLabelId() && - descriptor.getPropertyKeyId() == other.getPropertyIds()[0]; + descriptor.getPropertyId() == other.getPropertyIds()[0]; // this is safe because we are replacing this class before introducing composite constraints } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/NodePropertyExistenceConstraint.java b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/NodePropertyExistenceConstraint.java index c88a9ff7f3cc0..0aecf54ee65a0 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/NodePropertyExistenceConstraint.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/NodePropertyExistenceConstraint.java @@ -19,16 +19,16 @@ */ package org.neo4j.kernel.api.constraints; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.TokenNameLookup; import org.neo4j.kernel.api.exceptions.schema.CreateConstraintFailureException; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; /** * Description of constraint enforcing nodes to contain a certain property. */ public class NodePropertyExistenceConstraint extends NodePropertyConstraint { - public NodePropertyExistenceConstraint( NodePropertyDescriptor descriptor ) + public NodePropertyExistenceConstraint( LabelSchemaDescriptor descriptor ) { super( descriptor ); } @@ -52,13 +52,13 @@ public String userDescription( TokenNameLookup tokenNameLookup ) String boundIdentifier = labelName.toLowerCase(); return String.format( "CONSTRAINT ON ( %s:%s ) ASSERT exists(%s.%s)", boundIdentifier, labelName, boundIdentifier, - descriptor.propertyNameText( tokenNameLookup ) ); + tokenNameLookup.labelGetName( descriptor.getLabelId() ) ); } @Override public String toString() { - return String.format( "CONSTRAINT ON ( n:label[%s] ) ASSERT exists(n.property[%s])", - descriptor.getLabelId(), descriptor.propertyIdText() ); + return String.format( "CONSTRAINT ON ( n:label[%d] ) ASSERT exists(n.property[%d])", + descriptor.getLabelId(), descriptor.getPropertyId() ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/PropertyConstraint.java b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/PropertyConstraint.java index 8e953720e7ba7..c45d381933624 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/PropertyConstraint.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/PropertyConstraint.java @@ -19,9 +19,9 @@ */ package org.neo4j.kernel.api.constraints; -import org.neo4j.kernel.api.schema.EntityPropertyDescriptor; import org.neo4j.kernel.api.TokenNameLookup; import org.neo4j.kernel.api.exceptions.schema.CreateConstraintFailureException; +import org.neo4j.kernel.api.schema_new.SchemaDescriptor; /** * Interface describing a property constraint. @@ -49,7 +49,7 @@ void visitAddedRelationshipPropertyExistenceConstraint( RelationshipPropertyExis void removed( ChangeVisitor visitor ); - EntityPropertyDescriptor descriptor(); + SchemaDescriptor descriptor(); String userDescription( TokenNameLookup tokenNameLookup ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/RelationshipPropertyConstraint.java b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/RelationshipPropertyConstraint.java index 1c7797dd5e6be..474d933fd6214 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/RelationshipPropertyConstraint.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/RelationshipPropertyConstraint.java @@ -20,7 +20,10 @@ package org.neo4j.kernel.api.constraints; import org.neo4j.kernel.api.schema.RelationshipPropertyDescriptor; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.SchemaBoundary; +import org.neo4j.kernel.api.schema_new.SchemaDescriptor; /** * Base class describing property constraint on relationships. @@ -35,9 +38,9 @@ public RelationshipPropertyConstraint( RelationshipPropertyDescriptor descriptor } @Override - public final RelationshipPropertyDescriptor descriptor() + public final SchemaDescriptor descriptor() { - return descriptor; + return SchemaBoundary.map( descriptor ); } public boolean matches( RelationshipPropertyDescriptor descriptor ) @@ -49,7 +52,7 @@ public boolean matches( RelationTypeSchemaDescriptor other ) { return other != null && descriptor.getRelationshipTypeId() == other.getRelTypeId() && - descriptor.getPropertyKeyId() == other.getPropertyIds()[0]; + descriptor.getPropertyId() == other.getPropertyIds()[0]; // this is safe because we are replacing this class before introducing composite constraints } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/RelationshipPropertyExistenceConstraint.java b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/RelationshipPropertyExistenceConstraint.java index 794c8c1771c68..0fd3022f4d69e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/RelationshipPropertyExistenceConstraint.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/RelationshipPropertyExistenceConstraint.java @@ -58,6 +58,6 @@ public String userDescription( TokenNameLookup tokenNameLookup ) public String toString() { return String.format( "CONSTRAINT ON ()-[ n:relationshipType[%s] ]-() ASSERT exists(n.property[%s])", - descriptor.getRelationshipTypeId(), descriptor.propertyIdText() ); + descriptor.getRelationshipTypeId(), descriptor.getPropertyId() ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/UniquenessConstraint.java b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/UniquenessConstraint.java index f2cb8d2797288..ee431c2c06a5b 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/UniquenessConstraint.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/constraints/UniquenessConstraint.java @@ -19,9 +19,8 @@ */ package org.neo4j.kernel.api.constraints; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.TokenNameLookup; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; @@ -30,14 +29,14 @@ */ public class UniquenessConstraint extends NodePropertyConstraint { - public UniquenessConstraint( NodePropertyDescriptor descriptor ) + public UniquenessConstraint( LabelSchemaDescriptor descriptor ) { super( descriptor ); } public NewIndexDescriptor indexDescriptor() { - return NewIndexDescriptorFactory.forSchema( SchemaBoundary.map( descriptor ) ); + return NewIndexDescriptorFactory.forSchema( descriptor ); } @Override @@ -57,14 +56,15 @@ public String userDescription( TokenNameLookup tokenNameLookup ) { String labelName = labelName( tokenNameLookup ); String boundIdentifier = labelName.toLowerCase(); - return String.format( "CONSTRAINT ON ( %s:%s ) ASSERT %s.%s IS UNIQUE", - boundIdentifier, labelName, boundIdentifier, descriptor.propertyNameText( tokenNameLookup ) ); + return String + .format( "CONSTRAINT ON ( %s:%s ) ASSERT %s.%s IS UNIQUE", boundIdentifier, labelName, boundIdentifier, + tokenNameLookup.labelGetName( descriptor.getLabelId() ) ); } @Override public String toString() { - return String.format( "CONSTRAINT ON ( n:label[%s] ) ASSERT n.property[%s] IS UNIQUE", - descriptor.getLabelId(), descriptor.propertyIdText() ); + return String.format( "CONSTRAINT ON ( n:label[%d] ) ASSERT n.property[%d] IS UNIQUE", + descriptor.getLabelId(), descriptor.getPropertyId() ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/index/IndexPopulationFailedKernelException.java b/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/index/IndexPopulationFailedKernelException.java index 92a0342e9b02d..30d9ca6f08e3a 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/index/IndexPopulationFailedKernelException.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/index/IndexPopulationFailedKernelException.java @@ -19,25 +19,25 @@ */ package org.neo4j.kernel.api.exceptions.index; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.exceptions.KernelException; import org.neo4j.kernel.api.exceptions.Status; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; public class IndexPopulationFailedKernelException extends KernelException { private static final String FORMAT_MESSAGE = "Failed to populate index for %s [labelId: %d, propertyKeyId %s]"; - public IndexPopulationFailedKernelException( NodePropertyDescriptor descriptor, String indexUserDescription, + public IndexPopulationFailedKernelException( LabelSchemaDescriptor descriptor, String indexUserDescription, Throwable cause ) { super( Status.Schema.IndexCreationFailed, cause, FORMAT_MESSAGE, indexUserDescription, - descriptor.getLabelId(), descriptor.propertyIdText() ); + descriptor.getLabelId(), descriptor.getPropertyId() ); } - public IndexPopulationFailedKernelException( NodePropertyDescriptor descriptor, String indexUserDescription, + public IndexPopulationFailedKernelException( LabelSchemaDescriptor descriptor, String indexUserDescription, String message ) { super( Status.Schema.IndexCreationFailed, FORMAT_MESSAGE + ", due to " + message, - indexUserDescription, descriptor.getLabelId(), descriptor.propertyIdText() ); + indexUserDescription, descriptor.getLabelId(), descriptor.getPropertyId() ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/schema/AlreadyIndexedException.java b/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/schema/AlreadyIndexedException.java index c0e73a4671c70..db97a81dadb38 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/schema/AlreadyIndexedException.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/schema/AlreadyIndexedException.java @@ -19,9 +19,9 @@ */ package org.neo4j.kernel.api.exceptions.schema; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.TokenNameLookup; import org.neo4j.kernel.api.exceptions.Status; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; public class AlreadyIndexedException extends SchemaKernelException { @@ -31,10 +31,10 @@ public class AlreadyIndexedException extends SchemaKernelException private static final String CONSTRAINT_CONTEXT_FORMAT = "There already exists an index for label '%s' on property '%s'. " + "A constraint cannot be created until the index has been dropped."; - private final NodePropertyDescriptor descriptor; + private final LabelSchemaDescriptor descriptor; private final OperationContext context; - public AlreadyIndexedException( NodePropertyDescriptor descriptor, OperationContext context ) + public AlreadyIndexedException( LabelSchemaDescriptor descriptor, OperationContext context ) { super( Status.Schema.IndexAlreadyExists, constructUserMessage( context, null, descriptor ) ); @@ -43,7 +43,7 @@ public AlreadyIndexedException( NodePropertyDescriptor descriptor, OperationCont } private static String constructUserMessage( OperationContext context, TokenNameLookup tokenNameLookup, - NodePropertyDescriptor descriptor ) + LabelSchemaDescriptor descriptor ) { switch ( context ) { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/schema/SchemaKernelException.java b/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/schema/SchemaKernelException.java index bbdb7943a3629..4513de2ad1720 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/schema/SchemaKernelException.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/exceptions/schema/SchemaKernelException.java @@ -19,10 +19,10 @@ */ package org.neo4j.kernel.api.exceptions.schema; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.TokenNameLookup; import org.neo4j.kernel.api.exceptions.KernelException; import org.neo4j.kernel.api.exceptions.Status; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; /** * Signals that some constraint has been violated, for example a name containing invalid characters or length. @@ -51,19 +51,19 @@ public SchemaKernelException( Status statusCode, String message ) } protected static String messageWithLabelAndPropertyName( TokenNameLookup tokenNameLookup, String formatString, - NodePropertyDescriptor descriptor ) + LabelSchemaDescriptor descriptor ) { if ( tokenNameLookup != null ) { return String.format( formatString, tokenNameLookup.labelGetName( descriptor.getLabelId() ), - descriptor.propertyNameText( tokenNameLookup ) ); + tokenNameLookup.propertyKeyGetName( descriptor.getPropertyId() ) ); } else { return String.format( formatString, "label[" + descriptor.getLabelId() + "]", - "key[" + descriptor.propertyIdText() + "]" ); + "key[" + descriptor.getPropertyId() + "]" ); } } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/schema/EntityPropertyDescriptor.java b/community/kernel/src/main/java/org/neo4j/kernel/api/schema/EntityPropertyDescriptor.java index e7935c6592e6c..38b1dbf62142a 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/schema/EntityPropertyDescriptor.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/schema/EntityPropertyDescriptor.java @@ -77,7 +77,7 @@ public int getEntityId() /** * @return property key token id this index is for. */ - public int getPropertyKeyId() + public int getPropertyId() { return propertyKeyId; } @@ -85,7 +85,7 @@ public int getPropertyKeyId() /** * @return property key token ids this descriptor is for. */ - public int[] getPropertyKeyIds() + public int[] getPropertyIds() { throw new UnsupportedOperationException( "Cannot get multiple property Ids of single property descriptor" ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/schema/NodeMultiPropertyDescriptor.java b/community/kernel/src/main/java/org/neo4j/kernel/api/schema/NodeMultiPropertyDescriptor.java deleted file mode 100644 index ee23a7c7afc7f..0000000000000 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/schema/NodeMultiPropertyDescriptor.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2002-2017 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.api.schema; - -import java.util.Arrays; -import java.util.stream.Collectors; - -import org.neo4j.kernel.api.TokenNameLookup; - -import static java.lang.String.format; - -/** - * Description of a single label combined with multiple properties. - */ -public class NodeMultiPropertyDescriptor extends NodePropertyDescriptor -{ - private final int[] propertyKeyIds; - - public NodeMultiPropertyDescriptor( int labelId, int[] propertyKeyIds ) - { - super( labelId, -1 ); - this.propertyKeyIds = propertyKeyIds; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj != null && obj instanceof NodeMultiPropertyDescriptor ) - { - NodeMultiPropertyDescriptor that = (NodeMultiPropertyDescriptor) obj; - return this.getLabelId() == that.getLabelId() && - Arrays.equals( this.propertyKeyIds, that.propertyKeyIds ); - } - return false; - } - - @Override - public boolean isComposite() - { - return true; - } - - @Override - public int hashCode() - { - int result = getLabelId(); - for ( int element : propertyKeyIds ) - { - result = 31 * result + element; - } - return result; - } - - /** - * @return property key token id this index is for. - */ - public int getPropertyKeyId() - { - throw new UnsupportedOperationException( "Cannot get single property Id of composite index" ); - } - - /** - * @return property key token ids this index is for. - */ - public int[] getPropertyKeyIds() - { - return propertyKeyIds; - } - - @Override - public String propertyIdText() - { - return Arrays.stream( propertyKeyIds ).mapToObj( Integer::toString ) - .collect( Collectors.joining( "," ) ); - } - - public String propertyNameText( TokenNameLookup tokenNameLookup ) - { - return Arrays.stream( propertyKeyIds ).mapToObj( tokenNameLookup::propertyKeyGetName ) - .collect( Collectors.joining( "," ) ); - } - - /** - * @param tokenNameLookup used for looking up names for token ids. - * @return a user friendly description of what this index indexes. - */ - public String userDescription( TokenNameLookup tokenNameLookup ) - { - return format( ":%s(%s)", tokenNameLookup.labelGetName( getLabelId() ), - propertyNameText( tokenNameLookup ) ); - } - - @Override - public int compareTo( EntityPropertyDescriptor other ) - { - if ( other instanceof NodeMultiPropertyDescriptor ) - { - NodeMultiPropertyDescriptor that = (NodeMultiPropertyDescriptor) other; - int cmp = this.entityId - that.entityId; - if ( cmp == 0 && !Arrays.equals( this.propertyKeyIds, that.propertyKeyIds ) ) - { - cmp = this.propertyKeyIds.length - that.propertyKeyIds.length; - if ( cmp == 0 ) - { - for ( int i = 0; i < this.propertyKeyIds.length; i++ ) - { - cmp = this.propertyKeyIds[i] - that.propertyKeyIds[i]; - if ( cmp != 0 ) - { - return cmp; - } - } - } - } - return cmp; - } - return -1; - } -} diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/schema/NodePropertyDescriptor.java b/community/kernel/src/main/java/org/neo4j/kernel/api/schema/NodePropertyDescriptor.java deleted file mode 100644 index eee05b0b2eb54..0000000000000 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/schema/NodePropertyDescriptor.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2002-2017 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.api.schema; - -import org.neo4j.kernel.api.TokenNameLookup; -import org.neo4j.storageengine.api.EntityType; - -/** - * Description of a combination of a relationship type and one property. - */ -public class NodePropertyDescriptor extends EntityPropertyDescriptor -{ - public NodePropertyDescriptor( int labelId, int propertyKeyId ) - { - super(labelId, propertyKeyId); - } - - public int getLabelId() - { - return getEntityId(); - } - - public boolean isComposite() - { - return false; - } - - @Override - public String entityNameText( TokenNameLookup tokenNameLookup ) - { - return tokenNameLookup.labelGetName( getEntityId() ); - } - - public EntityType entityType() - { - return EntityType.NODE; - } - - public NodePropertyDescriptor descriptor() - { - return this; - } -} diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/LabelSchemaDescriptor.java b/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/LabelSchemaDescriptor.java index f41c5f80a142a..c29d5c3accf13 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/LabelSchemaDescriptor.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/LabelSchemaDescriptor.java @@ -28,7 +28,7 @@ public class LabelSchemaDescriptor implements SchemaDescriptor private final int labelId; private final int[] propertyIds; - LabelSchemaDescriptor( int labelId, int... propertyIds ) + public LabelSchemaDescriptor( int labelId, int... propertyIds ) { this.labelId = labelId; this.propertyIds = propertyIds; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/SchemaBoundary.java b/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/SchemaBoundary.java index 883d3951fb7ea..419a1cd812977 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/SchemaBoundary.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/SchemaBoundary.java @@ -19,8 +19,6 @@ */ package org.neo4j.kernel.api.schema_new; -import org.neo4j.kernel.api.schema.NodeMultiPropertyDescriptor; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema.RelationshipPropertyDescriptor; /** @@ -33,20 +31,8 @@ private SchemaBoundary() { } - public static LabelSchemaDescriptor map( NodePropertyDescriptor descriptor ) - { - return descriptor.isComposite() ? - SchemaDescriptorFactory.forLabel( descriptor.getLabelId(), descriptor.getPropertyKeyIds() ) : - SchemaDescriptorFactory.forLabel( descriptor.getLabelId(), descriptor.getPropertyKeyId() ); - } - public static RelationTypeSchemaDescriptor map( RelationshipPropertyDescriptor descriptor ) { - return SchemaDescriptorFactory.forRelType( descriptor.getRelationshipTypeId(), descriptor.getPropertyKeyId() ); - } - - public static NodePropertyDescriptor map( LabelSchemaDescriptor schema ) - { - return new NodeMultiPropertyDescriptor( schema.getLabelId(), schema.getPropertyIds() ); + return SchemaDescriptorFactory.forRelType( descriptor.getRelationshipTypeId(), descriptor.getPropertyIds() ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/constaints/ConstraintBoundary.java b/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/constaints/ConstraintBoundary.java index 29633abf77472..68df5b956a7b5 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/constaints/ConstraintBoundary.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/constaints/ConstraintBoundary.java @@ -28,13 +28,11 @@ import org.neo4j.kernel.api.constraints.RelationshipPropertyConstraint; import org.neo4j.kernel.api.constraints.RelationshipPropertyExistenceConstraint; import org.neo4j.kernel.api.constraints.UniquenessConstraint; -import org.neo4j.kernel.api.schema.NodeMultiPropertyDescriptor; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema.RelationshipPropertyDescriptor; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; import org.neo4j.kernel.api.schema_new.SchemaComputer; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; /** * This class represents the boundary of where new constraint descriptors are converted to old constraints. This class @@ -68,17 +66,17 @@ public static ConstraintDescriptor map( PropertyConstraint constraint ) if ( constraint instanceof UniquenessConstraint ) { UniquenessConstraint c = (UniquenessConstraint) constraint; - return ConstraintDescriptorFactory.uniqueForSchema( SchemaBoundary.map( c.descriptor() ) ); + return ConstraintDescriptorFactory.uniqueForSchema( c.descriptor() ); } if ( constraint instanceof NodePropertyExistenceConstraint ) { NodePropertyExistenceConstraint c = (NodePropertyExistenceConstraint) constraint; - return ConstraintDescriptorFactory.existsForSchema( SchemaBoundary.map( c.descriptor() ) ); + return ConstraintDescriptorFactory.existsForSchema( c.descriptor() ); } if ( constraint instanceof RelationshipPropertyExistenceConstraint ) { RelationshipPropertyExistenceConstraint c = (RelationshipPropertyExistenceConstraint) constraint; - return ConstraintDescriptorFactory.existsForSchema( SchemaBoundary.map( c.descriptor() ) ); + return ConstraintDescriptorFactory.existsForSchema( c.descriptor() ); } throw new IllegalStateException( "Unknown constraint type "+ constraint.getClass().getSimpleName() ); } @@ -109,15 +107,14 @@ public PropertyConstraint computeSpecific( LabelSchemaDescriptor schema ) switch ( descriptor.type() ) { case UNIQUE: - return new UniquenessConstraint( - schema.getPropertyIds().length == 1 ? - new NodePropertyDescriptor( schema.getLabelId(), schema.getPropertyId() ) : - new NodeMultiPropertyDescriptor( schema.getLabelId(), schema.getPropertyIds() ) - ); + final int labelId = schema.getLabelId(); + final int[] propertyKeyIds = new int[]{schema.getPropertyId()}; + return new UniquenessConstraint( SchemaDescriptorFactory.forLabel( labelId, propertyKeyIds ) ); case EXISTS: - return new NodePropertyExistenceConstraint( new NodePropertyDescriptor( - schema.getLabelId(), schema.getPropertyId() ) ); + final int labelId1 = schema.getLabelId(); + final int[] propertyKeyIds1 = new int[]{schema.getPropertyId()}; + return new NodePropertyExistenceConstraint( SchemaDescriptorFactory.forLabel( labelId1, propertyKeyIds1 ) ); default: throw new UnsupportedOperationException( "Although we cannot get here, this has not been implemented." ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/IndexProcedures.java b/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/IndexProcedures.java index 5d7550126f732..c23b3542cfc68 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/IndexProcedures.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/IndexProcedures.java @@ -24,7 +24,6 @@ import org.neo4j.function.Predicates; import org.neo4j.kernel.api.KernelTransaction; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.ReadOperations; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.ProcedureException; @@ -32,6 +31,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException; import org.neo4j.kernel.api.index.InternalIndexState; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.IndexingService; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingMode; @@ -54,7 +54,7 @@ public void awaitIndex( String indexSpecification, long timeout, TimeUnit timeou { IndexSpecifier index = parse( indexSpecification ); int labelId = getLabelId( index.label() ); - int propertyKeyId = getPropertyKeyId( index.property() ); + int propertyKeyId = getPropertyId( index.property() ); //TODO: Support composite indexes waitUntilOnline( getIndex( labelId, propertyKeyId, index ), index, timeout, timeoutUnits ); } @@ -63,7 +63,7 @@ public void resampleIndex( String indexSpecification ) throws ProcedureException { IndexSpecifier index = parse( indexSpecification ); int labelId = getLabelId( index.label() ); - int propertyKeyId = getPropertyKeyId( index.property() ); + int propertyKeyId = getPropertyId( index.property() ); //TODO: Support composite indexes try { @@ -95,7 +95,7 @@ private int getLabelId( String labelName ) throws ProcedureException return labelId; } - private int getPropertyKeyId( String propertyKeyName ) throws ProcedureException + private int getPropertyId( String propertyKeyName ) throws ProcedureException { int propertyKeyId = operations.propertyKeyGetForName( propertyKeyName ); if ( propertyKeyId == ReadOperations.NO_SUCH_PROPERTY_KEY ) @@ -111,7 +111,9 @@ private NewIndexDescriptor getIndex( int labelId, int propertyKeyId, IndexSpecif { try { - return operations.indexGetForLabelAndPropertyKey( new NodePropertyDescriptor( labelId, propertyKeyId ) ); + final int labelId1 = labelId; + final int[] propertyKeyIds = new int[]{propertyKeyId}; + return operations.indexGetForLabelAndPropertyKey( SchemaDescriptorFactory.forLabel( labelId1, propertyKeyIds ) ); } catch ( SchemaRuleNotFoundException e ) { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/DataIntegrityValidatingStatementOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/DataIntegrityValidatingStatementOperations.java index eef367e33c091..c1df58e187c1a 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/DataIntegrityValidatingStatementOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/DataIntegrityValidatingStatementOperations.java @@ -36,10 +36,8 @@ import org.neo4j.kernel.api.exceptions.schema.RepeatedPropertyInCompositeSchemaException; import org.neo4j.kernel.api.exceptions.schema.SchemaKernelException.OperationContext; import org.neo4j.kernel.api.exceptions.schema.TooManyLabelsException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; import org.neo4j.kernel.api.schema_new.SchemaDescriptor; import org.neo4j.kernel.api.schema_new.constaints.ConstraintBoundary; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor; @@ -118,7 +116,7 @@ public NewIndexDescriptor indexCreate( KernelStatement state, LabelSchemaDescrip throws AlreadyIndexedException, AlreadyConstrainedException, RepeatedPropertyInCompositeSchemaException { assertValidDescriptor( descriptor, OperationContext.INDEX_CREATION ); - assertIndexDoesNotExist( state, OperationContext.INDEX_CREATION, SchemaBoundary.map( descriptor ) ); + assertIndexDoesNotExist( state, OperationContext.INDEX_CREATION, descriptor ); return schemaWriteDelegate.indexCreate( state, descriptor ); } @@ -128,7 +126,7 @@ public void indexDrop( KernelStatement state, NewIndexDescriptor index ) throws try { NewIndexDescriptor existingIndex = - schemaReadDelegate.indexGetForLabelAndPropertyKey( state, SchemaBoundary.map( index.schema() ) ); + schemaReadDelegate.indexGetForLabelAndPropertyKey( state, index.schema() ); if ( existingIndex == null ) { @@ -164,7 +162,7 @@ public UniquenessConstraintDescriptor uniquePropertyConstraintCreate( assertConstraintDoesNotExist( state, constraint ); // It is not allowed to create uniqueness constraints on indexed label/property pairs - assertIndexDoesNotExist( state, OperationContext.CONSTRAINT_CREATION, SchemaBoundary.map( descriptor ) ); + assertIndexDoesNotExist( state, OperationContext.CONSTRAINT_CREATION, descriptor ); return schemaWriteDelegate.uniquePropertyConstraintCreate( state, descriptor ); } @@ -207,7 +205,7 @@ public void constraintDrop( KernelStatement state, ConstraintDescriptor descript } private void assertIndexDoesNotExist( KernelStatement state, OperationContext context, - NodePropertyDescriptor descriptor ) + LabelSchemaDescriptor descriptor ) throws AlreadyIndexedException, AlreadyConstrainedException { NewIndexDescriptor existingIndex = schemaReadDelegate.indexGetForLabelAndPropertyKey( state, descriptor ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/LockingStatementOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/LockingStatementOperations.java index e11a1ad7e5c61..26b04f8d9a089 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/LockingStatementOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/LockingStatementOperations.java @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.function.Function; +import org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.EntityNotFoundException; import org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException; @@ -184,7 +185,7 @@ public Iterator indexesGetForLabel( KernelStatement state, i } @Override - public NewIndexDescriptor indexGetForLabelAndPropertyKey( KernelStatement state, NodePropertyDescriptor descriptor ) + public NewIndexDescriptor indexGetForLabelAndPropertyKey( KernelStatement state, LabelSchemaDescriptor descriptor ) { acquireSharedSchemaLock( state ); state.assertOpen(); 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 774135709ed60..e80d02247425f 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 @@ -37,6 +37,8 @@ import org.neo4j.kernel.api.ExecutionStatisticsOperations; import org.neo4j.kernel.api.KernelTransaction; import org.neo4j.kernel.api.LegacyIndexHits; +import org.neo4j.kernel.api.TokenWriteOperations; +import org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException; import org.neo4j.kernel.api.ProcedureCallOperations; import org.neo4j.kernel.api.QueryRegistryOperations; import org.neo4j.kernel.api.ReadOperations; @@ -76,11 +78,9 @@ import org.neo4j.kernel.api.properties.DefinedProperty; import org.neo4j.kernel.api.properties.Property; import org.neo4j.kernel.api.query.ExecutingQuery; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.IndexQuery; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; import org.neo4j.kernel.api.schema_new.SchemaDescriptor; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor; import org.neo4j.kernel.api.schema_new.constaints.NodeExistenceConstraintDescriptor; @@ -572,14 +572,14 @@ public Cursor relationshipGetProperties( RelationshipItem relation // @Override - public NewIndexDescriptor indexGetForLabelAndPropertyKey( NodePropertyDescriptor descriptor ) + public NewIndexDescriptor indexGetForLabelAndPropertyKey( LabelSchemaDescriptor descriptor ) throws SchemaRuleNotFoundException { statement.assertOpen(); NewIndexDescriptor indexDescriptor = schemaRead().indexGetForLabelAndPropertyKey( statement, descriptor ); if ( indexDescriptor == null ) { - throw new SchemaRuleNotFoundException( SchemaRule.Kind.INDEX_RULE, SchemaBoundary.map( descriptor ) ); + throw new SchemaRuleNotFoundException( SchemaRule.Kind.INDEX_RULE, descriptor ); } return indexDescriptor; } @@ -599,7 +599,7 @@ public Iterator indexesGetAll() } @Override - public NewIndexDescriptor uniqueIndexGetForLabelAndPropertyKey( NodePropertyDescriptor descriptor ) + public NewIndexDescriptor uniqueIndexGetForLabelAndPropertyKey( LabelSchemaDescriptor descriptor ) throws SchemaRuleNotFoundException, DuplicateSchemaRuleException { @@ -608,7 +608,7 @@ public NewIndexDescriptor uniqueIndexGetForLabelAndPropertyKey( NodePropertyDesc while ( indexes.hasNext() ) { NewIndexDescriptor index = indexes.next(); - if ( index.schema().equals( SchemaBoundary.map( descriptor ) ) ) + if ( index.schema().equals( descriptor ) ) { if ( null == result ) { @@ -623,8 +623,7 @@ public NewIndexDescriptor uniqueIndexGetForLabelAndPropertyKey( NodePropertyDesc if ( null == result ) { - throw new SchemaRuleNotFoundException( SchemaRule.Kind.CONSTRAINT_INDEX_RULE, - SchemaBoundary.map( descriptor ) ); + throw new SchemaRuleNotFoundException( SchemaRule.Kind.CONSTRAINT_INDEX_RULE, descriptor ); } return result; 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 26ecf890880b2..595310435421f 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 @@ -60,12 +60,10 @@ import org.neo4j.kernel.api.properties.DefinedProperty; import org.neo4j.kernel.api.properties.Property; import org.neo4j.kernel.api.properties.PropertyKeyIdIterator; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.IndexQuery; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.OrderedPropertyValues; import org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; import org.neo4j.kernel.api.schema_new.SchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaUtil; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor; @@ -711,12 +709,7 @@ public void constraintDrop( KernelStatement state, ConstraintDescriptor constrai } @Override - public NewIndexDescriptor indexGetForLabelAndPropertyKey( KernelStatement state, NodePropertyDescriptor descriptor ) - { - return indexGetForLabelAndPropertyKey( state, SchemaBoundary.map( descriptor ) ); - } - - private NewIndexDescriptor indexGetForLabelAndPropertyKey( KernelStatement state, LabelSchemaDescriptor descriptor ) + public NewIndexDescriptor indexGetForLabelAndPropertyKey( KernelStatement state, LabelSchemaDescriptor descriptor ) { NewIndexDescriptor indexDescriptor = storeLayer.indexGetForLabelAndPropertyKey( descriptor ); Iterator rules = iterator( indexDescriptor ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedIndexProxy.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedIndexProxy.java index 2691baae7ab4a..0a20a0d5bd489 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedIndexProxy.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedIndexProxy.java @@ -28,7 +28,6 @@ import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.SchemaIndexProvider; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.logging.Log; import org.neo4j.logging.LogProvider; @@ -78,8 +77,7 @@ public InternalIndexState getState() @Override public boolean awaitStoreScanCompleted() throws IndexPopulationFailedKernelException { - throw getPopulationFailure().asIndexPopulationFailure( - SchemaBoundary.map( getDescriptor().schema() ), indexUserDescription ); + throw getPopulationFailure().asIndexPopulationFailure( getDescriptor().schema(), indexUserDescription ); } @Override @@ -91,8 +89,7 @@ public void activate() @Override public void validate() throws IndexPopulationFailedKernelException { - throw getPopulationFailure().asIndexPopulationFailure( - SchemaBoundary.map( getDescriptor().schema() ), indexUserDescription ); + throw getPopulationFailure().asIndexPopulationFailure( getDescriptor().schema(), indexUserDescription ); } @Override diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexPopulationFailure.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexPopulationFailure.java index 1808c4306c524..527a87f299294 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexPopulationFailure.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexPopulationFailure.java @@ -20,15 +20,15 @@ package org.neo4j.kernel.impl.api.index; import org.neo4j.helpers.Exceptions; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; public abstract class IndexPopulationFailure { public abstract String asString(); public abstract IndexPopulationFailedKernelException asIndexPopulationFailure( - NodePropertyDescriptor descriptor, String indexUserDescriptor ); + LabelSchemaDescriptor descriptor, String indexUserDescriptor ); public static IndexPopulationFailure failure( final Throwable failure ) { @@ -42,7 +42,7 @@ public String asString() @Override public IndexPopulationFailedKernelException asIndexPopulationFailure( - NodePropertyDescriptor descriptor, String indexUserDescription ) + LabelSchemaDescriptor descriptor, String indexUserDescription ) { return new IndexPopulationFailedKernelException( descriptor, indexUserDescription, failure ); } @@ -61,7 +61,7 @@ public String asString() @Override public IndexPopulationFailedKernelException asIndexPopulationFailure( - NodePropertyDescriptor descriptor, String indexUserDescription ) + LabelSchemaDescriptor descriptor, String indexUserDescription ) { return new IndexPopulationFailedKernelException( descriptor, indexUserDescription, failure ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/SchemaReadOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/SchemaReadOperations.java index 7ce3b43b71ba1..eaee17dffc7e0 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/SchemaReadOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/SchemaReadOperations.java @@ -21,8 +21,6 @@ import java.util.Iterator; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; -import org.neo4j.kernel.api.schema.RelationshipPropertyDescriptor; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.constraints.NodePropertyConstraint; import org.neo4j.kernel.api.constraints.PropertyConstraint; @@ -30,6 +28,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException; import org.neo4j.kernel.api.index.InternalIndexState; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptor; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; @@ -41,7 +40,7 @@ public interface SchemaReadOperations /** * Returns the descriptor for the given labelId and propertyKey. */ - NewIndexDescriptor indexGetForLabelAndPropertyKey( KernelStatement state, NodePropertyDescriptor descriptor ); + NewIndexDescriptor indexGetForLabelAndPropertyKey( KernelStatement state, LabelSchemaDescriptor descriptor ); /** * Get all indexes for a label. diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/coreapi/schema/PropertyNameUtils.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/coreapi/schema/PropertyNameUtils.java index cdb1b1a648b2d..5035fc1f86fc1 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/coreapi/schema/PropertyNameUtils.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/coreapi/schema/PropertyNameUtils.java @@ -28,7 +28,7 @@ import org.neo4j.kernel.api.TokenWriteOperations; import org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException; import org.neo4j.kernel.api.exceptions.schema.IllegalTokenNameException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; public class PropertyNameUtils { @@ -36,11 +36,11 @@ private PropertyNameUtils() { } - public static String[] getPropertyKeys( ReadOperations readOperations, NodePropertyDescriptor descriptor ) + public static String[] getPropertyKeys( ReadOperations readOperations, LabelSchemaDescriptor descriptor ) throws PropertyKeyIdNotFoundKernelException { int[] propertyKeyIds = - descriptor.isComposite() ? descriptor.getPropertyKeyIds() : new int[]{descriptor.getPropertyKeyId()}; + false ? descriptor.getPropertyIds() : new int[]{descriptor.getPropertyId()}; String[] propertyKeys = new String[propertyKeyIds.length]; for ( int i = 0; i < propertyKeyIds.length; i++ ) { @@ -49,10 +49,10 @@ public static String[] getPropertyKeys( ReadOperations readOperations, NodePrope return propertyKeys; } - public static String[] getPropertyKeys( TokenNameLookup tokenNameLookup, NodePropertyDescriptor descriptor ) + public static String[] getPropertyKeys( TokenNameLookup tokenNameLookup, LabelSchemaDescriptor descriptor ) { int[] propertyKeyIds = - descriptor.isComposite() ? descriptor.getPropertyKeyIds() : new int[]{descriptor.getPropertyKeyId()}; + false ? descriptor.getPropertyIds() : new int[]{descriptor.getPropertyId()}; String[] propertyKeys = new String[propertyKeyIds.length]; for ( int i = 0; i < propertyKeyIds.length; i++ ) { @@ -82,7 +82,7 @@ public static String[] getPropertyKeys( TokenNameLookup tokenNameLookup, int[] p return propertyKeys; } - public static int[] getPropertyKeyIds( ReadOperations statement, String[] propertyKeys ) + public static int[] getPropertyIds( ReadOperations statement, String[] propertyKeys ) { int[] propertyKeyIds = new int[propertyKeys.length]; for ( int i = 0; i < propertyKeys.length; i++ ) @@ -92,7 +92,7 @@ public static int[] getPropertyKeyIds( ReadOperations statement, String[] proper return propertyKeyIds; } - public static int[] getPropertyKeyIds( ReadOperations statement, Iterable propertyKeys ) + public static int[] getPropertyIds( ReadOperations statement, Iterable propertyKeys ) { return Iterables.stream( propertyKeys ).mapToInt( statement::propertyKeyGetForName ).toArray(); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/coreapi/schema/SchemaImpl.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/coreapi/schema/SchemaImpl.java index 72741d70de3b5..aae4c6d552acf 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/coreapi/schema/SchemaImpl.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/coreapi/schema/SchemaImpl.java @@ -45,7 +45,6 @@ import org.neo4j.kernel.api.constraints.NodePropertyConstraint; import org.neo4j.kernel.api.constraints.NodePropertyExistenceConstraint; import org.neo4j.kernel.api.constraints.PropertyConstraint; -import org.neo4j.kernel.api.constraints.RelationshipPropertyConstraint; import org.neo4j.kernel.api.constraints.RelationshipPropertyExistenceConstraint; import org.neo4j.kernel.api.constraints.UniquenessConstraint; import org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException; @@ -63,9 +62,8 @@ import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException; import org.neo4j.kernel.api.exceptions.schema.TooManyLabelsException; import org.neo4j.kernel.api.index.InternalIndexState; -import org.neo4j.kernel.api.schema.NodeMultiPropertyDescriptor; -import org.neo4j.kernel.api.schema.RelationshipPropertyDescriptor; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.constaints.ConstraintBoundary; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor; @@ -327,11 +325,10 @@ private static NewIndexDescriptor getIndexDescriptor( ReadOperations readOperati throws SchemaRuleNotFoundException { int labelId = readOperations.labelGetForName( index.getLabel().name() ); - int[] propertyKeyIds = PropertyNameUtils.getPropertyKeyIds( readOperations, index.getPropertyKeys() ); + int[] propertyKeyIds = PropertyNameUtils.getPropertyIds( readOperations, index.getPropertyKeys() ); assertValidLabel( index.getLabel(), labelId ); assertValidProperties( index.getPropertyKeys(), propertyKeyIds ); - return readOperations.indexGetForLabelAndPropertyKey( - new NodeMultiPropertyDescriptor( labelId, propertyKeyIds ) ); + return readOperations.indexGetForLabelAndPropertyKey( SchemaDescriptorFactory.forLabel( labelId, propertyKeyIds ) ); } private static void assertValidLabel( Label label, int labelId ) @@ -397,10 +394,10 @@ else if ( constraint instanceof UniquenessConstraint ) else if ( constraint instanceof RelationshipPropertyExistenceConstraint ) { StatementTokenNameLookup lookup = new StatementTokenNameLookup( readOperations ); - RelationshipPropertyDescriptor descriptor = ((RelationshipPropertyConstraint) constraint).descriptor(); + RelationTypeSchemaDescriptor descriptor = (RelationTypeSchemaDescriptor) constraint.descriptor(); return new RelationshipPropertyExistenceConstraintDefinition( actions, - RelationshipType.withName( lookup.relationshipTypeGetName( descriptor.getRelationshipTypeId() ) ), - lookup.propertyKeyGetName( descriptor.getPropertyKeyId() ) ); + RelationshipType.withName( lookup.relationshipTypeGetName( descriptor.getRelTypeId() ) ), + lookup.propertyKeyGetName( descriptor.getPropertyId() ) ); } throw new IllegalArgumentException( "Unknown constraint " + constraint ); } @@ -585,7 +582,7 @@ public void dropPropertyUniquenessConstraint( Label label, String[] properties ) try { int labelId = statement.readOperations().labelGetForName( label.name() ); - int[] propertyKeyIds = PropertyNameUtils.getPropertyKeyIds( statement.readOperations(), properties ); + int[] propertyKeyIds = PropertyNameUtils.getPropertyIds( statement.readOperations(), properties ); statement.schemaWriteOperations().constraintDrop( ConstraintDescriptorFactory.uniqueForLabel( labelId, propertyKeyIds ) ); } @@ -609,7 +606,7 @@ public void dropNodePropertyExistenceConstraint( Label label, String[] propertie try { int labelId = statement.readOperations().labelGetForName( label.name() ); - int[] propertyKeyIds = PropertyNameUtils.getPropertyKeyIds( statement.readOperations(), properties ); + int[] propertyKeyIds = PropertyNameUtils.getPropertyIds( statement.readOperations(), properties ); statement.schemaWriteOperations().constraintDrop( ConstraintDescriptorFactory.existsForLabel( labelId, propertyKeyIds ) ); } 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 acbd5ed6e3354..9eea57b9d73ba 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 @@ -58,7 +58,6 @@ import org.neo4j.kernel.GraphDatabaseQueryService; import org.neo4j.kernel.api.KernelTransaction; import org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.ReadOperations; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.EntityNotFoundException; @@ -72,6 +71,8 @@ import org.neo4j.kernel.api.legacyindex.AutoIndexing; import org.neo4j.kernel.api.properties.Property; import org.neo4j.kernel.api.schema_new.IndexQuery; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.security.SecurityContext; import org.neo4j.kernel.configuration.Config; @@ -615,8 +616,10 @@ private NewIndexDescriptor findAnyIndexByLabelAndProperty( ReadOperations readOp { try { + final int labelId1 = labelId; + final int[] propertyKeyIds = new int[]{propertyId}; NewIndexDescriptor descriptor = - readOps.indexGetForLabelAndPropertyKey( new NodePropertyDescriptor( labelId, propertyId ) ); + readOps.indexGetForLabelAndPropertyKey( SchemaDescriptorFactory.forLabel( labelId1, propertyKeyIds ) ); if ( readOps.indexGetState( descriptor ) == InternalIndexState.ONLINE ) { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureArgumentFormatter.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureArgumentFormatter.java index 825545beab6ba..a0e7caf4c75a2 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureArgumentFormatter.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureArgumentFormatter.java @@ -29,8 +29,8 @@ import org.neo4j.kernel.api.constraints.NodePropertyExistenceConstraint; import org.neo4j.kernel.api.constraints.RelationshipPropertyExistenceConstraint; import org.neo4j.kernel.api.constraints.UniquenessConstraint; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; -import org.neo4j.kernel.api.schema.RelationshipPropertyDescriptor; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; @@ -42,7 +42,7 @@ public enum DbStructureArgumentFormatter implements ArgumentFormatter private static List IMPORTS = Arrays.asList( UniquenessConstraint.class.getCanonicalName(), - NodePropertyDescriptor.class.getCanonicalName(), + LabelSchemaDescriptor.class.getCanonicalName(), NewIndexDescriptor.class.getCanonicalName(), NewIndexDescriptorFactory.class.getCanonicalName() ); @@ -98,18 +98,18 @@ else if ( arg instanceof NewIndexDescriptor ) builder.append( format( "NewIndexDescriptorFactory.forLabel( %d, %s )", labelId, asString( descriptor.schema().getPropertyIds() ) ) ); } - else if ( arg instanceof NodePropertyDescriptor ) + else if ( arg instanceof LabelSchemaDescriptor ) { - NodePropertyDescriptor descriptor = (NodePropertyDescriptor) arg; + LabelSchemaDescriptor descriptor = (LabelSchemaDescriptor) arg; int labelId = descriptor.getLabelId(); - builder.append( format( "new NodePropertyDescriptor( %s, %s )", labelId, descriptor.propertyIdText() ) ); + builder.append( format( "new NodePropertyDescriptor( %d, %d )", labelId, descriptor.getPropertyId() ) ); } else if ( arg instanceof UniquenessConstraint ) { UniquenessConstraint constraint = (UniquenessConstraint) arg; int labelId = constraint.label(); builder.append( format( "new UniquenessConstraint( new NodePropertyDescriptor( %s, %s ) )", labelId, - constraint.descriptor().propertyIdText() ) ); + constraint.descriptor().getPropertyId() ) ); } else if ( arg instanceof NodePropertyExistenceConstraint ) { @@ -117,13 +117,15 @@ else if ( arg instanceof NodePropertyExistenceConstraint ) int labelId = constraint.label(); builder.append( format( "new NodePropertyExistenceConstraint( new NodePropertyDescriptor( %s, %s ) )", labelId, - constraint.descriptor().propertyIdText() ) ); + constraint.descriptor().getPropertyId() ) ); } else if ( arg instanceof RelationshipPropertyExistenceConstraint ) { - RelationshipPropertyDescriptor descriptor = ((RelationshipPropertyExistenceConstraint) arg).descriptor(); - int relTypeId = descriptor.getRelationshipTypeId(); - int propertyKey = descriptor.getPropertyKeyId(); + RelationTypeSchemaDescriptor descriptor = (RelationTypeSchemaDescriptor) ( + (RelationshipPropertyExistenceConstraint) arg) + .descriptor(); + int relTypeId = descriptor.getRelTypeId(); + int propertyKey = descriptor.getPropertyId(); builder.append( format( "new RelationshipPropertyExistenceConstraint( new NodePropertyDescriptor( %s, %s ) )", relTypeId, propertyKey ) ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureCollector.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureCollector.java index bb1571c7f7b2a..5fc50f31493ac 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureCollector.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureCollector.java @@ -90,7 +90,7 @@ public Iterator> knownUniqueConstraints() //TODO: Add support for composite indexes return Iterators.map( uniquenessConstraint -> { String label = labels.byIdOrFail( uniquenessConstraint.label() ); - String propertyKey = propertyKeys.byIdOrFail( uniquenessConstraint.descriptor().getPropertyKeyId() ); + String propertyKey = propertyKeys.byIdOrFail( uniquenessConstraint.descriptor().getPropertyId() ); return Pair.of( label, propertyKey ); }, uniquenessConstraints.iterator() ); } @@ -101,7 +101,7 @@ public Iterator> knownNodePropertyExistenceConstraints() //TODO: Add support for composite indexes return Iterators.map( uniquenessConstraint -> { String label = labels.byIdOrFail( uniquenessConstraint.label() ); - String propertyKey = propertyKeys.byIdOrFail( uniquenessConstraint.descriptor().getPropertyKeyId() ); + String propertyKey = propertyKeys.byIdOrFail( uniquenessConstraint.descriptor().getPropertyId() ); return Pair.of( label, propertyKey ); }, nodePropertyExistenceConstraints.iterator() ); } diff --git a/community/kernel/src/main/java/org/neo4j/unsafe/batchinsert/internal/BatchInserterImpl.java b/community/kernel/src/main/java/org/neo4j/unsafe/batchinsert/internal/BatchInserterImpl.java index 954814dc8e80b..4f62e13f2ba99 100644 --- a/community/kernel/src/main/java/org/neo4j/unsafe/batchinsert/internal/BatchInserterImpl.java +++ b/community/kernel/src/main/java/org/neo4j/unsafe/batchinsert/internal/BatchInserterImpl.java @@ -67,8 +67,6 @@ import org.neo4j.kernel.api.labelscan.LabelScanWriter; import org.neo4j.kernel.api.labelscan.NodeLabelUpdate; import org.neo4j.kernel.api.properties.DefinedProperty; -import org.neo4j.kernel.api.schema.NodeMultiPropertyDescriptor; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor; @@ -1123,7 +1121,7 @@ public ConstraintDefinition createPropertyUniquenessConstraint( IndexDefinition { int labelId = getOrCreateLabelId( indexDefinition.getLabel().name() ); int[] propertyKeyIds = getOrCreatePropertyKeyIds( indexDefinition.getPropertyKeys() ); - NodePropertyDescriptor descriptor = new NodeMultiPropertyDescriptor( labelId, propertyKeyIds ); + LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel( labelId, propertyKeyIds ); validateUniquenessConstraintCanBeCreated( labelId, propertyKeyIds ); createUniquenessConstraintRule( new UniquenessConstraint( descriptor ) ); 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 f48c166de1870..cf1038ae129af 100644 --- a/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java +++ b/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java @@ -37,8 +37,8 @@ import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException; -import org.neo4j.kernel.api.schema.NodeMultiPropertyDescriptor; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge; import org.neo4j.kernel.internal.GraphDatabaseAPI; @@ -52,7 +52,7 @@ import static org.neo4j.helpers.collection.Iterators.count; import static org.neo4j.helpers.collection.MapUtil.map; import static org.neo4j.kernel.api.schema_new.IndexQuery.stringPrefix; -import static org.neo4j.kernel.impl.coreapi.schema.PropertyNameUtils.getPropertyKeyIds; +import static org.neo4j.kernel.impl.coreapi.schema.PropertyNameUtils.getPropertyIds; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.containsOnly; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.findNodesByLabelAndProperty; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasProperty; @@ -613,9 +613,9 @@ private NewIndexDescriptor indexDescriptor( ReadOperations readOperations, Index throws SchemaRuleNotFoundException { int labelId = readOperations.labelGetForName( index.getLabel().name() ); - int[] propertyKeyIds = getPropertyKeyIds( readOperations, index.getPropertyKeys() ); + int[] propertyKeyIds = getPropertyIds( readOperations, index.getPropertyKeys() ); - NodePropertyDescriptor descriptor = new NodeMultiPropertyDescriptor( labelId, propertyKeyIds ); + LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel( labelId, propertyKeyIds ); return readOperations.indexGetForLabelAndPropertyKey( descriptor ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/AwaitIndexProcedureTest.java b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/AwaitIndexProcedureTest.java index feeb789c3ac6c..09cfc8434ff98 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/AwaitIndexProcedureTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/AwaitIndexProcedureTest.java @@ -27,14 +27,13 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.ReadOperations; import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException; import org.neo4j.kernel.api.index.InternalIndexState; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; @@ -62,10 +61,9 @@ public class AwaitIndexProcedureTest private static final TimeUnit timeoutUnits = TimeUnit.MILLISECONDS; private final ReadOperations operations = mock( ReadOperations.class ); private final IndexProcedures procedure = new IndexProcedures( new StubKernelTransaction( operations ), null ); - private final NodePropertyDescriptor descriptor = new NodePropertyDescriptor( 123, 456 ); - private final NodePropertyDescriptor anyDescriptor = new NodePropertyDescriptor( 0, 0 ); - private final NewIndexDescriptor anyIndex = NewIndexDescriptorFactory.forSchema( SchemaBoundary.map( - anyDescriptor ) ); + private final LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel( 123, 456 ); + private final LabelSchemaDescriptor anyDescriptor = SchemaDescriptorFactory.forLabel( 0, 0 ); + private final NewIndexDescriptor anyIndex = NewIndexDescriptorFactory.forSchema( anyDescriptor ); @Test public void shouldThrowAnExceptionIfTheLabelDoesntExist() throws ProcedureException @@ -104,7 +102,7 @@ public void shouldLookUpTheIndexByLabelIdAndPropertyKeyId() throws ProcedureException, SchemaRuleNotFoundException, IndexNotFoundKernelException { when( operations.labelGetForName( anyString() ) ).thenReturn( descriptor.getLabelId() ); - when( operations.propertyKeyGetForName( anyString() ) ).thenReturn( descriptor.getPropertyKeyId() ); + when( operations.propertyKeyGetForName( anyString() ) ).thenReturn( descriptor.getPropertyId() ); when( operations.indexGetForLabelAndPropertyKey( anyObject() ) ).thenReturn( anyIndex ); when( operations.indexGetState( any( NewIndexDescriptor.class ) ) ).thenReturn( ONLINE ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/ResampleIndexProcedureTest.java b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/ResampleIndexProcedureTest.java index 6060ac3726031..dc552fc924c1c 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/ResampleIndexProcedureTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/ResampleIndexProcedureTest.java @@ -26,7 +26,7 @@ import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; @@ -94,7 +94,8 @@ public void shouldLookUpTheIndexByLabelIdAndPropertyKeyId() procedure.resampleIndex( ":Person(name)" ); - verify( operations ).indexGetForLabelAndPropertyKey( new NodePropertyDescriptor( 123, 456 ) ); + final int[] propertyKeyIds = new int[]{456}; + verify( operations ).indexGetForLabelAndPropertyKey( SchemaDescriptorFactory.forLabel( 123, propertyKeyIds ) ); } @Test diff --git a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/SchemaProcedureIT.java b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/SchemaProcedureIT.java index b2750d2f19a27..a87912a6d3388 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/SchemaProcedureIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/SchemaProcedureIT.java @@ -35,7 +35,6 @@ import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.properties.DefinedProperty; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.security.AnonymousContext; import org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/DataIntegrityValidatingStatementOperationsTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/DataIntegrityValidatingStatementOperationsTest.java index 97f09f173609e..88407a050a189 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/DataIntegrityValidatingStatementOperationsTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/DataIntegrityValidatingStatementOperationsTest.java @@ -28,16 +28,15 @@ import java.util.Iterator; -import org.neo4j.kernel.api.exceptions.schema.RepeatedPropertyInCompositeSchemaException; import org.neo4j.kernel.api.exceptions.schema.AlreadyConstrainedException; import org.neo4j.kernel.api.exceptions.schema.AlreadyIndexedException; import org.neo4j.kernel.api.exceptions.schema.DropIndexFailureException; import org.neo4j.kernel.api.exceptions.schema.IllegalTokenNameException; import org.neo4j.kernel.api.exceptions.schema.IndexBelongsToConstraintException; import org.neo4j.kernel.api.exceptions.schema.NoSuchIndexException; +import org.neo4j.kernel.api.exceptions.schema.RepeatedPropertyInCompositeSchemaException; import org.neo4j.kernel.api.exceptions.schema.SchemaKernelException; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; @@ -82,7 +81,7 @@ public void setup() public void shouldDisallowReAddingIndex() throws Exception { // GIVEN - when( innerRead.indexGetForLabelAndPropertyKey( state, SchemaBoundary.map( descriptor ) ) ).thenReturn( index ); + when( innerRead.indexGetForLabelAndPropertyKey( state, descriptor ) ).thenReturn( index ); // WHEN try @@ -103,7 +102,7 @@ public void shouldDisallowReAddingIndex() throws Exception public void shouldDisallowAddingIndexWhenConstraintIndexExists() throws Exception { // GIVEN - when( innerRead.indexGetForLabelAndPropertyKey( state, SchemaBoundary.map( descriptor ) ) ).thenReturn( uniqueIndex ); + when( innerRead.indexGetForLabelAndPropertyKey( state, descriptor ) ).thenReturn( uniqueIndex ); // WHEN try @@ -124,7 +123,7 @@ public void shouldDisallowAddingIndexWhenConstraintIndexExists() throws Exceptio public void shouldDisallowDroppingIndexThatDoesNotExist() throws Exception { // GIVEN - when( innerRead.indexGetForLabelAndPropertyKey( state, SchemaBoundary.map( descriptor ) ) ).thenReturn( null ); + when( innerRead.indexGetForLabelAndPropertyKey( state, descriptor ) ).thenReturn( null ); // WHEN try @@ -145,7 +144,7 @@ public void shouldDisallowDroppingIndexThatDoesNotExist() throws Exception public void shouldDisallowDroppingIndexWhenConstraintIndexExists() throws Exception { // GIVEN - when( innerRead.indexGetForLabelAndPropertyKey( state, SchemaBoundary.map( descriptor ) ) ).thenReturn( uniqueIndex ); + when( innerRead.indexGetForLabelAndPropertyKey( state, descriptor ) ).thenReturn( uniqueIndex ); // WHEN try @@ -166,7 +165,7 @@ public void shouldDisallowDroppingIndexWhenConstraintIndexExists() throws Except public void shouldDisallowDroppingConstraintIndexThatDoesNotExists() throws Exception { // GIVEN - when( innerRead.indexGetForLabelAndPropertyKey( state, SchemaBoundary.map( descriptor ) ) ).thenReturn( uniqueIndex ); + when( innerRead.indexGetForLabelAndPropertyKey( state, descriptor ) ).thenReturn( uniqueIndex ); // WHEN try @@ -187,7 +186,7 @@ public void shouldDisallowDroppingConstraintIndexThatDoesNotExists() throws Exce public void shouldDisallowDroppingConstraintIndexThatIsReallyJustRegularIndex() throws Exception { // GIVEN - when( innerRead.indexGetForLabelAndPropertyKey( state, SchemaBoundary.map( descriptor ) ) ).thenReturn( uniqueIndex ); + when( innerRead.indexGetForLabelAndPropertyKey( state, descriptor ) ).thenReturn( uniqueIndex ); // WHEN try diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/KernelTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/KernelTest.java index 2627c725cae1f..913c69088cd34 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/KernelTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/KernelTest.java @@ -26,10 +26,8 @@ import java.util.function.Function; import org.neo4j.graphdb.Transaction; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException; -import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge; import org.neo4j.kernel.impl.factory.CommunityEditionModule; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/LockingStatementOperationsTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/LockingStatementOperationsTest.java index 90c47cffcda10..7ede31bd2d76c 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/LockingStatementOperationsTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/LockingStatementOperationsTest.java @@ -33,7 +33,6 @@ import org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException; import org.neo4j.kernel.api.properties.DefinedProperty; import org.neo4j.kernel.api.properties.Property; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/OperationsFacadeTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/OperationsFacadeTest.java index ea640345cc0e8..0d1439349b45f 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/OperationsFacadeTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/OperationsFacadeTest.java @@ -30,11 +30,11 @@ import org.mockito.runners.MockitoJUnitRunner; import org.neo4j.helpers.collection.Iterators; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.TokenNameLookup; import org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException; import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.impl.api.operations.SchemaReadOperations; @@ -47,7 +47,7 @@ public class OperationsFacadeTest { private final String LABEL1 = "Label1"; private final String PROP1 = "Prop1"; - private final NodePropertyDescriptor descriptor = new NodePropertyDescriptor( 1, 2 ); + private final LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel( 1, 2 ); @Mock private KernelStatement kernelStatement; @@ -86,7 +86,7 @@ public void testThrowExceptionWhenDuplicateUniqueIndexFound() throws SchemaRuleNotFoundException, DuplicateSchemaRuleException { SchemaReadOperations readOperations = setupSchemaReadOperations(); - NewIndexDescriptor index = NewIndexDescriptorFactory.forSchema( SchemaBoundary.map( descriptor ) ); + NewIndexDescriptor index = NewIndexDescriptorFactory.forSchema( descriptor ); Mockito.when( readOperations .uniqueIndexesGetForLabel( Mockito.any( KernelStatement.class ), Mockito.eq( descriptor.getLabelId() ) ) ) .thenReturn( Iterators.iterator( index, index ) ); @@ -127,7 +127,7 @@ private TokenNameLookup getDefaultTokenNameLookup() { TokenNameLookup tokenNameLookup = Mockito.mock( TokenNameLookup.class ); Mockito.when( tokenNameLookup.labelGetName( descriptor.getLabelId() ) ).thenReturn( LABEL1 ); - Mockito.when( tokenNameLookup.propertyKeyGetName( descriptor.getPropertyKeyId() ) ).thenReturn( PROP1 ); + Mockito.when( tokenNameLookup.propertyKeyGetName( descriptor.getPropertyId() ) ).thenReturn( PROP1 ); return tokenNameLookup; } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/constraints/ConstraintIndexCreatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/constraints/ConstraintIndexCreatorTest.java index cd95912a3ce92..2490c0d00b3f0 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/constraints/ConstraintIndexCreatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/constraints/ConstraintIndexCreatorTest.java @@ -39,8 +39,6 @@ import org.neo4j.kernel.api.proc.CallableProcedure; import org.neo4j.kernel.api.proc.CallableUserAggregationFunction; import org.neo4j.kernel.api.proc.CallableUserFunction; -import org.neo4j.kernel.api.schema_new.OrderedPropertyValues; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; @@ -120,7 +118,7 @@ public void shouldDropIndexIfPopulationFails() throws Exception IndexProxy indexProxy = mock( IndexProxy.class ); when( indexingService.getIndexProxy( 2468L ) ).thenReturn( indexProxy ); IndexEntryConflictException cause = new IndexEntryConflictException( 2, 1, "a" ); - doThrow( new IndexPopulationFailedKernelException( SchemaBoundary.map( descriptor ), "some index", cause ) ) + doThrow( new IndexPopulationFailedKernelException( descriptor, "some index", cause ) ) .when( indexProxy ).awaitStoreScanCompleted(); PropertyAccessor propertyAccessor = mock( PropertyAccessor.class ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexIT.java index bc4fb56d2f85d..9b02ef7058303 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexIT.java @@ -32,8 +32,7 @@ import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.TokenWriteOperations; import org.neo4j.kernel.api.exceptions.schema.SchemaKernelException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.security.AnonymousContext; import org.neo4j.kernel.api.security.SecurityContext; @@ -58,7 +57,7 @@ public class IndexIT extends KernelIntegrationTest private int labelId; private int propertyKeyId; - private NodePropertyDescriptor descriptor; + private LabelSchemaDescriptor descriptor; @Before public void createLabelAndProperty() throws Exception @@ -66,7 +65,9 @@ public void createLabelAndProperty() throws Exception TokenWriteOperations tokenWrites = tokenWriteOperationsInNewTransaction(); labelId = tokenWrites.labelGetOrCreateForName( LABEL ); propertyKeyId = tokenWrites.propertyKeyGetOrCreateForName( PROPERTY_KEY ); - descriptor = new NodePropertyDescriptor( labelId, propertyKeyId ); + final int labelId1 = labelId; + final int[] propertyKeyIds = new int[]{propertyKeyId}; + descriptor = SchemaDescriptorFactory.forLabel( labelId1, propertyKeyIds ); commit(); } @@ -77,7 +78,7 @@ public void addIndexRuleInATransaction() throws Exception SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction(); // WHEN - NewIndexDescriptor expectedRule = schemaWriteOperations.indexCreate( SchemaBoundary.map( descriptor ) ); + NewIndexDescriptor expectedRule = schemaWriteOperations.indexCreate( descriptor ); commit(); // THEN @@ -92,7 +93,7 @@ public void committedAndTransactionalIndexRulesShouldBeMerged() throws Exception { // GIVEN SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction(); - NewIndexDescriptor existingRule = schemaWriteOperations.indexCreate( SchemaBoundary.map( descriptor ) ); + NewIndexDescriptor existingRule = schemaWriteOperations.indexCreate( descriptor ); commit(); // WHEN @@ -113,7 +114,7 @@ public void rollBackIndexRuleShouldNotBeCommitted() throws Exception SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction(); // WHEN - schemaWriteOperations.indexCreate( SchemaBoundary.map( descriptor ) ); + schemaWriteOperations.indexCreate( descriptor ); // don't mark as success rollback(); @@ -129,7 +130,8 @@ public void shouldRemoveAConstraintIndexWithoutOwnerInRecovery() throws Exceptio // given PropertyAccessor propertyAccessor = mock( PropertyAccessor.class ); ConstraintIndexCreator creator = new ConstraintIndexCreator( () -> kernel, indexingService, propertyAccessor, false ); - creator.createConstraintIndex( SchemaBoundary.map( descriptor ) ); + + creator.createConstraintIndex( descriptor ); // when restartDb(); @@ -147,7 +149,7 @@ public void shouldDisallowDroppingIndexThatDoesNotExist() throws Exception NewIndexDescriptor index; { SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction(); - index = statement.indexCreate( SchemaBoundary.map( descriptor ) ); + index = statement.indexCreate( descriptor ); commit(); } { @@ -177,7 +179,7 @@ public void shouldFailToCreateIndexWhereAConstraintAlreadyExists() throws Except // given { SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction(); - statement.uniquePropertyConstraintCreate( SchemaBoundary.map( descriptor ) ); + statement.uniquePropertyConstraintCreate( descriptor ); commit(); } @@ -185,7 +187,7 @@ public void shouldFailToCreateIndexWhereAConstraintAlreadyExists() throws Except try { SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction(); - statement.indexCreate( SchemaBoundary.map( descriptor ) ); + statement.indexCreate( descriptor ); commit(); fail( "expected exception" ); @@ -245,7 +247,7 @@ public void shouldNotListConstraintIndexesAmongIndexes() throws Exception { // given SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction(); - schemaWriteOperations.uniquePropertyConstraintCreate( SchemaBoundary.map( descriptor ) ); + schemaWriteOperations.uniquePropertyConstraintCreate( descriptor ); commit(); // then/when @@ -259,7 +261,7 @@ public void shouldNotListIndexesAmongConstraintIndexes() throws Exception { // given SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction(); - schemaWriteOperations.indexCreate( SchemaBoundary.map( descriptor ) ); + schemaWriteOperations.indexCreate( descriptor ); commit(); // then/when diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java index 9b48bc44b2a3e..e91cf29c95cc0 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java @@ -31,7 +31,6 @@ import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.TokenWriteOperations; import org.neo4j.kernel.api.exceptions.ProcedureException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.security.AnonymousContext; import org.neo4j.kernel.api.security.SecurityContext; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/KernelIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/KernelIT.java index 14b428bf43bcd..8ab960c37f9f8 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/KernelIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/KernelIT.java @@ -43,7 +43,6 @@ import org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException; import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.kernel.api.exceptions.schema.SchemaKernelException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.security.AnonymousContext; 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 a9a3696693786..ce6031046b2dc 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 @@ -34,7 +34,6 @@ import org.neo4j.kernel.api.exceptions.schema.IndexBrokenKernelException; import org.neo4j.kernel.api.properties.Property; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.security.SecurityContext; @@ -252,7 +251,7 @@ private NewIndexDescriptor createUniquenessConstraint( int labelId, int... prope LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel( labelId, propertyIds ); statement.schemaWriteOperations().uniquePropertyConstraintCreate( descriptor ); NewIndexDescriptor result = - statement.readOperations().uniqueIndexGetForLabelAndPropertyKey( SchemaBoundary.map( descriptor ) ); + statement.readOperations().uniqueIndexGetForLabelAndPropertyKey( descriptor ); commit(); return result; } 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 71ad929957725..390c897601c56 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 @@ -30,7 +30,8 @@ import org.neo4j.kernel.api.exceptions.KernelException; import org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException; import org.neo4j.kernel.api.properties.DefinedProperty; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.security.AnonymousContext; @@ -300,8 +301,10 @@ public void unrelatedNodesWithSamePropertyShouldNotInterfereWithUniquenessCheck( ReadOperations readOps = statement.readOperations(); int person = readOps.labelGetForName( "Person" ); int propId = readOps.propertyKeyGetForName( "id" ); + final int labelId = person; + final int[] propertyKeyIds = new int[]{propId}; NewIndexDescriptor idx = readOps - .uniqueIndexGetForLabelAndPropertyKey( new NodePropertyDescriptor( person, propId ) ); + .uniqueIndexGetForLabelAndPropertyKey( SchemaDescriptorFactory.forLabel( labelId, propertyKeyIds ) ); // when createLabeledNode( statement, "Item", "id", 2 ); @@ -327,8 +330,10 @@ public void addingUniqueNodeWithUnrelatedValueShouldNotAffectLookup() throws Exc ReadOperations readOps = statement.readOperations(); int person = readOps.labelGetForName( "Person" ); int propId = readOps.propertyKeyGetForName( "id" ); + final int labelId = person; + final int[] propertyKeyIds = new int[]{propId}; NewIndexDescriptor idx = readOps - .uniqueIndexGetForLabelAndPropertyKey( new NodePropertyDescriptor( person, propId ) ); + .uniqueIndexGetForLabelAndPropertyKey( SchemaDescriptorFactory.forLabel( labelId, propertyKeyIds ) ); // when createLabeledNode( statement, "Person", "id", 2 ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/SchemaTransactionStateTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/SchemaTransactionStateTest.java index 8ef835aa1acd3..fa7e351df1302 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/SchemaTransactionStateTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/SchemaTransactionStateTest.java @@ -33,7 +33,7 @@ import org.neo4j.helpers.collection.Iterators; import org.neo4j.kernel.api.index.InternalIndexState; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; @@ -67,7 +67,9 @@ private static NewIndexDescriptor indexCreate( StateHandlingStatementOperations private static NewIndexDescriptor indexGetForLabelAndPropertyKey( StateHandlingStatementOperations txContext, KernelStatement state, int labelId, int propertyKey ) { - return txContext.indexGetForLabelAndPropertyKey( state, new NodePropertyDescriptor( labelId, propertyKey ) ); + final int labelId3 = labelId; + final int[] propertyKeyIds = new int[]{propertyKey}; + return txContext.indexGetForLabelAndPropertyKey( state, SchemaDescriptorFactory.forLabel( labelId3, propertyKeyIds ) ); } private static NewIndexDescriptor indexGetForLabelAndPropertyKey( StoreReadLayer store, int labelId, int propertyKey ) 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 492a9615940d4..3a9eec12ae321 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 @@ -30,7 +30,6 @@ import org.neo4j.helpers.collection.Iterables; import org.neo4j.helpers.collection.Iterators; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.IndexQuery; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.OrderedPropertyValues; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStorageTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStorageTest.java index 463632ef8370f..63d65fce96512 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStorageTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStorageTest.java @@ -44,10 +44,6 @@ import org.neo4j.kernel.api.TokenNameLookup; import org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException; import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; -import org.neo4j.kernel.api.schema.RelationshipPropertyDescriptor; -import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; -import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.SchemaDescriptorPredicates; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptorFactory; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/Commands.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/Commands.java index 9c2870eb70a8f..e46c720f260df 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/Commands.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/Commands.java @@ -26,8 +26,7 @@ import java.util.List; import org.neo4j.kernel.api.index.SchemaIndexProvider; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.impl.store.DynamicNodeLabels; import org.neo4j.kernel.impl.store.PropertyStore; @@ -141,11 +140,11 @@ public static RelationshipGroupCommand createRelationshipGroup( long id, int typ } public static SchemaRuleCommand createIndexRule( SchemaIndexProvider.Descriptor provider, - long id, NodePropertyDescriptor descriptor ) + long id, LabelSchemaDescriptor descriptor ) { SchemaRule rule = IndexRule.indexRule( id, - NewIndexDescriptorFactory.forSchema( SchemaBoundary.map( descriptor ) ), + NewIndexDescriptorFactory.forLabel( descriptor.getLabelId(), descriptor.getPropertyId() ), provider ); DynamicRecord record = new DynamicRecord( id ); record.setInUse( true ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/HighIdTransactionApplierTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/HighIdTransactionApplierTest.java index 88f0eda35d35c..9bf137cf83266 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/HighIdTransactionApplierTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/HighIdTransactionApplierTest.java @@ -22,7 +22,8 @@ import org.junit.Rule; import org.junit.Test; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.PropertyType; import org.neo4j.kernel.impl.store.record.NodeRecord; @@ -74,10 +75,12 @@ public void shouldUpdateHighIdsOnExternalTransaction() throws Exception tracker.visitRelationshipGroupCommand( Commands.createRelationshipGroup( 20, 2 ) ); // Schema rules + final int[] propertyKeyIds = new int[]{1}; tracker.visitSchemaRuleCommand( Commands.createIndexRule( - NO_INDEX_PROVIDER.getProviderDescriptor(), 10, new NodePropertyDescriptor( 0, 1 ) ) ); + NO_INDEX_PROVIDER.getProviderDescriptor(), 10, SchemaDescriptorFactory.forLabel( 0, propertyKeyIds ) ) ); + final int[] propertyKeyIds1 = new int[]{2}; tracker.visitSchemaRuleCommand( Commands.createIndexRule( - NO_INDEX_PROVIDER.getProviderDescriptor(), 20, new NodePropertyDescriptor( 1, 2 ) ) ); + NO_INDEX_PROVIDER.getProviderDescriptor(), 20, SchemaDescriptorFactory.forLabel( 1, propertyKeyIds1 ) ) ); // Properties tracker.visitPropertyCommand( Commands.createProperty( 10, PropertyType.STRING, 0, 6, 7 ) ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/IndexWorkSyncTransactionApplicationStressIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/IndexWorkSyncTransactionApplicationStressIT.java index cfecbb1245d2f..a7f0574cdaf13 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/IndexWorkSyncTransactionApplicationStressIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/IndexWorkSyncTransactionApplicationStressIT.java @@ -34,7 +34,6 @@ import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.schema_new.IndexQuery; import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; -import org.neo4j.kernel.api.schema_new.SchemaBoundary; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.txstate.TransactionState; import org.neo4j.kernel.impl.api.TransactionQueue; @@ -95,7 +94,7 @@ public void shouldApplyIndexUpdatesInWorkSyncedBatches() throws Exception .indexProvider( new InMemoryIndexProvider() ) .build(); storageEngine.apply( tx( asList( createIndexRule( - InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR, 1, SchemaBoundary.map( descriptor ) ) ) ), + InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR, 1, descriptor ) ) ), TransactionApplicationMode.EXTERNAL ); Dependencies dependencies = new Dependencies(); storageEngine.satisfyDependencies( dependencies ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/CineastsDbStructure.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/CineastsDbStructure.java index 68c8b01d88a36..b7c64a635c5bd 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/CineastsDbStructure.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/CineastsDbStructure.java @@ -20,8 +20,9 @@ package org.neo4j.kernel.impl.util.dbstructure; import org.neo4j.helpers.collection.Visitable; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.constraints.UniquenessConstraint; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; // @@ -83,7 +84,8 @@ public void accept( DbStructureVisitor visitor ) visitor.visitIndex( NewIndexDescriptorFactory.forLabel( 3, 5 ), ":Actor(name)", 1.0d, 44689L ); visitor.visitIndex( NewIndexDescriptorFactory.forLabel( 4, 5 ), ":Director(name)", 1.0d, 6010L ); visitor.visitUniqueIndex( NewIndexDescriptorFactory.forLabel( 2, 3 ), ":User(login)", 1.0d, 45L ); - visitor.visitUniqueConstraint( new UniquenessConstraint( new NodePropertyDescriptor( 2, 3 ) ), "CONSTRAINT ON ( user:User ) ASSERT user.login IS UNIQUE" ); + final int[] propertyKeyIds = new int[]{3}; + visitor.visitUniqueConstraint( new UniquenessConstraint( SchemaDescriptorFactory.forLabel( 2, propertyKeyIds ) ), "CONSTRAINT ON ( user:User ) ASSERT user.login IS UNIQUE" ); visitor.visitAllNodesCount( 63042L ); visitor.visitNodeCount( 0, "Movie", 12862L ); visitor.visitNodeCount( 1, "Person", 50179L ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureArgumentFormatterTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureArgumentFormatterTest.java index f19554ec92aaa..c5862f99ebfee 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureArgumentFormatterTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureArgumentFormatterTest.java @@ -23,8 +23,9 @@ import java.io.IOException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.constraints.UniquenessConstraint; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import static org.junit.Assert.assertEquals; @@ -72,8 +73,9 @@ public void shouldFormatIndexDescriptors() @Test public void shouldFormatUniquenessConstraints() { + final int[] propertyKeyIds = new int[]{42}; assertEquals( "new UniquenessConstraint( new NodePropertyDescriptor( 23, 42 ) )", - formatArgument( new UniquenessConstraint( new NodePropertyDescriptor( 23, 42 ) ) ) ); + formatArgument( new UniquenessConstraint( SchemaDescriptorFactory.forLabel( 23, propertyKeyIds ) ) ) ); } private String formatArgument( Object arg ) diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureCollectorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureCollectorTest.java index c03cdbfba1ea2..2b5eaad873eb3 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureCollectorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureCollectorTest.java @@ -22,8 +22,8 @@ import org.junit.Test; import org.neo4j.helpers.collection.Iterators; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.constraints.UniquenessConstraint; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import static java.util.Arrays.asList; @@ -44,7 +44,8 @@ public void collectsDbStructure() collector.visitRelationshipType( 1, "LIVES_IN" ); collector.visitRelationshipType( 2, "FRIEND" ); collector.visitUniqueIndex( NewIndexDescriptorFactory.forLabel( 1, 1 ), ":Person(name)", 1.0d, 1L ); - collector.visitUniqueConstraint( new UniquenessConstraint( new NodePropertyDescriptor( 2, 1 ) ), ":Person(name)" ); + final int[] propertyKeyIds = new int[]{1}; + collector.visitUniqueConstraint( new UniquenessConstraint( SchemaDescriptorFactory.forLabel( 2, propertyKeyIds ) ), ":Person(name)" ); collector.visitIndex( NewIndexDescriptorFactory.forLabel( 2, 2 ), ":City(income)", 0.2d, 1L ); collector.visitAllNodesCount( 50 ); collector.visitNodeCount( 1, "Person", 20 ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureInvocationTracingAcceptanceTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureInvocationTracingAcceptanceTest.java index 878f94368f969..bb24346a10c39 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureInvocationTracingAcceptanceTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureInvocationTracingAcceptanceTest.java @@ -45,8 +45,9 @@ import javax.tools.ToolProvider; import org.neo4j.helpers.collection.Visitable; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.constraints.UniquenessConstraint; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import static org.junit.Assert.assertEquals; @@ -133,7 +134,9 @@ private void exerciseVisitor( Function visitor ) visitor.apply( null ).visitRelationshipType( 1, "REJECTS" ); visitor.apply( null ).visitIndex( NewIndexDescriptorFactory.forLabel( 0, 1 ), ":Person(age)", 0.5d, 1L ); visitor.apply( null ).visitUniqueIndex( NewIndexDescriptorFactory.forLabel( 0, 0 ), ":Person(name)", 0.5d, 1L ); - visitor.apply( null ).visitUniqueConstraint( new UniquenessConstraint( new NodePropertyDescriptor( 1, 0) ), ":Party(name)" ); + final int[] propertyKeyIds = new int[]{0}; + visitor.apply( null ).visitUniqueConstraint( new UniquenessConstraint( + SchemaDescriptorFactory.forLabel( 1, propertyKeyIds ) ), ":Party(name)" ); visitor.apply( null ).visitAllNodesCount( 55 ); visitor.apply( null ).visitNodeCount( 0, "Person", 50 ); visitor.apply( null ).visitNodeCount( 0, "Party", 5 ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/GraphDbStructureGuideTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/GraphDbStructureGuideTest.java index dbd7f534d3f7a..995e9e6fca543 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/GraphDbStructureGuideTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/GraphDbStructureGuideTest.java @@ -32,7 +32,6 @@ import org.neo4j.graphdb.Transaction; import org.neo4j.kernel.api.DataWriteOperations; import org.neo4j.kernel.api.TokenWriteOperations; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.ReadOperations; import org.neo4j.kernel.api.SchemaWriteOperations; import org.neo4j.kernel.api.Statement; diff --git a/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java b/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java index bca5df09459a0..a08ad85ba0fb1 100644 --- a/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java +++ b/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java @@ -121,7 +121,7 @@ public void setUp() labelsIdNameMap = labelsNameIdMap.entrySet() .stream() .collect( Collectors.toMap( Map.Entry::getValue, Map.Entry::getKey ) ); - propertyId = getPropertyKeyId(); + propertyId = getPropertyId(); } @Test @@ -269,7 +269,7 @@ private void waitAndActivateIndexes( Map labelsIds, int property } } - private int getPropertyKeyId() + private int getPropertyId() { try ( Transaction ignored = embeddedDatabase.beginTx() ) { 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 a4ca63f8d1fe4..8b3f0d782b424 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 @@ -30,7 +30,6 @@ import org.neo4j.graphdb.schema.IndexDefinition; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.KernelException; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.IndexingService;