Search in sources :

Example 6 with IndexDefinitionImpl

use of org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl in project neo4j by neo4j.

the class FullCheckTokenIndexIT method verifyIndexExistAndOnline.

private void verifyIndexExistAndOnline(GraphDatabaseAPI db, IndexDescriptor index) {
    awaitIndexesOnline(db);
    try (Transaction tx = db.beginTx()) {
        var indexes = StreamSupport.stream(tx.schema().getIndexes().spliterator(), false).map(IndexDefinitionImpl.class::cast).map(IndexDefinitionImpl::getIndexReference).collect(Collectors.toList());
        assertThat(indexes).hasSize(1);
        assertThat(indexes.get(0)).isEqualTo(index);
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) IndexDefinitionImpl(org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl)

Example 7 with IndexDefinitionImpl

use of org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl in project neo4j by neo4j.

the class SchemaWithPECAcceptanceTest method createUniquenessConstraint.

private ConstraintDefinition createUniquenessConstraint(Label label, String propertyKey) {
    SchemaHelper.createUniquenessConstraint(db, label, propertyKey);
    SchemaHelper.awaitIndexes(db);
    InternalSchemaActions actions = mock(InternalSchemaActions.class);
    IndexDefinition index = new IndexDefinitionImpl(actions, label, new String[] { propertyKey }, true);
    return new UniquenessConstraintDefinition(actions, index);
}
Also used : InternalSchemaActions(org.neo4j.kernel.impl.coreapi.schema.InternalSchemaActions) IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) UniquenessConstraintDefinition(org.neo4j.kernel.impl.coreapi.schema.UniquenessConstraintDefinition) IndexDefinitionImpl(org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl)

Example 8 with IndexDefinitionImpl

use of org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl in project neo4j by neo4j.

the class IndexingServiceIntegrationTest method testManualIndexPopulation.

@ParameterizedTest
@MethodSource("parameters")
void testManualIndexPopulation(GraphDatabaseSettings.SchemaIndex schemaIndex) throws InterruptedException, IndexNotFoundKernelException {
    setUp(schemaIndex);
    IndexDescriptor index;
    try (Transaction tx = database.beginTx()) {
        IndexDefinitionImpl indexDefinition = (IndexDefinitionImpl) tx.schema().indexFor(Label.label(FOOD_LABEL)).on(PROPERTY_NAME).create();
        index = indexDefinition.getIndexReference();
        tx.commit();
    }
    IndexingService indexingService = getIndexingService(database);
    IndexProxy indexProxy = indexingService.getIndexProxy(index);
    waitIndexOnline(indexProxy);
    assertEquals(InternalIndexState.ONLINE, indexProxy.getState());
    PopulationProgress progress = indexProxy.getIndexPopulationProgress();
    assertEquals(progress.getCompleted(), progress.getTotal());
}
Also used : PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexDefinitionImpl(org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 9 with IndexDefinitionImpl

use of org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl in project neo4j by neo4j.

the class SchemaLoggingIT method createIndex.

private static long createIndex(GraphDatabaseAPI db, String labelName, String property) {
    long indexId;
    try (Transaction tx = db.beginTx()) {
        IndexDefinition indexDefinition = tx.schema().indexFor(label(labelName)).on(property).create();
        indexId = ((IndexDefinitionImpl) indexDefinition).getIndexReference().getId();
        tx.commit();
    }
    try (Transaction tx = db.beginTx()) {
        tx.schema().awaitIndexesOnline(2, TimeUnit.MINUTES);
        tx.commit();
    }
    return indexId;
}
Also used : Transaction(org.neo4j.graphdb.Transaction) IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) IndexDefinitionImpl(org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl)

Example 10 with IndexDefinitionImpl

use of org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl in project neo4j by neo4j.

the class RecoveryWithTokenIndexesIT method verifyIndexExistAndOnline.

private void verifyIndexExistAndOnline(GraphDatabaseService db, IndexDescriptor index) {
    awaitIndexesOnline(db);
    try (Transaction tx = db.beginTx()) {
        var indexes = StreamSupport.stream(tx.schema().getIndexes().spliterator(), false).map(IndexDefinitionImpl.class::cast).map(IndexDefinitionImpl::getIndexReference).collect(Collectors.toList());
        assertThat(indexes).hasSize(1);
        assertThat(indexes.get(0)).isEqualTo(index);
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) IndexDefinitionImpl(org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl)

Aggregations

IndexDefinitionImpl (org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl)10 Transaction (org.neo4j.graphdb.Transaction)8 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)4 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)4 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)3 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)2 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)2 StreamSupport.stream (java.util.stream.StreamSupport.stream)1 RandomStringUtils.randomAscii (org.apache.commons.lang3.RandomStringUtils.randomAscii)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 Test (org.junit.jupiter.api.Test)1 EntityType (org.neo4j.common.EntityType)1 Config (org.neo4j.configuration.Config)1 Label (org.neo4j.graphdb.Label)1 IndexCreator (org.neo4j.graphdb.schema.IndexCreator)1 PopulationProgress (org.neo4j.internal.kernel.api.PopulationProgress)1