use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class BatchInsertTest method shouldRunIndexPopulationJobAtShutdown.
@ParameterizedTest
@MethodSource("params")
void shouldRunIndexPopulationJobAtShutdown(int denseNodeThreshold) throws Throwable {
// GIVEN
IndexPopulator populator = mock(IndexPopulator.class);
IndexProvider provider = mock(IndexProvider.class);
IndexAccessor accessor = mock(IndexAccessor.class);
when(provider.getProviderDescriptor()).thenReturn(DESCRIPTOR);
when(provider.getPopulator(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(), any(), any(TokenNameLookup.class))).thenReturn(populator);
when(populator.sample(any(CursorContext.class))).thenReturn(new IndexSample());
when(provider.getOnlineAccessor(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(TokenNameLookup.class))).thenReturn(accessor);
when(provider.completeConfiguration(any(IndexDescriptor.class))).then(inv -> inv.getArgument(0));
BatchInserter inserter = newBatchInserterWithIndexProvider(singleInstanceIndexProviderFactory(KEY, provider), provider.getProviderDescriptor(), denseNodeThreshold);
inserter.createDeferredSchemaIndex(label("Hacker")).on("handle").create();
long nodeId = inserter.createNode(map("handle", "Jakewins"), label("Hacker"));
// WHEN
inserter.shutdown();
// THEN
verify(provider).init();
verify(provider).start();
verify(provider).getPopulator(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(), any(), any(TokenNameLookup.class));
verify(populator).create();
verify(populator).add(argThat(c -> c.contains(add(nodeId, internalIndex.schema(), Values.of("Jakewins")))), any(CursorContext.class));
verify(populator).verifyDeferredConstraints(any(NodePropertyAccessor.class));
verify(populator).close(eq(true), any());
verify(provider).stop();
verify(provider).shutdown();
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class BatchInsertTest method dbWithIndexAndSingleIndexedNode.
private long dbWithIndexAndSingleIndexedNode(int denseNodeThreshold) throws Exception {
IndexPopulator populator = mock(IndexPopulator.class);
IndexProvider provider = mock(IndexProvider.class);
when(provider.getProviderDescriptor()).thenReturn(DESCRIPTOR);
when(provider.getPopulator(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(), any(), any(TokenNameLookup.class))).thenReturn(populator);
when(provider.completeConfiguration(any(IndexDescriptor.class))).then(inv -> inv.getArgument(0));
BatchInserter inserter = newBatchInserterWithIndexProvider(singleInstanceIndexProviderFactory(KEY, provider), provider.getProviderDescriptor(), denseNodeThreshold);
inserter.createDeferredSchemaIndex(label("Hacker")).on("handle").create();
long nodeId = inserter.createNode(map("handle", "Jakewins"), label("Hacker"));
inserter.shutdown();
return nodeId;
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class SchemaLoggingIT method shouldLogUserReadableLabelAndPropertyNames.
@Test
void shouldLogUserReadableLabelAndPropertyNames() {
String labelName = "User";
String property = "name";
// when
long indexId = createIndex(db, labelName, property);
// then
IndexProvider defaultProvider = indexProviderMap.getDefaultProvider();
IndexProviderDescriptor providerDescriptor = defaultProvider.getProviderDescriptor();
String indexName = "Index( id=" + indexId + ", name='index_a908f819', type='GENERAL BTREE', " + "schema=(:User {name}), indexProvider='" + providerDescriptor.name() + "' )";
assertThat(logProvider).forLevel(INFO).containsMessageWithArguments("Index population started: [%s]", indexName).containsMessageWithArguments(CREATION_FINISHED, indexName);
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class DefaultIndexProviderMap method put.
private IndexProvider put(IndexProviderDescriptor providerDescriptor, IndexProvider provider) {
IndexProvider existing = indexProvidersByDescriptor.putIfAbsent(providerDescriptor, provider);
indexProvidersByName.putIfAbsent(providerDescriptor.name(), provider);
return existing;
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class DefaultIndexProviderMap method initDefaultProviders.
private void initDefaultProviders() {
String providerName = config.get(GraphDatabaseSettings.default_schema_provider);
IndexProvider configuredDefaultProvider = indexProvidersByName.get(providerName);
requireNonNull(configuredDefaultProvider, () -> format("Configured default provider: `%s` not found. Available index providers: %s.", providerName, indexProvidersByName.keySet()));
defaultIndexProvider = configuredDefaultProvider;
String fulltextProviderName = config.get(GraphDatabaseInternalSettings.default_fulltext_provider);
fulltextIndexProvider = indexProvidersByName.get(fulltextProviderName);
if (fulltextIndexProvider == null) {
// Not all environments have the full-text index provider available.
fulltextIndexProvider = IndexProvider.EMPTY;
}
var configuredTokenIndexProvider = indexProvidersByName.get(TOKEN_INDEX_PROVIDER_NAME);
requireNonNull(configuredTokenIndexProvider, () -> format("Token index provider: `%s` not found. Available index providers: %s.", TOKEN_INDEX_PROVIDER_NAME, indexProvidersByName.keySet().toString()));
tokenIndexProvider = configuredTokenIndexProvider;
}
Aggregations