use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class FusionIndexProviderTest method mustSelectCorrectTargetForAllGivenValueCombinations.
@Test
void mustSelectCorrectTargetForAllGivenValueCombinations() {
// given
EnumMap<IndexSlot, Value[]> values = FusionIndexTestHelp.valuesByGroup();
Value[] allValues = FusionIndexTestHelp.allValues();
for (IndexSlot slot : IndexSlot.values()) {
Value[] group = values.get(slot);
for (Value value : group) {
// when
IndexProvider selected = instanceSelector.select(slotSelector.selectSlot(array(value), CATEGORY_OF));
// then
assertSame(orLucene(providers.get(slot)), selected);
}
}
// All composite values should go to generic
for (Value firstValue : allValues) {
for (Value secondValue : allValues) {
// when
IndexProvider selected = instanceSelector.select(slotSelector.selectSlot(array(firstValue, secondValue), CATEGORY_OF));
// then
assertSame(providers.get(GENERIC), selected);
}
}
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class FusionSlotSelectorTest method shouldValidateSelectorInstances.
@Test
void shouldValidateSelectorInstances() {
// given
EnumMap<IndexSlot, IndexProvider> instances = new EnumMap<>(IndexSlot.class);
for (IndexSlot indexSlot : IndexSlot.values()) {
instances.put(indexSlot, IndexProvider.EMPTY);
}
IndexProvider mockedIndxProvider = mock(IndexProvider.class);
instances.put(GENERIC, mockedIndxProvider);
InstanceSelector<IndexProvider> selector = new InstanceSelector<>(instances);
// when
validateSelectorInstances(selector, GENERIC);
// then this should be fine
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method createIndexRules.
private IndexDescriptor[] createIndexRules(GraphDatabaseSettings.SchemaIndex schemaIndex, Map<String, Integer> labelNameIdMap, int propertyId) {
final IndexProviderMap indexProviderMap = getIndexProviderMap();
IndexProvider indexProvider = indexProviderMap.lookup(schemaIndex.providerName());
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
List<IndexDescriptor> list = new ArrayList<>();
for (Integer labelId : labelNameIdMap.values()) {
final LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyId);
IndexDescriptor index = IndexPrototype.forSchema(schema, providerDescriptor).withName("index_" + labelId).materialise(labelId);
index = indexProvider.completeConfiguration(index);
list.add(index);
}
return list.toArray(new IndexDescriptor[0]);
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class DefaultIndexProviderMap method lookup.
@Override
public IndexProvider lookup(String providerDescriptorName) {
assertInit();
IndexProvider provider = indexProvidersByName.get(providerDescriptorName);
assertProviderFound(provider, providerDescriptorName);
return provider;
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class BatchInsertTest method shouldRepopulatePreexistingIndexed.
@ParameterizedTest
@MethodSource("params")
void shouldRepopulatePreexistingIndexed(int denseNodeThreshold) throws Throwable {
// GIVEN
long jakewins = dbWithIndexAndSingleIndexedNode(denseNodeThreshold);
IndexPopulator populator = mock(IndexPopulator.class);
IndexProvider provider = mock(IndexProvider.class);
IndexAccessor accessor = mock(IndexAccessor.class);
when(provider.getProviderDescriptor()).thenReturn(DESCRIPTOR);
when(provider.completeConfiguration(any(IndexDescriptor.class))).then(inv -> inv.getArgument(0));
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);
BatchInserter inserter = newBatchInserterWithIndexProvider(singleInstanceIndexProviderFactory(KEY, provider), provider.getProviderDescriptor(), denseNodeThreshold);
long boggle = inserter.createNode(map("handle", "b0ggl3"), 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(jakewins, internalIndex.schema(), Values.of("Jakewins"))) && c.contains(add(boggle, internalIndex.schema(), Values.of("b0ggl3")))), any(CursorContext.class));
verify(populator).verifyDeferredConstraints(any(NodePropertyAccessor.class));
verify(populator).close(eq(true), any());
verify(provider).stop();
verify(provider).shutdown();
}
Aggregations