Search in sources :

Example 71 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class MultiIndexPopulationConcurrentUpdatesIT method checkIndexIsOnline.

private void checkIndexIsOnline(int labelId) throws IndexNotFoundKernelException {
    LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyId);
    IndexDescriptor index = single(schemaCache.indexesForSchema(schema));
    IndexProxy indexProxy = indexService.getIndexProxy(index);
    assertSame(InternalIndexState.ONLINE, indexProxy.getState());
}
Also used : LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 72 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class MultiIndexPopulationConcurrentUpdatesIT method indexDroppedDuringPopulationDoesNotExist.

@ParameterizedTest
@MethodSource("parameters")
void indexDroppedDuringPopulationDoesNotExist(GraphDatabaseSettings.SchemaIndex schemaIndex) throws Throwable {
    Integer labelToDropId = labelsNameIdMap.get(COLOR_LABEL);
    launchCustomIndexPopulation(schemaIndex, labelsNameIdMap, propertyId, new IndexDropAction(labelToDropId));
    labelsNameIdMap.remove(COLOR_LABEL);
    waitAndActivateIndexes(labelsNameIdMap, propertyId);
    assertThrows(IndexNotFoundKernelException.class, () -> {
        Iterator<IndexDescriptor> iterator = schemaCache.indexesForSchema(SchemaDescriptor.forLabel(labelToDropId, propertyId));
        while (iterator.hasNext()) {
            IndexDescriptor index = iterator.next();
            indexService.getIndexProxy(index);
        }
    });
}
Also used : IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 73 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class MultiIndexPopulationConcurrentUpdatesIT method createIndexRules.

private IndexDescriptor[] createIndexRules(GraphDatabaseSettings.SchemaIndex schemaIndex, Map<String, Integer> labelNameIdMap, int propertyId) {
    final IndexProviderMap indexProviderMap = getIndexProviderMap();
    IndexProvider indexProvider = indexProviderMap.lookup(schemaIndex.providerName());
    IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
    List<IndexDescriptor> list = new ArrayList<>();
    for (Integer labelId : labelNameIdMap.values()) {
        final LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyId);
        IndexDescriptor index = IndexPrototype.forSchema(schema, providerDescriptor).withName("index_" + labelId).materialise(labelId);
        index = indexProvider.completeConfiguration(index);
        list.add(index);
    }
    return list.toArray(new IndexDescriptor[0]);
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) ArrayList(java.util.ArrayList) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexProviderMap(org.neo4j.kernel.impl.api.index.IndexProviderMap)

Example 74 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class MultiIndexPopulationConcurrentUpdatesIT method waitIndexOnline.

private void waitIndexOnline(IndexingService indexService, int propertyId, int labelId) throws IndexNotFoundKernelException, IndexPopulationFailedKernelException, InterruptedException, IndexActivationFailedKernelException {
    LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyId);
    IndexDescriptor index = single(schemaCache.indexesForSchema(schema));
    IndexProxy indexProxy = indexService.getIndexProxy(index);
    indexProxy.awaitStoreScanCompleted(0, TimeUnit.MILLISECONDS);
    while (indexProxy.getState() != InternalIndexState.ONLINE) {
        Thread.sleep(10);
    }
    indexProxy.activate();
}
Also used : LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 75 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class NodeScanIT method trackPageCacheAccessOnNodeLabelScan.

@Test
void trackPageCacheAccessOnNodeLabelScan() throws KernelException {
    var testLabel = Label.label("testLabel");
    try (KernelTransaction tx = kernel.beginTransaction(IMPLICIT, read())) {
        var cursorContext = tx.cursorContext();
        assertThat(cursorContext.getCursorTracer().pins()).isZero();
        var label = tx.tokenRead().nodeLabel(testLabel.name());
        IndexDescriptor index = tx.schemaRead().index(SchemaDescriptor.forAnyEntityTokens(EntityType.NODE)).next();
        TokenReadSession tokenReadSession = tx.dataRead().tokenReadSession(index);
        try (NodeLabelIndexCursor cursor = tx.cursors().allocateNodeLabelIndexCursor(cursorContext)) {
            tx.dataRead().nodeLabelScan(tokenReadSession, cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(label));
            assertThat(cursorContext.getCursorTracer().pins()).isNotZero();
        }
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenReadSession(org.neo4j.internal.kernel.api.TokenReadSession) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) NodeLabelIndexCursor(org.neo4j.internal.kernel.api.NodeLabelIndexCursor) Test(org.junit.jupiter.api.Test)

Aggregations

IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)404 Test (org.junit.jupiter.api.Test)231 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)81 Value (org.neo4j.values.storable.Value)43 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)33 ArrayList (java.util.ArrayList)31 Transaction (org.neo4j.graphdb.Transaction)31 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)31 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)30 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)30 TokenRead (org.neo4j.internal.kernel.api.TokenRead)29 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 SchemaRead (org.neo4j.internal.kernel.api.SchemaRead)26 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)25 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)25 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)23 IndexNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)23 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)23 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)22 KernelException (org.neo4j.exceptions.KernelException)20