use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig in project neo4j by neo4j.
the class IndexingServiceFactory method createIndexingService.
public static IndexingService createIndexingService(Config config, JobScheduler scheduler, SchemaIndexProviderMap providerMap, IndexStoreView storeView, TokenNameLookup tokenNameLookup, Iterable<IndexRule> indexRules, LogProvider logProvider, IndexingService.Monitor monitor, Runnable schemaStateChangeCallback) {
if (providerMap == null || providerMap.getDefaultProvider() == null) {
throw new IllegalStateException("You cannot run the database without an index provider, " + "please make sure that a valid provider (subclass of " + SchemaIndexProvider.class.getName() + ") is on your classpath.");
}
IndexSamplingConfig samplingConfig = new IndexSamplingConfig(config);
MultiPopulatorFactory multiPopulatorFactory = MultiPopulatorFactory.forConfig(config);
IndexMapReference indexMapRef = new IndexMapReference();
IndexSamplingControllerFactory factory = new IndexSamplingControllerFactory(samplingConfig, storeView, scheduler, tokenNameLookup, logProvider);
IndexSamplingController indexSamplingController = factory.create(indexMapRef);
IndexProxyCreator proxySetup = new IndexProxyCreator(samplingConfig, storeView, providerMap, tokenNameLookup, logProvider);
return new IndexingService(proxySetup, providerMap, indexMapRef, storeView, indexRules, indexSamplingController, tokenNameLookup, scheduler, schemaStateChangeCallback, multiPopulatorFactory, logProvider, monitor);
}
use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig in project neo4j by neo4j.
the class LuceneSchemaIndexPopulatorTest method before.
@Before
public void before() throws Exception {
directory = new RAMDirectory();
DirectoryFactory directoryFactory = new DirectoryFactory.Single(new DirectoryFactory.UncloseableDirectory(directory));
provider = new LuceneSchemaIndexProvider(fs.get(), directoryFactory, testDir.directory("folder"), NullLogProvider.getInstance(), Config.empty(), OperationalMode.single);
indexStoreView = mock(IndexStoreView.class);
IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.empty());
indexPopulator = provider.getPopulator(indexId, index, samplingConfig);
indexPopulator.create();
indexPopulator.configureSampling(true);
}
use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig in project neo4j by neo4j.
the class BatchInserterImpl method repopulateAllIndexes.
private void repopulateAllIndexes() throws IOException, IndexEntryConflictException {
if (!labelsTouched) {
return;
}
final IndexRule[] rules = getIndexesNeedingPopulation();
final IndexPopulator[] populators = new IndexPopulator[rules.length];
// the store is uncontended at this point, so creating a local LockService is safe.
final NewIndexDescriptor[] descriptors = new NewIndexDescriptor[rules.length];
for (int i = 0; i < rules.length; i++) {
IndexRule rule = rules[i];
descriptors[i] = rule.getIndexDescriptor();
populators[i] = schemaIndexProviders.apply(rule.getProviderDescriptor()).getPopulator(rule.getId(), descriptors[i], new IndexSamplingConfig(config));
populators[i].create();
}
Visitor<NodeUpdates, IOException> propertyUpdateVisitor = updates -> {
for (int i = 0; i < descriptors.length; i++) {
Optional<IndexEntryUpdate> update = updates.forIndex(descriptors[i].schema());
if (update.isPresent()) {
try {
populators[i].add(Collections.singletonList(update.get()));
} catch (IndexEntryConflictException conflict) {
throw conflict.notAllowed(descriptors[i]);
}
}
}
return true;
};
List<NewIndexDescriptor> descriptorList = Arrays.asList(descriptors);
int[] labelIds = descriptorList.stream().mapToInt(index -> index.schema().getLabelId()).toArray();
int[] propertyKeyIds = descriptorList.stream().flatMapToInt(d -> Arrays.stream(d.schema().getPropertyIds())).toArray();
InitialNodeLabelCreationVisitor labelUpdateVisitor = new InitialNodeLabelCreationVisitor();
StoreScan<IOException> storeScan = indexStoreView.visitNodes(labelIds, (propertyKeyId) -> PrimitiveIntCollections.contains(propertyKeyIds, propertyKeyId), propertyUpdateVisitor, labelUpdateVisitor, true);
storeScan.run();
for (IndexPopulator populator : populators) {
populator.verifyDeferredConstraints(indexStoreView);
populator.close(true);
}
labelUpdateVisitor.close();
}
use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldNotReportIndexInconsistenciesIfIndexIsFailed.
@Test
public void shouldNotReportIndexInconsistenciesIfIndexIsFailed() throws Exception {
// this test fails all indexes, and then destroys a record and makes sure we only get a failure for
// the label scan store but not for any index
// given
DirectStoreAccess storeAccess = fixture.directStoreAccess();
// fail all indexes
Iterator<IndexRule> rules = new SchemaStorage(storeAccess.nativeStores().getSchemaStore()).indexesGetAll();
while (rules.hasNext()) {
IndexRule rule = rules.next();
IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.empty());
IndexPopulator populator = storeAccess.indexes().getPopulator(rule.getId(), rule.getIndexDescriptor(), samplingConfig);
populator.markAsFailed("Oh noes! I was a shiny index and then I was failed");
populator.close(false);
}
for (Long indexedNodeId : indexedNodes) {
storeAccess.nativeStores().getNodeStore().updateRecord(notInUse(new NodeRecord(indexedNodeId, false, -1, -1)));
}
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.LABEL_SCAN_DOCUMENT, 1).verify(RecordType.COUNTS, 3).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportNodesWithDuplicatePropertyValueInUniqueIndex.
@Test
public void shouldReportNodesWithDuplicatePropertyValueInUniqueIndex() throws Exception {
// given
IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.empty());
Iterator<IndexRule> indexRuleIterator = new SchemaStorage(fixture.directStoreAccess().nativeStores().getSchemaStore()).indexesGetAll();
while (indexRuleIterator.hasNext()) {
IndexRule indexRule = indexRuleIterator.next();
IndexAccessor accessor = fixture.directStoreAccess().indexes().getOnlineAccessor(indexRule.getId(), indexRule.getIndexDescriptor(), samplingConfig);
IndexUpdater updater = accessor.newUpdater(IndexUpdateMode.ONLINE);
updater.process(IndexEntryUpdate.add(42, indexRule.getIndexDescriptor().schema(), "value"));
updater.close();
accessor.close();
}
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.NODE, 1).verify(RecordType.INDEX, 2).andThatsAllFolks();
}
Aggregations