Skip to content

Commit

Permalink
Remove DefaultIndexReference
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd authored and ragadeeshu committed May 21, 2018
1 parent 15b1b77 commit b7d1e83
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 123 deletions.

This file was deleted.

Expand Up @@ -57,6 +57,7 @@
import org.neo4j.kernel.api.schema.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema.SchemaDescriptorFactory;
import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory;
import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor;
import org.neo4j.kernel.api.txstate.TransactionCountingStateVisitor; import org.neo4j.kernel.api.txstate.TransactionCountingStateVisitor;
import org.neo4j.kernel.api.txstate.TransactionState; import org.neo4j.kernel.api.txstate.TransactionState;
import org.neo4j.kernel.impl.api.ClockContext; import org.neo4j.kernel.impl.api.ClockContext;
Expand Down Expand Up @@ -404,7 +405,7 @@ public InternalIndexState indexGetState( IndexReference index ) throws IndexNotF
assertValidIndex( index ); assertValidIndex( index );
sharedOptimisticLock( ResourceTypes.LABEL, index.label() ); sharedOptimisticLock( ResourceTypes.LABEL, index.label() );
ktx.assertOpen(); ktx.assertOpen();
return indexGetState( indexDescriptor( index ) ); return indexGetState( (IndexDescriptor) index );
} }


@Override @Override
Expand All @@ -413,7 +414,7 @@ public PopulationProgress indexGetPopulationProgress( IndexReference index )
{ {
sharedOptimisticLock( ResourceTypes.LABEL, index.label() ); sharedOptimisticLock( ResourceTypes.LABEL, index.label() );
ktx.assertOpen(); ktx.assertOpen();
IndexDescriptor descriptor = indexDescriptor( index ); IndexDescriptor descriptor = (IndexDescriptor) index;


if ( ktx.hasTxStateWithChanges() ) if ( ktx.hasTxStateWithChanges() )
{ {
Expand All @@ -432,26 +433,28 @@ public Long indexGetOwningUniquenessConstraintId( IndexReference index )
{ {
sharedOptimisticLock( ResourceTypes.LABEL, index.label() ); sharedOptimisticLock( ResourceTypes.LABEL, index.label() );
ktx.assertOpen(); ktx.assertOpen();
return indexGetOwningUniquenessConstraintId( indexDescriptor( index ) ); if ( index instanceof StoreIndexDescriptor )
{
return ((StoreIndexDescriptor) index).getOwningConstraint();
}
else
{
return null;
}
} }


@Override @Override
public long indexGetCommittedId( IndexReference index ) throws SchemaRuleNotFoundException public long indexGetCommittedId( IndexReference index ) throws SchemaRuleNotFoundException
{ {
sharedOptimisticLock( ResourceTypes.LABEL, index.label() ); sharedOptimisticLock( ResourceTypes.LABEL, index.label() );
ktx.assertOpen(); ktx.assertOpen();
return storageReader.indexGetCommittedId( indexDescriptor( index ) ); if ( index instanceof StoreIndexDescriptor )
}

IndexDescriptor indexDescriptor( IndexReference index )
{
if ( index.isUnique() )
{ {
return IndexDescriptorFactory.uniqueForLabel( index.label(), index.properties() ); return ((StoreIndexDescriptor) index).getId();
} }
else else
{ {
return IndexDescriptorFactory.forLabel( index.label(), index.properties() ); return -1L;
} }
} }


Expand Down
Expand Up @@ -899,35 +899,35 @@ public IndexReference indexCreate( SchemaDescriptor descriptor,
} }


@Override @Override
public void indexDrop( IndexReference index ) throws SchemaKernelException public void indexDrop( IndexReference indexReference ) throws SchemaKernelException
{ {
IndexDescriptor index = (IndexDescriptor) indexReference;
assertValidIndex( index ); assertValidIndex( index );


acquireExclusiveLabelLock( index.label() ); acquireExclusiveLabelLock( indexReference.label() );
ktx.assertOpen(); ktx.assertOpen();
org.neo4j.kernel.api.schema.LabelSchemaDescriptor descriptor = labelDescriptor( index );
try try
{ {
IndexDescriptor existingIndex = allStoreHolder.indexGetForSchema( descriptor ); IndexDescriptor existingIndex = allStoreHolder.indexGetForSchema( index.schema() );


if ( existingIndex == null ) if ( existingIndex == null )
{ {
throw new NoSuchIndexException( descriptor ); throw new NoSuchIndexException( index.schema() );
} }


if ( existingIndex.type() == UNIQUE ) if ( existingIndex.type() == UNIQUE )
{ {
if ( allStoreHolder.indexGetOwningUniquenessConstraintId( existingIndex ) != null ) if ( allStoreHolder.indexGetOwningUniquenessConstraintId( existingIndex ) != null )
{ {
throw new IndexBelongsToConstraintException( descriptor ); throw new IndexBelongsToConstraintException( index.schema() );
} }
} }
} }
catch ( IndexBelongsToConstraintException | NoSuchIndexException e ) catch ( IndexBelongsToConstraintException | NoSuchIndexException e )
{ {
throw new DropIndexFailureException( descriptor, e ); throw new DropIndexFailureException( index.schema(), e );
} }
ktx.txState().indexDoDrop( allStoreHolder.indexDescriptor( index ) ); ktx.txState().indexDoDrop( index );
} }


@Override @Override
Expand Down Expand Up @@ -1245,11 +1245,11 @@ private void indexBackedConstraintCreate( IndexBackedConstraintDescriptor constr
} }
} }


private void assertValidIndex( IndexReference index ) throws NoSuchIndexException private void assertValidIndex( IndexDescriptor index ) throws NoSuchIndexException
{ {
if ( index == CapableIndexReference.NO_INDEX ) if ( index == CapableIndexReference.NO_INDEX )
{ {
throw new NoSuchIndexException( SchemaDescriptorFactory.forLabel( index.label(), index.properties() ) ); throw new NoSuchIndexException( index.schema() );
} }
} }
} }

0 comments on commit b7d1e83

Please sign in to comment.