diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/DefaultCapableIndexReference.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/DefaultCapableIndexReference.java
deleted file mode 100644
index 4508fa7521de6..0000000000000
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/DefaultCapableIndexReference.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2002-2018 "Neo4j,"
- * Neo4j Sweden AB [http://neo4j.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.impl.api.store;
-
-import java.util.Arrays;
-
-import org.neo4j.internal.kernel.api.CapableIndexReference;
-import org.neo4j.internal.kernel.api.IndexCapability;
-import org.neo4j.internal.kernel.api.IndexOrder;
-import org.neo4j.internal.kernel.api.IndexReference;
-import org.neo4j.internal.kernel.api.IndexValueCapability;
-import org.neo4j.internal.kernel.api.schema.SchemaDescriptor;
-import org.neo4j.kernel.api.index.IndexProvider;
-import org.neo4j.kernel.api.schema.index.IndexDescriptor;
-import org.neo4j.values.storable.ValueCategory;
-
-public class DefaultCapableIndexReference implements CapableIndexReference
-{
- private final int label;
- private final int[] properties;
- private final boolean unique;
- private final IndexProvider.Descriptor providerDescriptor;
- private final IndexCapability capability;
-
- public DefaultCapableIndexReference( boolean unique, IndexCapability indexCapability,
- IndexProvider.Descriptor providerDescriptor, int label, int... properties )
- {
- this.unique = unique;
- this.capability = indexCapability;
- this.label = label;
- this.providerDescriptor = providerDescriptor;
- this.properties = properties;
- }
-
- @Override
- public boolean isUnique()
- {
- return unique;
- }
-
- @Override
- public int label()
- {
- return label;
- }
-
- @Override
- public int[] properties()
- {
- return properties;
- }
-
- @Override
- public String providerKey()
- {
- return providerDescriptor.getKey();
- }
-
- @Override
- public String providerVersion()
- {
- return providerDescriptor.getVersion();
- }
-
- @Override
- public IndexOrder[] orderCapability( ValueCategory... valueCategories )
- {
- return capability.orderCapability( valueCategories );
- }
-
- @Override
- public IndexValueCapability valueCapability( ValueCategory... valueCategories )
- {
- return capability.valueCapability( valueCategories );
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o )
- {
- return true;
- }
- if ( !(o instanceof IndexReference) )
- {
- return false;
- }
-
- IndexReference that = (IndexReference) o;
-
- return label == that.label() && unique == that.isUnique() && Arrays.equals( properties, that.properties() );
- }
-
- @Override
- public String toString()
- {
- return String.format( "Index(%d:%s)", label, Arrays.toString( properties ) );
- }
-
- @Override
- public int hashCode()
- {
- int result = label;
- result = 31 * result + Arrays.hashCode( properties );
- result = 31 * result + (unique ? 1 : 0);
- result = 31 * result + (providerDescriptor != null ? providerDescriptor.hashCode() : 0);
- return result;
- }
-
- public static CapableIndexReference fromDescriptor( IndexDescriptor descriptor )
- {
- boolean unique = descriptor.type() == IndexDescriptor.Type.UNIQUE;
- final SchemaDescriptor schema = descriptor.schema();
- return new DefaultCapableIndexReference( unique, IndexCapability.NO_CAPABILITY, IndexProvider.UNDECIDED,
- schema.keyId(), schema.getPropertyIds() );
- }
-}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/CompositeIndexingIT.java b/community/kernel/src/test/java/org/neo4j/kernel/api/CompositeIndexingIT.java
index b7f9025dcd7c1..e40dbb0e4d204 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/api/CompositeIndexingIT.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/api/CompositeIndexingIT.java
@@ -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
@@ -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 );
@@ -118,7 +117,7 @@ public void clean() throws Exception
}
else
{
- ktx.schemaWrite().indexDrop( fromDescriptor( index ) );
+ ktx.schemaWrite().indexDrop( index );
}
tx.success();
}
@@ -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;
}
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 3b3cdab4fed8c..0a8de27722cd2 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
@@ -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;
@@ -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 );
}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java
index cc6304ce4328f..38d0ef0b3159c 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java
@@ -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;
@@ -85,8 +85,8 @@
public class BuiltInProceduresTest
{
- private final List indexes = new LinkedList<>();
- private final List uniqueIndexes = new LinkedList<>();
+ private final List indexes = new LinkedList<>();
+ private final List uniqueIndexes = new LinkedList<>();
private final List constraints = new LinkedList<>();
private final Map labels = new HashMap<>();
private final Map propKeys = new HashMap<>();
@@ -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 );
}
@@ -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 ) );
}
@@ -506,20 +508,18 @@ public void setup() throws Exception
(Answer) 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( );
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 fc2e9b26ea9b0..f068e7502066c 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
@@ -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
{
@@ -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)" );
@@ -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)" );
@@ -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)" );
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 de57180b26887..87376e0115f67 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
@@ -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;
@@ -46,6 +45,7 @@
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;
@@ -53,7 +53,6 @@
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;
@@ -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 );