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);
}
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());
}
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()));
}
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);
}
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);
}
Aggregations