use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class LuceneFulltextIndexTest method completeConfigurationMustNotOverwriteExistingConfiguration.
@Test
void completeConfigurationMustNotOverwriteExistingConfiguration() {
IndexConfig indexConfig = IndexConfig.with("A", Values.stringValue("B"));
FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { 1 }, new int[] { 1 });
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
IndexDescriptor descriptor = indexProvider.completeConfiguration(IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").materialise(1)).withIndexConfig(indexConfig);
assertEquals(Values.stringValue("B"), descriptor.getIndexConfig().get("A"));
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class LuceneFulltextIndexTest method completeConfigurationMustInjectMissingConfigurations.
@Test
void completeConfigurationMustInjectMissingConfigurations() throws Exception {
int label;
int propertyKey;
try (Transaction tx = db.beginTx()) {
createNodeIndexableByPropertyValue(tx, LABEL, "bla");
tx.commit();
}
try (KernelTransactionImplementation tx = getKernelTransaction()) {
label = tx.tokenRead().nodeLabel(LABEL.name());
propertyKey = tx.tokenRead().propertyKey(PROP);
tx.success();
}
IndexConfig indexConfig = IndexConfig.with(EVENTUALLY_CONSISTENT, Values.booleanValue(true));
FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { label }, new int[] { propertyKey });
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
IndexDescriptor descriptor = indexProvider.completeConfiguration(IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").withIndexConfig(indexConfig).materialise(1));
assertThat((Value) descriptor.getIndexConfig().get(ANALYZER)).isEqualTo(Values.stringValue("standard-no-stop-words"));
assertThat((Value) descriptor.getIndexConfig().get(EVENTUALLY_CONSISTENT)).isEqualTo(Values.booleanValue(true));
assertThat(asList(descriptor.getCapability().behaviours())).containsExactlyInAnyOrder(IndexBehaviour.EVENTUALLY_CONSISTENT, IndexBehaviour.SKIP_AND_LIMIT);
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class Operations method ensureIndexPrototypeHasIndexProvider.
private IndexPrototype ensureIndexPrototypeHasIndexProvider(IndexPrototype prototype) {
if (prototype.getIndexProvider() == IndexProviderDescriptor.UNDECIDED) {
IndexProviderDescriptor provider;
if (prototype.getIndexType() == IndexType.FULLTEXT) {
provider = indexProviders.getFulltextProvider();
} else if (prototype.getIndexType() == IndexType.LOOKUP) {
provider = indexProviders.getTokenIndexProvider();
} else {
provider = indexProviders.getDefaultProvider();
}
prototype = prototype.withIndexProvider(provider);
}
return prototype;
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class GenericBlockBasedIndexPopulatorTest method setup.
@BeforeEach
void setup() {
IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("test", "v1");
IndexDirectoryStructure directoryStructure = directoriesByProvider(directory.homePath()).forProvider(providerDescriptor);
indexFiles = new IndexFiles.Directory(fs, directoryStructure, INDEX_DESCRIPTOR.getId());
databaseIndexContext = DatabaseIndexContext.builder(pageCache, fs, DEFAULT_DATABASE_NAME).build();
jobScheduler = JobSchedulerFactory.createInitialisedScheduler();
populationWorkScheduler = new IndexPopulator.PopulationWorkScheduler() {
@Override
public <T> JobHandle<T> schedule(IndexPopulator.JobDescriptionSupplier descriptionSupplier, Callable<T> job) {
return jobScheduler.schedule(Group.INDEX_POPULATION_WORK, new JobMonitoringParams(null, null, null), job);
}
};
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class IndexingService method init.
/**
* Called while the database starts up, before recovery.
*/
@Override
public void init() throws IOException {
validateDefaultProviderExisting();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(INIT_TAG))) {
indexMapRef.modify(indexMap -> {
Map<InternalIndexState, List<IndexLogRecord>> indexStates = new EnumMap<>(InternalIndexState.class);
for (IndexDescriptor descriptor : indexDescriptors) {
// No index (except NLI) is allowed to have the name generated for NLI.
if (descriptor.getName().equals(IndexDescriptor.NLI_GENERATED_NAME) && !(descriptor.schema().isAnyTokenSchemaDescriptor() && descriptor.schema().entityType() == NODE)) {
throw new IllegalStateException("Index '" + descriptor.userDescription(tokenNameLookup) + "' is using a reserved name: '" + IndexDescriptor.NLI_GENERATED_NAME + "'. This index must be removed on an earlier version " + "to be able to use binaries for version 4.3 or newer.");
}
IndexProxy indexProxy;
IndexProviderDescriptor providerDescriptor = descriptor.getIndexProvider();
IndexProvider provider = providerMap.lookup(providerDescriptor);
InternalIndexState initialState = provider.getInitialState(descriptor, cursorContext);
indexStates.computeIfAbsent(initialState, internalIndexState -> new ArrayList<>()).add(new IndexLogRecord(descriptor));
internalLog.debug(indexStateInfo("init", initialState, descriptor));
switch(initialState) {
case ONLINE:
monitor.initialState(databaseName, descriptor, ONLINE);
indexProxy = indexProxyCreator.createOnlineIndexProxy(descriptor);
break;
case POPULATING:
// The database was shut down during population, or a crash has occurred, or some other sad thing.
monitor.initialState(databaseName, descriptor, POPULATING);
indexProxy = indexProxyCreator.createRecoveringIndexProxy(descriptor);
break;
case FAILED:
monitor.initialState(databaseName, descriptor, FAILED);
IndexPopulationFailure failure = failure(provider.getPopulationFailure(descriptor, cursorContext));
indexProxy = indexProxyCreator.createFailedIndexProxy(descriptor, failure);
break;
default:
throw new IllegalArgumentException("" + initialState);
}
indexMap.putIndexProxy(indexProxy);
}
logIndexStateSummary("init", indexStates);
return indexMap;
});
}
indexStatisticsStore.init();
}
Aggregations