Search in sources :

Example 1 with IndexDefinitionImpl

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

the class IndexingServiceIntegrationTest method dropIndexDirectlyOnIndexingServiceRaceWithCheckpoint.

@ParameterizedTest
@MethodSource("parameters")
void dropIndexDirectlyOnIndexingServiceRaceWithCheckpoint(GraphDatabaseSettings.SchemaIndex schemaIndex) throws Throwable {
    setUp(schemaIndex);
    IndexingService indexingService = getIndexingService(database);
    CheckPointer checkPointer = getCheckPointer(database);
    IndexDescriptor indexDescriptor;
    try (Transaction tx = database.beginTx()) {
        IndexDefinitionImpl indexDefinition = (IndexDefinitionImpl) tx.schema().indexFor(Label.label("label")).on("prop").create();
        indexDescriptor = indexDefinition.getIndexReference();
        tx.commit();
    }
    try (Transaction tx = database.beginTx()) {
        tx.schema().awaitIndexesOnline(1, TimeUnit.HOURS);
        tx.commit();
    }
    Race race = new Race();
    race.addContestant(Race.throwing(() -> checkPointer.forceCheckPoint(new SimpleTriggerInfo("Test force"))));
    race.addContestant(Race.throwing(() -> indexingService.dropIndex(indexDescriptor)));
    race.go();
}
Also used : SimpleTriggerInfo(org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Race(org.neo4j.test.Race) CheckPointer(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer) 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 2 with IndexDefinitionImpl

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

the class DefaultSchemaIndexConfigTest method createIndex.

private void createIndex(GraphDatabaseService db) {
    try (Transaction tx = db.beginTx()) {
        IndexDefinitionImpl indexDefinition = (IndexDefinitionImpl) tx.schema().indexFor(LABEL_ONE).on(KEY).create();
        index = indexDefinition.getIndexReference();
        tx.commit();
    }
    try (Transaction tx = db.beginTx()) {
        tx.schema().awaitIndexesOnline(2, TimeUnit.MINUTES);
        tx.commit();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) IndexDefinitionImpl(org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl)

Example 3 with IndexDefinitionImpl

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

the class IndexConfigMigrationIT method getIndexConfig.

@SuppressWarnings("SameParameterValue")
private static Map<String, Value> getIndexConfig(GraphDatabaseAPI db, Transaction tx, Label label) throws IndexNotFoundKernelException {
    IndexDefinitionImpl indexDefinition = (IndexDefinitionImpl) single(tx.schema().getIndexes(label));
    IndexDescriptor index = indexDefinition.getIndexReference();
    IndexingService indexingService = getIndexingService(db);
    IndexProxy indexProxy = indexingService.getIndexProxy(index);
    return indexProxy.indexConfig();
}
Also used : IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexDefinitionImpl(org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl)

Example 4 with IndexDefinitionImpl

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

the class CompositeStringLengthValidationIT method createIndex.

private IndexDescriptor createIndex(String... keys) {
    IndexDefinition indexDefinition;
    try (Transaction tx = db.beginTx()) {
        IndexCreator indexCreator = tx.schema().indexFor(LABEL);
        for (String key : keys) {
            indexCreator = indexCreator.on(key);
        }
        indexDefinition = indexCreator.create();
        tx.commit();
    }
    try (Transaction tx = db.beginTx()) {
        tx.schema().awaitIndexesOnline(30, SECONDS);
        tx.commit();
    }
    return ((IndexDefinitionImpl) indexDefinition).getIndexReference();
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexCreator(org.neo4j.graphdb.schema.IndexCreator) IndexDefinitionImpl(org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl)

Example 5 with IndexDefinitionImpl

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

the class LabelScanNodeViewTracingIT method findTokenIndex.

private IndexDescriptor findTokenIndex() {
    try (Transaction tx = database.beginTx()) {
        var nodeIndex = stream(tx.schema().getIndexes().spliterator(), false).map(indexDef -> ((IndexDefinitionImpl) indexDef).getIndexReference()).filter(index -> index.isTokenIndex() && index.schema().entityType() == EntityType.NODE).findFirst();
        assertTrue(nodeIndex.isPresent());
        return nodeIndex.get();
    }
}
Also used : IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) Label(org.neo4j.graphdb.Label) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Config(org.neo4j.configuration.Config) StoreScan(org.neo4j.kernel.impl.api.index.StoreScan) RecordStorageEngine(org.neo4j.internal.recordstorage.RecordStorageEngine) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) LockService(org.neo4j.lock.LockService) DbmsExtension(org.neo4j.test.extension.DbmsExtension) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Test(org.junit.jupiter.api.Test) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) Inject(org.neo4j.test.extension.Inject) StreamSupport.stream(java.util.stream.StreamSupport.stream) EntityType(org.neo4j.common.EntityType) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexDefinitionImpl(org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl) Transaction(org.neo4j.graphdb.Transaction) JobScheduler(org.neo4j.scheduler.JobScheduler) RandomStringUtils.randomAscii(org.apache.commons.lang3.RandomStringUtils.randomAscii) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction)

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