Search in sources :

Example 6 with LabelSchemaDescriptor

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

the class FusionIndexUpdaterTest method verifyChangeWithCorrectUpdaterMixed.

private void verifyChangeWithCorrectUpdaterMixed(IndexUpdater expectRemoveFrom, IndexUpdater expectAddTo, Value[] beforeValues, Value[] afterValues) throws IndexEntryConflictException {
    for (int beforeIndex = 0; beforeIndex < beforeValues.length; beforeIndex++) {
        Value before = beforeValues[beforeIndex];
        for (int afterIndex = 0; afterIndex < afterValues.length; afterIndex++) {
            Value after = afterValues[afterIndex];
            IndexEntryUpdate<LabelSchemaDescriptor> change = change(before, after);
            fusionIndexUpdater.process(change);
            if (expectRemoveFrom != expectAddTo) {
                verify(expectRemoveFrom, times(afterIndex + 1)).process(remove(before));
                verify(expectAddTo, times(beforeIndex + 1)).process(add(after));
            } else {
                verify(expectRemoveFrom).process(change(before, after));
            }
        }
    }
}
Also used : Value(org.neo4j.values.storable.Value) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor)

Example 7 with LabelSchemaDescriptor

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

the class UniqueDatabaseIndexPopulatorTest method sampleIncludedUpdates.

@Test
void sampleIncludedUpdates() {
    LabelSchemaDescriptor schemaDescriptor = forLabel(1, 1);
    populator = newPopulator();
    List<IndexEntryUpdate<?>> updates = Arrays.asList(add(1, schemaDescriptor, "foo"), add(2, schemaDescriptor, "bar"), add(3, schemaDescriptor, "baz"), add(4, schemaDescriptor, "qux"));
    updates.forEach(populator::includeSample);
    IndexSample sample = populator.sample(NULL);
    assertEquals(new IndexSample(4, 4, 4), sample);
}
Also used : IndexEntryUpdate(org.neo4j.storageengine.api.IndexEntryUpdate) IndexSample(org.neo4j.kernel.api.index.IndexSample) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) Test(org.junit.jupiter.api.Test)

Example 8 with LabelSchemaDescriptor

use of org.neo4j.internal.schema.LabelSchemaDescriptor 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 9 with LabelSchemaDescriptor

use of org.neo4j.internal.schema.LabelSchemaDescriptor 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 10 with LabelSchemaDescriptor

use of org.neo4j.internal.schema.LabelSchemaDescriptor 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)

Aggregations

LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)63 Test (org.junit.jupiter.api.Test)41 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)24 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)16 SchemaWrite (org.neo4j.internal.kernel.api.SchemaWrite)5 UniquenessConstraintDescriptor (org.neo4j.internal.schema.constraints.UniquenessConstraintDescriptor)5 Value (org.neo4j.values.storable.Value)5 Transaction (org.neo4j.graphdb.Transaction)4 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)4 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)4 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)4 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 RepeatedTest (org.junit.jupiter.api.RepeatedTest)3 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)3 Node (org.neo4j.graphdb.Node)3 TokenRead (org.neo4j.internal.kernel.api.TokenRead)3 TokenWrite (org.neo4j.internal.kernel.api.TokenWrite)3 IndexConfig (org.neo4j.internal.schema.IndexConfig)3