Search in sources :

Example 1 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class IndexAccessorCompatibility method before.

@Before
public void before() throws Exception {
    IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
    IndexPopulator populator = indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup);
    populator.create();
    populator.close(true, NULL);
    accessor = indexProvider.getOnlineAccessor(descriptor, indexSamplingConfig, tokenNameLookup);
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) Before(org.junit.Before)

Example 2 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class SimpleIndexPopulatorCompatibility method shouldApplyUpdatesIdempotently.

@Test
public void shouldApplyUpdatesIdempotently() throws Exception {
    // GIVEN
    IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
    final Value propertyValue = Values.of("value1");
    withPopulator(indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup), p -> {
        long nodeId = 1;
        // update using populator...
        IndexEntryUpdate<SchemaDescriptor> update = add(nodeId, descriptor.schema(), propertyValue);
        p.add(singletonList(update), NULL);
        // ...is the same as update using updater
        try (IndexUpdater updater = p.newPopulatingUpdater((node, propertyId, cursorContext) -> propertyValue, NULL)) {
            updater.process(update);
        }
    });
    // THEN
    try (IndexAccessor accessor = indexProvider.getOnlineAccessor(descriptor, indexSamplingConfig, tokenNameLookup)) {
        try (ValueIndexReader reader = accessor.newValueReader();
            NodeValueIterator nodes = new NodeValueIterator()) {
            int propertyKeyId = descriptor.schema().getPropertyId();
            reader.query(NULL_CONTEXT, nodes, unconstrained(), PropertyIndexQuery.exact(propertyKeyId, propertyValue));
            assertEquals(asSet(1L), PrimitiveLongCollections.toSet(nodes));
        }
    }
}
Also used : NodeValueIterator(org.neo4j.kernel.impl.index.schema.NodeValueIterator) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) Value(org.neo4j.values.storable.Value) Values.stringValue(org.neo4j.values.storable.Values.stringValue) Test(org.junit.Test)

Example 3 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class SimpleIndexPopulatorCompatibility method shouldStorePopulationFailedForRetrievalFromProviderLater.

@Test
public void shouldStorePopulationFailedForRetrievalFromProviderLater() throws Exception {
    // GIVEN
    String failure = "The contrived failure";
    IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
    // WHEN (this will attempt to call close)
    withPopulator(indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup), p -> p.markAsFailed(failure), false);
    // THEN
    assertThat(indexProvider.getPopulationFailure(descriptor, NULL)).contains(failure);
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) Test(org.junit.Test)

Example 4 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class TokenIndexPopulatorCompatibility method shouldBeAbleToDropAClosedIndexPopulator.

@Test
public void shouldBeAbleToDropAClosedIndexPopulator() {
    // GIVEN
    IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
    final IndexPopulator p = indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup);
    p.close(false, NULL);
    // WHEN
    p.drop();
// THEN - no exception should be thrown (it's been known to!)
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) Test(org.junit.Test)

Example 5 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class TokenIndexPopulatorCompatibility method shouldStorePopulationFailedForRetrievalFromProviderLater.

@Test
public void shouldStorePopulationFailedForRetrievalFromProviderLater() throws Exception {
    // GIVEN
    String failure = "The contrived failure";
    IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
    // WHEN (this will attempt to call close)
    withPopulator(indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup), p -> p.markAsFailed(failure), false);
    // THEN
    assertThat(indexProvider.getPopulationFailure(descriptor, NULL)).contains(failure);
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) Test(org.junit.Test)

Aggregations

IndexSamplingConfig (org.neo4j.kernel.impl.api.index.IndexSamplingConfig)15 Test (org.junit.Test)7 BeforeEach (org.junit.jupiter.api.BeforeEach)3 IndexAccessors (org.neo4j.consistency.checking.index.IndexAccessors)3 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)2 Monitors (org.neo4j.monitoring.Monitors)2 Path (java.nio.file.Path)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ByteBuffersDirectory (org.apache.lucene.store.ByteBuffersDirectory)1 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 DependencyResolver (org.neo4j.common.DependencyResolver)1 Config (org.neo4j.configuration.Config)1 DatabaseReadOnlyChecker (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker)1 LookupAccessorsFromRunningDb (org.neo4j.consistency.LookupAccessorsFromRunningDb)1 ConsistencyReporter (org.neo4j.consistency.report.ConsistencyReporter)1 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)1 InconsistencyMessageLogger (org.neo4j.consistency.report.InconsistencyMessageLogger)1 InconsistencyReport (org.neo4j.consistency.report.InconsistencyReport)1