/** * Sorts indexes by type, returning first GENERAL indexes, followed by UNIQUE. Implementation is not suitable in * hot path. * * @param indexes Indexes to sort * @return sorted indexes */ static Iterator<IndexReference> sortByType( Iterator<IndexReference> indexes ) { List<IndexReference> materialized = Iterators.asList( indexes ); return Iterators.concat( Iterators.filter( i -> !i.isUnique(), materialized.iterator() ), Iterators.filter( IndexReference::isUnique, materialized.iterator() ) ); }
if ( index.isUnique() )
if ( !index.isUnique() )
boolean constraintIndex = index.isUnique(); String[] propertyNames = PropertyNameUtils.getPropertyKeys( tokenRead, index.properties() ); switch ( schema.entityType() )
private IndexReference getOrCreateUniquenessConstraintIndex( SchemaRead schemaRead, TokenRead tokenRead, SchemaDescriptor schema, String provider ) throws SchemaKernelException, IndexNotFoundKernelException { IndexReference descriptor = schemaRead.index( schema ); if ( descriptor != IndexReference.NO_INDEX ) { if ( descriptor.isUnique() ) { // OK so we found a matching constraint index. We check whether or not it has an owner // because this may have been a left-over constraint index from a previously failed // constraint creation, due to crash or similar, hence the missing owner. if ( schemaRead.indexGetOwningUniquenessConstraintId( descriptor ) == null ) { return descriptor; } throw new AlreadyConstrainedException( ConstraintDescriptorFactory.uniqueForSchema( schema ), OperationContext.CONSTRAINT_CREATION, new SilentTokenNameLookup( tokenRead ) ); } // There's already an index for this schema descriptor, which isn't of the type we're after. throw new AlreadyIndexedException( schema, CONSTRAINT_CREATION ); } IndexDescriptor indexDescriptor = createConstraintIndex( schema, provider ); IndexProxy indexProxy = indexingService.getIndexProxy( indexDescriptor.schema() ); return indexProxy.getDescriptor(); }
properties, schemaRead.indexGetState(indexReference).toString(), !indexReference.isUnique() ? "INDEX" : "UNIQUENESS", schemaRead.indexGetState(indexReference).equals(InternalIndexState.FAILED) ? schemaRead.indexGetFailure(indexReference) : "NO FAILURE", schemaRead.indexGetPopulationProgress(indexReference).getCompleted() / schemaRead.indexGetPopulationProgress(indexReference).getTotal() * 100, properties, "NOT_FOUND", !indexReference.isUnique() ? "INDEX" : "UNIQUENESS", "NOT_FOUND", 0,0,0,
/** * Sorts indexes by type, returning first GENERAL indexes, followed by UNIQUE. Implementation is not suitable in * hot path. * * @param indexes Indexes to sort * @return sorted indexes */ static Iterator<IndexReference> sortByType( Iterator<IndexReference> indexes ) { List<IndexReference> materialized = Iterators.asList( indexes ); return Iterators.concat( Iterators.filter( i -> !i.isUnique(), materialized.iterator() ), Iterators.filter( IndexReference::isUnique, materialized.iterator() ) ); }
if ( index.isUnique() )
boolean constraintIndex = index.isUnique(); String[] propertyNames = PropertyNameUtils.getPropertyKeys( tokenRead, index.properties() ); switch ( schema.entityType() )
if ( !index.isUnique() )
private IndexReference getOrCreateUniquenessConstraintIndex( SchemaRead schemaRead, TokenRead tokenRead, SchemaDescriptor schema, String provider ) throws SchemaKernelException, IndexNotFoundKernelException { IndexReference descriptor = schemaRead.index( schema ); if ( descriptor != IndexReference.NO_INDEX ) { if ( descriptor.isUnique() ) { // OK so we found a matching constraint index. We check whether or not it has an owner // because this may have been a left-over constraint index from a previously failed // constraint creation, due to crash or similar, hence the missing owner. if ( schemaRead.indexGetOwningUniquenessConstraintId( descriptor ) == null ) { return descriptor; } throw new AlreadyConstrainedException( ConstraintDescriptorFactory.uniqueForSchema( schema ), OperationContext.CONSTRAINT_CREATION, new SilentTokenNameLookup( tokenRead ) ); } // There's already an index for this schema descriptor, which isn't of the type we're after. throw new AlreadyIndexedException( schema, CONSTRAINT_CREATION ); } IndexDescriptor indexDescriptor = createConstraintIndex( schema, provider ); IndexProxy indexProxy = indexingService.getIndexProxy( indexDescriptor.schema() ); return indexProxy.getDescriptor(); }