Skip to content

Commit

Permalink
Remove DefaultCapableIndexReference
Browse files Browse the repository at this point in the history
  • Loading branch information
ragadeeshu committed May 21, 2018
1 parent d5d06c1 commit f724fb4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 160 deletions.

This file was deleted.

Expand Up @@ -57,7 +57,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.neo4j.kernel.api.schema.index.IndexDescriptor.Type.UNIQUE;
import static org.neo4j.kernel.impl.api.store.DefaultCapableIndexReference.fromDescriptor;

@RunWith( Parameterized.class )
public class CompositeIndexingIT
Expand Down Expand Up @@ -97,7 +96,7 @@ public void setup() throws Exception
try ( Transaction ignore = graphDatabaseAPI.beginTx() )
{
KernelTransaction ktx = ktx();
while ( ktx.schemaRead().indexGetState( fromDescriptor( index ) ) !=
while ( ktx.schemaRead().indexGetState( index ) !=
InternalIndexState.ONLINE )
{
Thread.sleep( 10 );
Expand All @@ -118,7 +117,7 @@ public void clean() throws Exception
}
else
{
ktx.schemaWrite().indexDrop( fromDescriptor( index ) );
ktx.schemaWrite().indexDrop( index );
}
tx.success();
}
Expand Down Expand Up @@ -338,7 +337,7 @@ private long createNode()
private NodeValueIndexCursor seek( KernelTransaction transaction ) throws KernelException
{
NodeValueIndexCursor cursor = transaction.cursors().allocateNodeValueIndexCursor();
transaction.dataRead().nodeIndexSeek( fromDescriptor( index ), cursor, IndexOrder.NONE, exactQuery() );
transaction.dataRead().nodeIndexSeek( index, cursor, IndexOrder.NONE, exactQuery() );
return cursor;
}

Expand Down
Expand Up @@ -38,7 +38,6 @@
import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException;
import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException;
import org.neo4j.kernel.api.schema.SchemaDescriptorFactory;
import org.neo4j.kernel.impl.api.store.DefaultCapableIndexReference;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
Expand Down Expand Up @@ -78,7 +77,7 @@ public void setup()
procedure = new IndexProcedures( transaction, null );
descriptor = SchemaDescriptorFactory.forLabel( 123, 456 );
anyDescriptor = SchemaDescriptorFactory.forLabel( 0, 0 );
anyIndex = DefaultCapableIndexReference.fromDescriptor( forSchema( anyDescriptor ) );
anyIndex = forSchema( anyDescriptor );
when( transaction.tokenRead() ).thenReturn( tokenRead );
when( transaction.schemaRead() ).thenReturn( schemaRead );
}
Expand Down
Expand Up @@ -57,8 +57,8 @@
import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptor;
import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptorFactory;
import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory;
import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor;
import org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProviderFactory;
import org.neo4j.kernel.impl.api.store.DefaultCapableIndexReference;
import org.neo4j.kernel.impl.factory.Edition;
import org.neo4j.kernel.impl.proc.Procedures;
import org.neo4j.kernel.internal.GraphDatabaseAPI;
Expand All @@ -85,8 +85,8 @@

public class BuiltInProceduresTest
{
private final List<IndexReference> indexes = new LinkedList<>();
private final List<IndexReference> uniqueIndexes = new LinkedList<>();
private final List<CapableIndexReference> indexes = new LinkedList<>();
private final List<CapableIndexReference> uniqueIndexes = new LinkedList<>();
private final List<ConstraintDescriptor> constraints = new LinkedList<>();
private final Map<Integer,String> labels = new HashMap<>();
private final Map<Integer,String> propKeys = new HashMap<>();
Expand Down Expand Up @@ -415,7 +415,8 @@ private void givenIndex( String label, String propKey )
int labelId = token( label, labels );
int propId = token( propKey, propKeys );

IndexReference index = IndexDescriptorFactory.forLabel( labelId, propId );
CapableIndexReference index =
StoreIndexDescriptor.indexRule( 0, IndexDescriptorFactory.forLabel( labelId, propId ), InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR );
indexes.add( index );
}

Expand All @@ -424,7 +425,8 @@ private void givenUniqueConstraint( String label, String propKey )
int labelId = token( label, labels );
int propId = token( propKey, propKeys );

