Search in sources :

Example 26 with LabelSchemaDescriptor

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

the class MultipleIndexPopulatorTest method updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan.

@Test
void updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan() throws IndexEntryConflictException, FlipFailedKernelException {
    // given
    createIndexPopulator();
    multipleIndexPopulator.create(NULL);
    IndexUpdater updater = mock(IndexUpdater.class);
    IndexPopulator populator = createIndexPopulator(updater);
    IndexUpdater indexUpdater = mock(IndexUpdater.class);
    LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(1, 1);
    addPopulator(populator, 1);
    // when external updates comes in
    ValueIndexEntryUpdate<LabelSchemaDescriptor> lowUpdate = IndexEntryUpdate.add(10, schema, intValue(99));
    ValueIndexEntryUpdate<LabelSchemaDescriptor> highUpdate = IndexEntryUpdate.add(20, schema, intValue(101));
    multipleIndexPopulator.queueConcurrentUpdate(lowUpdate);
    multipleIndexPopulator.queueConcurrentUpdate(highUpdate);
    // and we ask to apply them, given an entity in between the two
    multipleIndexPopulator.applyExternalUpdates(15);
    // then only the lower one should be applied, the higher one ignored
    verify(populator, times(1)).newPopulatingUpdater(any(), any());
    verify(updater).process(lowUpdate);
    verify(updater, never()).process(highUpdate);
    verify(indexUpdater, never()).process(any(IndexEntryUpdate.class));
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexEntryUpdate(org.neo4j.storageengine.api.IndexEntryUpdate) ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Example 27 with LabelSchemaDescriptor

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

the class SchemaReadWriteTestBase method shouldSeeIndexFromTransaction.

@Test
void shouldSeeIndexFromTransaction() throws Exception {
    try (KernelTransaction transaction = beginTransaction()) {
        transaction.schemaWrite().indexCreate(forLabel(label, prop1), "my index");
        transaction.commit();
    }
    try (KernelTransaction transaction = beginTransaction()) {
        LabelSchemaDescriptor schema = forLabel(label, prop2);
        transaction.schemaWrite().indexCreate(schema, "my other index");
        SchemaRead schemaRead = transaction.schemaRead();
        IndexDescriptor index = single(schemaRead.index(schema));
        assertThat(index.schema().getPropertyIds()).isEqualTo(new int[] { prop2 });
        assertThat(2).isEqualTo(Iterators.asList(schemaRead.indexesGetAll()).size());
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) SchemaRead(org.neo4j.internal.kernel.api.SchemaRead) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 28 with LabelSchemaDescriptor

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

the class IndexCreateIT method shouldCreateWithSpecificExistingProviderName.

protected void shouldCreateWithSpecificExistingProviderName(IndexCreator creator) throws KernelException {
    int counter = 0;
    for (GraphDatabaseSettings.SchemaIndex indexSetting : GraphDatabaseSettings.SchemaIndex.values()) {
        // given
        TokenWrite tokenWrite = tokenWriteInNewTransaction();
        int labelId = tokenWrite.labelGetOrCreateForName("Label" + counter);
        int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
        commit();
        SchemaWrite schemaWrite = schemaWriteInNewTransaction();
        LabelSchemaDescriptor descriptor = forLabel(labelId, propId);
        String provider = indexSetting.providerName();
        String indexName = "index-" + counter;
        creator.create(schemaWrite, descriptor, provider, indexName);
        IndexDescriptor index = transaction.kernelTransaction().schemaRead().indexGetForName(indexName);
        // when
        commit();
        // then
        assertEquals(provider, indexingService.getIndexProxy(index).getDescriptor().getIndexProvider().name());
        counter++;
    }
}
Also used : GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 29 with LabelSchemaDescriptor

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

the class MultiIndexPopulationConcurrentUpdatesIT method getIndexReader.

private ValueIndexReader getIndexReader(int propertyId, Integer countryLabelId) throws IndexNotFoundKernelException {
    LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(countryLabelId, propertyId);
    IndexDescriptor index = single(schemaCache.indexesForSchema(schema));
    return indexService.getIndexProxy(index).newValueReader();
}
Also used : LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 30 with LabelSchemaDescriptor

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

the class SchemaStorageIT method makeIndexRuleForConstraint.

private IndexDescriptor makeIndexRuleForConstraint(long ruleId, String label, String propertyKey, long constraintId) {
    LabelSchemaDescriptor schema = forLabel(labelId(label), propId(propertyKey));
    IndexPrototype prototype = uniqueForSchema(schema, GenericNativeIndexProvider.DESCRIPTOR);
    UniquenessConstraintDescriptor constraint = ConstraintDescriptorFactory.uniqueForSchema(schema);
    prototype = prototype.withName(SchemaRule.generateName(constraint, new String[] { label }, new String[] { propertyKey }));
    return prototype.materialise(ruleId).withOwningConstraintId(constraintId);
}
Also used : IndexPrototype(org.neo4j.internal.schema.IndexPrototype) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) UniquenessConstraintDescriptor(org.neo4j.internal.schema.constraints.UniquenessConstraintDescriptor)

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