Search in sources :

Example 1 with TokenIndexProviderFactory

use of org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory in project neo4j by neo4j.

the class LuceneIndexRecoveryIT method startDb.

private void startDb(ExtensionFactory<?> indexProviderFactory) {
    if (db != null) {
        managementService.shutdown();
    }
    TestDatabaseManagementServiceBuilder factory = new TestDatabaseManagementServiceBuilder();
    factory.setFileSystem(fs);
    factory.setExtensions(asList(indexProviderFactory, new TokenIndexProviderFactory()));
    managementService = factory.impermanent().setConfig(default_schema_provider, DESCRIPTOR.name()).build();
    db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory)

Example 2 with TokenIndexProviderFactory

use of org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory in project neo4j by neo4j.

the class FulltextIndexConsistencyCheckIT method mustDiscoverNodeInIndexMissingFromStore.

@Disabled("Turns out that this is not something that the consistency checker actually looks for, currently. " + "The test is disabled until the consistency checker is extended with checks that will discover this sort of inconsistency.")
@Test
void mustDiscoverNodeInIndexMissingFromStore() throws Exception {
    GraphDatabaseService db = createDatabase();
    try (Transaction tx = db.beginTx()) {
        tx.execute(format(NODE_CREATE, "nodes", asStrList("Label"), asStrList("prop"))).close();
        tx.commit();
    }
    long nodeId;
    try (Transaction tx = db.beginTx()) {
        tx.schema().awaitIndexesOnline(2, TimeUnit.MINUTES);
        Node node = tx.createNode(Label.label("Label"));
        nodeId = node.getId();
        node.setProperty("prop", "value");
        tx.commit();
    }
    // Remove the property without updating the index
    managementService.shutdown();
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).setFileSystem(fs).removeExtensions(INDEX_PROVIDERS_FILTER).addExtension(new FailingGenericNativeIndexProviderFactory(SKIP_ONLINE_UPDATES)).addExtension(new TokenIndexProviderFactory()).build();
    db = managementService.database(DEFAULT_DATABASE_NAME);
    try (Transaction tx = db.beginTx()) {
        tx.getNodeById(nodeId).removeProperty("prop");
        tx.commit();
    }
    managementService.shutdown();
    ConsistencyCheckService.Result result = checkConsistency();
    assertFalse(result.isSuccessful());
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory) FailingGenericNativeIndexProviderFactory(org.neo4j.kernel.impl.index.schema.FailingGenericNativeIndexProviderFactory) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with TokenIndexProviderFactory

use of org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory in project neo4j by neo4j.

the class BatchInsertTest method newBatchInserterWithIndexProvider.

private BatchInserter newBatchInserterWithIndexProvider(ExtensionFactory<?> provider, IndexProviderDescriptor providerDescriptor, int denseNodeThreshold) throws Exception {
    Config configuration = configuration(denseNodeThreshold);
    configuration.set(GraphDatabaseSettings.default_schema_provider, providerDescriptor.name());
    return BatchInserters.inserter(databaseLayout, fs, configuration, asList(provider, new TokenIndexProviderFactory()));
}
Also used : Config(org.neo4j.configuration.Config) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory)

Example 4 with TokenIndexProviderFactory

use of org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory in project neo4j by neo4j.

the class UniqueConstraintCompatibility method setUp.

/*
     * There are a quite a number of permutations to consider, when it comes to unique
     * constraints.
     *
     * We have two supported providers:
     *  - InMemoryIndexProvider
     *  - LuceneIndexProvider
     *
     * An index can be in a number of states, two of which are interesting:
     *  - ONLINE: the index is in active duty
     *  - POPULATING: the index is in the process of being created and filled with data
     *
     * Further more, indexes that are POPULATING have two ways of ingesting data:
     *  - Through add()'ing existing data
     *  - Through NodePropertyUpdates sent to a "populating updater"
     *
     * Then, when we add data to an index, two outcomes are possible, depending on the
     * data:
     *  - The index does not contain an equivalent value, and the entity id is added to
     *    the index.
     *  - The index already contains an equivalent value, and the addition is rejected.
     *
     * And when it comes to observing these outcomes, there are a whole bunch of
     * interesting transaction states that are worth exploring:
     *  - Adding a label to a node
     *  - Removing a label from a node
     *  - Combinations of adding and removing a label, ultimately adding it
     *  - Combinations of adding and removing a label, ultimately removing it
     *  - Adding a property
     *  - Removing a property
     *  - Changing an existing property
     *  - Combinations of adding and removing a property, ultimately adding it
     *  - Combinations of adding and removing a property, ultimately removing it
     *  - Likewise combinations of adding, removing and changing a property
     *
     * To make matters worse, we index a number of different types, some of which may or
     * may not collide in the index because of coercion. We need to make sure that the
     * indexes deal with these values correctly. And we also have the ways in which these
     * operations can be performed in any number of transactions, for instance, if all
     * the conflicting nodes were added in the same transaction or not.
     *
     * All in all, we have many cases to test for!
     *
     * Still, it is possible to boil things down a little bit, because there are fewer
     * outcomes than there are scenarios that lead to those outcomes. With a bit of
     * luck, we can abstract over the scenarios that lead to those outcomes, and then
     * only write a test per outcome. These are the outcomes I see:
     *  - Populating an index succeeds
     *  - Populating an index fails because of the existing data
     *  - Populating an index fails because of updates to data
     *  - Adding to an online index succeeds
     *  - Adding to an online index fails because of existing data
     *  - Adding to an online index fails because of data in the same transaction
     *
     * There's a lot of work to be done here.
     */
@Before
public void setUp() {
    managementService = new TestDatabaseManagementServiceBuilder(graphDbDir).setExtensions(asList(new PredefinedIndexProviderFactory(indexProvider), new TokenIndexProviderFactory())).noOpSystemGraphInitializer().impermanent().setConfig(default_schema_provider, indexProvider.getProviderDescriptor().name()).build();
    db = managementService.database(DEFAULT_DATABASE_NAME);
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory) Before(org.junit.Before)

Example 5 with TokenIndexProviderFactory

use of org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory in project neo4j by neo4j.

the class IndexRecoveryIT method startDb.

private void startDb() {
    if (db != null) {
        managementService.shutdown();
    }
    managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setFileSystem(testDirectory.getFileSystem()).setExtensions(asList(mockedIndexProviderFactory, new TokenIndexProviderFactory())).noOpSystemGraphInitializer().setMonitors(monitors).setConfig(default_schema_provider, PROVIDER_DESCRIPTOR.name()).build();
    db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory)

Aggregations

TokenIndexProviderFactory (org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory)9 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)7 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)2 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 Transaction (org.neo4j.graphdb.Transaction)2 FailingGenericNativeIndexProviderFactory (org.neo4j.kernel.impl.index.schema.FailingGenericNativeIndexProviderFactory)2 Path (java.nio.file.Path)1 Before (org.junit.Before)1 Disabled (org.junit.jupiter.api.Disabled)1 Config (org.neo4j.configuration.Config)1 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)1 Node (org.neo4j.graphdb.Node)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 UncloseableDelegatingFileSystemAbstraction (org.neo4j.io.fs.UncloseableDelegatingFileSystemAbstraction)1 PageCache (org.neo4j.io.pagecache.PageCache)1 ExtensionFactory (org.neo4j.kernel.extension.ExtensionFactory)1 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.IndexSamplingConfig)1