IndexReference index = IndexDescriptorFactory.uniqueForLabel( labelId, propId );
CapableIndexReference index =
StoreIndexDescriptor.indexRule( 0, IndexDescriptorFactory.uniqueForLabel( labelId, propId ), InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR );
uniqueIndexes.add( index );
constraints.add( ConstraintDescriptorFactory.uniqueForLabel( labelId, propId ) );
}
Expand Down Expand Up @@ -506,20 +508,18 @@ public void setup() throws Exception
(Answer<CapableIndexReference>) invocationOnMock -> {
int label = invocationOnMock.getArgument( 0 );
int prop = invocationOnMock.getArgument( 1 );
for ( IndexReference index : indexes )
for ( CapableIndexReference index : indexes )
{
if ( index.label() == label && prop == index.properties()[0] )
{
return new DefaultCapableIndexReference( index.isUnique(), null,
InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR, label, prop );
return index;
}
}
for ( IndexReference index : uniqueIndexes )
for ( CapableIndexReference index : uniqueIndexes )
{
if ( index.label() == label && prop == index.properties()[0] )
{
return new DefaultCapableIndexReference( index.isUnique(), null,
InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR, label, prop );
return index;
}
}
throw new AssertionError( );
Expand Down
Expand Up @@ -44,7 +44,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.neo4j.kernel.impl.api.store.DefaultCapableIndexReference.fromDescriptor;

public class ResampleIndexProcedureTest
{
Expand Down Expand Up @@ -108,7 +107,7 @@ public void shouldLookUpTheIndexByLabelIdAndPropertyKeyId()
IndexDescriptor index = IndexDescriptorFactory.forLabel( 0, 0 );
when( tokenRead.nodeLabel( anyString() ) ).thenReturn( 123 );
when( tokenRead.propertyKey( anyString() ) ).thenReturn( 456 );
when( schemaRead.index( anyInt(), any() ) ).thenReturn( fromDescriptor( index ) );
when( schemaRead.index( anyInt(), any() ) ).thenReturn( index );

procedure.resampleIndex( ":Person(name)" );

Expand All @@ -123,7 +122,7 @@ public void shouldLookUpTheCompositeIndexByLabelIdAndPropertyKeyId()
when( tokenRead.nodeLabel( anyString() ) ).thenReturn( 123 );
when( tokenRead.propertyKey( "name" ) ).thenReturn( 0 );
when( tokenRead.propertyKey( "lastName" ) ).thenReturn( 1 );
when( schemaRead.index( 123, 0, 1 ) ).thenReturn( fromDescriptor( index ) );
when( schemaRead.index( 123, 0, 1 ) ).thenReturn( index );

procedure.resampleIndex( ":Person(name, lastName)" );

Expand Down Expand Up @@ -155,7 +154,7 @@ public void shouldTriggerResampling()
throws SchemaRuleNotFoundException, ProcedureException, IndexNotFoundKernelException
{
IndexDescriptor index = IndexDescriptorFactory.forLabel( 123, 456 );
when( schemaRead.index( anyInt(), any() ) ).thenReturn( fromDescriptor( index ) );
when( schemaRead.index( anyInt(), any() ) ).thenReturn( index );

procedure.resampleIndex( ":Person(name)" );

Expand Down
Expand Up @@ -25,7 +25,6 @@
import java.util.List;

import org.neo4j.internal.kernel.api.CapableIndexReference;
import org.neo4j.internal.kernel.api.IndexCapability;
import org.neo4j.internal.kernel.api.Kernel;
import org.neo4j.internal.kernel.api.Modes;
import org.neo4j.internal.kernel.api.SchemaRead;
Expand All @@ -46,14 +45,14 @@
import org.neo4j.kernel.api.schema.SchemaDescriptorFactory;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory;
import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor;
import org.neo4j.kernel.api.txstate.TransactionState;
import org.neo4j.kernel.impl.api.KernelTransactionImplementation;
import org.neo4j.kernel.impl.api.StatementOperationParts;
import org.neo4j.kernel.impl.api.TransactionHeaderInformation;
import org.neo4j.kernel.impl.api.index.IndexProxy;
import org.neo4j.kernel.impl.api.index.IndexingService;
import org.neo4j.kernel.impl.api.state.ConstraintIndexCreator;
import org.neo4j.kernel.impl.api.store.DefaultCapableIndexReference;
import org.neo4j.kernel.impl.locking.ResourceTypes;
import org.neo4j.kernel.impl.locking.SimpleStatementLocks;
import org.neo4j.kernel.impl.transaction.TransactionHeaderInformationFactory;
Expand Down Expand Up @@ -82,9 +81,8 @@ public class ConstraintIndexCreatorTest

private final LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel( LABEL_ID, PROPERTY_KEY_ID );
private final IndexDescriptor index = IndexDescriptorFactory.uniqueForLabel( 123, 456 );
private final CapableIndexReference indexReference =
new DefaultCapableIndexReference( true, IndexCapability.NO_CAPABILITY,
new IndexProvider.Descriptor( "foo", "1.872" ), LABEL_ID, PROPERTY_KEY_ID );
private final CapableIndexReference indexReference = StoreIndexDescriptor.indexRule( 0, IndexDescriptorFactory.uniqueForLabel( LABEL_ID, PROPERTY_KEY_ID ),
new IndexProvider.Descriptor( "foo", "1.872" ) );
private final SchemaRead schemaRead = schemaRead();
private final TokenRead tokenRead = mock( TokenRead.class );

Expand Down

0 comments on commit f724fb4

Please sign in to comment.