use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class IndexUpdaterMapTest method shouldCloseAllUpdaters.
@Test
void shouldCloseAllUpdaters() throws Exception {
// given
indexMap.putIndexProxy(indexProxy1);
indexMap.putIndexProxy(indexProxy2);
IndexUpdater updater1 = updaterMap.getUpdater(schemaIndexDescriptor1, NULL);
IndexUpdater updater2 = updaterMap.getUpdater(schemaIndexDescriptor, NULL);
// hen
updaterMap.close();
// then
verify(updater1).close();
verify(updater2).close();
assertTrue(updaterMap.isEmpty(), "updater map must be empty");
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class IndexUpdaterMapTest method shouldRetrieveNoUpdaterForNonExistingIndex.
@Test
void shouldRetrieveNoUpdaterForNonExistingIndex() {
// when
IndexUpdater updater = updaterMap.getUpdater(schemaIndexDescriptor1, NULL);
// then
assertNull(updater);
assertTrue(updaterMap.isEmpty(), "updater map must be empty");
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class IndexingService method applyRecoveredUpdates.
private void applyRecoveredUpdates() throws IOException, IndexEntryConflictException {
if (log.isDebugEnabled()) {
log.debug("Applying recovered updates: " + recoveredNodeIds);
}
monitor.applyingRecoveredData(recoveredNodeIds);
if (!recoveredNodeIds.isEmpty()) {
try (IndexUpdaterMap updaterMap = indexMapRef.createIndexUpdaterMap(IndexUpdateMode.RECOVERY)) {
for (IndexUpdater updater : updaterMap) {
updater.remove(recoveredNodeIds);
}
IndexUpdates updates = readRecoveredUpdatesFromStore();
apply(updates, IndexUpdateMode.RECOVERY);
monitor.appliedRecoveredData(updates);
}
}
recoveredNodeIds.clear();
}
use of org.neo4j.kernel.api.index.IndexUpdater 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();
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class ContractCheckingIndexProxyTest method shouldNotCloseWhileUpdating.
@Test(expected = /* THEN */
IllegalStateException.class)
public void shouldNotCloseWhileUpdating() throws IOException {
// GIVEN
final DoubleLatch latch = new DoubleLatch();
final IndexProxy inner = new IndexProxyAdapter() {
@Override
public IndexUpdater newUpdater(IndexUpdateMode mode) {
return super.newUpdater(mode);
}
};
final IndexProxy outer = newContractCheckingIndexProxy(inner);
outer.start();
// WHEN
runInSeparateThread(() -> {
try (IndexUpdater updater = outer.newUpdater(IndexUpdateMode.ONLINE)) {
updater.process(null);
latch.startAndWaitForAllToStartAndFinish();
} catch (IndexEntryConflictException e) {
throw new RuntimeException(e);
}
});
try {
latch.waitForAllToStart();
outer.close();
} finally {
latch.finish();
}
}
Aggregations