use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportNodesThatAreNotIndexed.
@Test
public void shouldReportNodesThatAreNotIndexed() 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.remove(asPrimitiveLongSet(indexedNodes));
updater.close();
accessor.close();
}
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.NODE, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class MultipleIndexPopulator method newPopulatingUpdater.
@Override
public MultipleIndexUpdater newPopulatingUpdater(PropertyAccessor accessor) {
Map<LabelSchemaDescriptor, Pair<IndexPopulation, IndexUpdater>> updaters = new HashMap<>();
forEachPopulation(population -> {
IndexUpdater updater = population.populator.newPopulatingUpdater(accessor);
updaters.put(population.descriptor.schema(), Pair.of(population, updater));
});
return new MultipleIndexUpdater(this, updaters, logProvider);
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class IndexUpdaterMap method getUpdater.
IndexUpdater getUpdater(LabelSchemaDescriptor descriptor) {
IndexUpdater updater = updaterMap.get(descriptor);
if (null == updater) {
IndexProxy indexProxy = indexMap.getIndexProxy(descriptor);
if (null != indexProxy) {
updater = indexProxy.newUpdater(indexUpdateMode);
updaterMap.put(descriptor, updater);
}
}
return updater;
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class FulltextIndexConsistencyCheckIT method mustDiscoverNodeInStoreMissingFromIndex.
@Test
void mustDiscoverNodeInStoreMissingFromIndex() throws Exception {
GraphDatabaseService db = createDatabase();
try (Transaction tx = db.beginTx()) {
tx.execute(format(NODE_CREATE, "nodes", asStrList("Label"), asStrList("prop"))).close();
tx.commit();
}
IndexDescriptor indexDescriptor;
long nodeId;
try (Transaction tx = db.beginTx()) {
tx.schema().awaitIndexesOnline(2, TimeUnit.MINUTES);
indexDescriptor = getFulltextIndexDescriptor(tx.schema().getIndexes());
Node node = tx.createNode(Label.label("Label"));
node.setProperty("prop", "value");
nodeId = node.getId();
tx.commit();
}
IndexingService indexes = getIndexingService(db);
IndexProxy indexProxy = indexes.getIndexProxy(indexDescriptor);
try (IndexUpdater updater = indexProxy.newUpdater(IndexUpdateMode.ONLINE, NULL)) {
updater.process(IndexEntryUpdate.remove(nodeId, indexDescriptor, Values.stringValue("value")));
}
managementService.shutdown();
ConsistencyCheckService.Result result = checkConsistency();
assertFalse(result.isSuccessful());
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class GenericBlockBasedIndexPopulatorTest method shouldThrowOnDuplicatedValuesFromScanAndExternalUpdates.
@Test
void shouldThrowOnDuplicatedValuesFromScanAndExternalUpdates() throws IOException {
// given
BlockBasedIndexPopulator<GenericKey, NativeIndexValue> populator = instantiatePopulator(UNIQUE_INDEX_DESCRIPTOR);
try {
// when
Value duplicate = Values.of("duplicate");
ValueIndexEntryUpdate<?> externalUpdate = ValueIndexEntryUpdate.add(1, INDEX_DESCRIPTOR, duplicate);
ValueIndexEntryUpdate<?> scanUpdate = ValueIndexEntryUpdate.add(2, INDEX_DESCRIPTOR, duplicate);
assertThrows(IndexEntryConflictException.class, () -> {
try (IndexUpdater updater = populator.newPopulatingUpdater(NULL)) {
updater.process(externalUpdate);
}
populator.add(singleton(scanUpdate), NULL);
populator.scanCompleted(nullInstance, populationWorkScheduler, NULL);
});
} finally {
populator.close(true, NULL);
}
}
Aggregations