indexes: allow to process inline keys for every index storage (only testing purposes)

GitOrigin-RevId: 0fc3d02aabe827b34957a91012f905c7fcb01f4c
This commit is contained in:
Dmitro Batko
2020-03-10 09:01:29 +00:00
committed by intellij-monorepo-bot
parent ff9322dd60
commit 0a108fe06e
2 changed files with 9 additions and 8 deletions
@@ -239,13 +239,6 @@ public final class VfsAwareMapIndexStorage<Key, Value> extends MapIndexStorage<K
}
}
private boolean doProcessKeys(@NotNull Processor<? super Key> processor) throws IOException {
return myMap instanceof PersistentHashMap && myKeyDescriptor instanceof InlineKeyDescriptor
// process keys and check that they're already present in map because we don't have separated key storage we must check keys
? ((PersistentHashMap<Key, UpdatableValueContainer<Value>>)myMap).processKeysWithExistingMapping(processor)
// optimization: process all keys, some of them might be already deleted but we don't care. We just read key storage file here
: myMap.processKeys(processor);
}
@NotNull
private static TIntHashSet loadHashedIds(@NotNull File fileWithCaches) throws IOException {
@@ -292,7 +292,7 @@ public abstract class MapIndexStorage<Key, Value> implements IndexStorage<Key, V
l.lock();
try {
myCache.clear(); // this will ensure that all new keys are made into the map
return myMap.processKeys(processor);
return doProcessKeys(processor);
}
catch (IOException e) {
throw new StorageException(e);
@@ -306,6 +306,14 @@ public abstract class MapIndexStorage<Key, Value> implements IndexStorage<Key, V
}
}
protected boolean doProcessKeys(@NotNull Processor<? super Key> processor) throws IOException {
return myMap instanceof PersistentHashMap && myKeyDescriptor instanceof InlineKeyDescriptor
// process keys and check that they're already present in map because we don't have separated key storage we must check keys
? ((PersistentHashMap<Key, UpdatableValueContainer<Value>>)myMap).processKeysWithExistingMapping(processor)
// optimization: process all keys, some of them might be already deleted but we don't care. We just read key storage file here
: myMap.processKeys(processor);
}
@TestOnly
public PersistentMap<Key, UpdatableValueContainer<Value>> getIndexMap() {
return myMap;