diff --git a/java/execution/impl/src/com/intellij/execution/testDiscovery/indices/DiscoveredTestsIndex.java b/java/execution/impl/src/com/intellij/execution/testDiscovery/indices/DiscoveredTestsIndex.java index 3b4574c59898..e1849714bbd2 100644 --- a/java/execution/impl/src/com/intellij/execution/testDiscovery/indices/DiscoveredTestsIndex.java +++ b/java/execution/impl/src/com/intellij/execution/testDiscovery/indices/DiscoveredTestsIndex.java @@ -20,7 +20,7 @@ public class DiscoveredTestsIndex extends MapReduceIndex(new IntCollectionDataExternalizer())); } diff --git a/java/execution/impl/src/com/intellij/execution/testDiscovery/indices/TestFilesIndex.java b/java/execution/impl/src/com/intellij/execution/testDiscovery/indices/TestFilesIndex.java index f4c9da8d4a8c..e3ae818a8a79 100644 --- a/java/execution/impl/src/com/intellij/execution/testDiscovery/indices/TestFilesIndex.java +++ b/java/execution/impl/src/com/intellij/execution/testDiscovery/indices/TestFilesIndex.java @@ -21,7 +21,7 @@ public class TestFilesIndex extends MapReduceIndex { protected TestFilesIndex(@NotNull File file) throws IOException { super(INDEX_EXTENSION, new MyIndexStorage(file), - new PersistentMapBasedForwardIndex(new File(file, "forward.idx")), + new PersistentMapBasedForwardIndex(new File(file, "forward.idx"), false), new KeyCollectionForwardIndexAccessor<>(new IntCollectionDataExternalizer())); } diff --git a/java/java-tests/testSrc/com/intellij/java/index/StringIndex.java b/java/java-tests/testSrc/com/intellij/java/index/StringIndex.java index d0e01aa2ac70..cbc6e759c7c3 100644 --- a/java/java-tests/testSrc/com/intellij/java/index/StringIndex.java +++ b/java/java-tests/testSrc/com/intellij/java/index/StringIndex.java @@ -103,7 +103,7 @@ public class StringIndex { }; myIndex = new MapReduceIndex(extension, storage, - new PersistentMapBasedForwardIndex(forwardIndexFile), + new PersistentMapBasedForwardIndex(forwardIndexFile, false), new KeyCollectionForwardIndexAccessor<>(anotherStringExternalizer)) { @Override public void checkCanceled() { diff --git a/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompilerReferenceIndex.java b/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompilerReferenceIndex.java index 1718a31be0c3..0baed9958e3e 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompilerReferenceIndex.java +++ b/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompilerReferenceIndex.java @@ -273,7 +273,7 @@ public class CompilerReferenceIndex { throws IOException { super(extension, createIndexStorage(extension.getKeyDescriptor(), extension.getValueExternalizer(), extension.getName(), indexDir, readOnly), - readOnly ? null : new PersistentMapBasedForwardIndex(new File(indexDir, extension.getName().getName() + ".inputs")), + readOnly ? null : new PersistentMapBasedForwardIndex(new File(indexDir, extension.getName().getName() + ".inputs"), false), readOnly ? null : new KeyCollectionForwardIndexAccessor<>(extension)); } diff --git a/platform/lang-impl/src/com/intellij/util/indexing/VfsAwareMapReduceIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/VfsAwareMapReduceIndex.java index e4b7a551e699..548780555bbd 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/VfsAwareMapReduceIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/VfsAwareMapReduceIndex.java @@ -437,7 +437,7 @@ public class VfsAwareMapReduceIndex extends MapReduceIndex) return new EmptyForwardIndex(); // indexStorage and forwardIndex are same here File indexStorageFile = IndexInfrastructure.getInputIndexStorageFile((ID)indexExtension.getName()); - return new PersistentMapBasedForwardIndex(indexStorageFile, false); + return new PersistentMapBasedForwardIndex(indexStorageFile, false, false); } private static boolean shouldCreateForwardIndex(@NotNull IndexExtension indexExtension) { diff --git a/platform/lang-impl/src/com/intellij/util/indexing/hash/FileContentHashIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/hash/FileContentHashIndex.java index ad65ba28491e..e66f22cb589d 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/hash/FileContentHashIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/hash/FileContentHashIndex.java @@ -17,7 +17,7 @@ public class FileContentHashIndex extends VfsAwareMapReduceIndex storage) throws IOException { super(extension, storage, - new PersistentMapBasedForwardIndex(IndexInfrastructure.getInputIndexStorageFile(extension.getName())), + new PersistentMapBasedForwardIndex(IndexInfrastructure.getInputIndexStorageFile(extension.getName()), false), new MapForwardIndexAccessor<>(new InputMapExternalizer<>(extension)), null, null); } diff --git a/platform/lang-impl/src/com/intellij/util/indexing/snapshot/SnapshotInputMappings.java b/platform/lang-impl/src/com/intellij/util/indexing/snapshot/SnapshotInputMappings.java index 7d1f6f33de10..d5d1c07795e8 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/snapshot/SnapshotInputMappings.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/snapshot/SnapshotInputMappings.java @@ -208,7 +208,7 @@ public class SnapshotInputMappings implements UpdatableSnapsh if (SharedIndicesData.ourFileSharedIndicesEnabled && !SharedIndicesData.DO_CHECKS) return null; final File saved = new File(IndexInfrastructure.getPersistentIndexRootDir(myIndexId), "values"); try { - return new PersistentMapBasedForwardIndex(saved); + return new PersistentMapBasedForwardIndex(saved, false); } catch (IOException ex) { IOUtil.deleteAllFilesStartingWith(saved); diff --git a/platform/util/src/com/intellij/util/indexing/impl/forward/PersistentMapBasedForwardIndex.java b/platform/util/src/com/intellij/util/indexing/impl/forward/PersistentMapBasedForwardIndex.java index 76d2ea5e0654..d60515485170 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/forward/PersistentMapBasedForwardIndex.java +++ b/platform/util/src/com/intellij/util/indexing/impl/forward/PersistentMapBasedForwardIndex.java @@ -20,26 +20,31 @@ public class PersistentMapBasedForwardIndex implements ForwardIndex { @NotNull private final File myMapFile; private final boolean myUseChunks; + private final boolean myReadOnly; - public PersistentMapBasedForwardIndex(@NotNull File mapFile) throws IOException { - this(mapFile, true); + public PersistentMapBasedForwardIndex(@NotNull File mapFile, boolean isReadOnly) throws IOException { + this(mapFile, true, isReadOnly); } - public PersistentMapBasedForwardIndex(@NotNull File mapFile, boolean useChunks) throws IOException { + public PersistentMapBasedForwardIndex(@NotNull File mapFile, boolean useChunks, boolean isReadOnly) throws IOException { myPersistentMap = createMap(mapFile); myMapFile = mapFile; myUseChunks = useChunks; + myReadOnly = isReadOnly; } @NotNull protected PersistentHashMap createMap(File file) throws IOException { Boolean oldHasNoChunksValue = PersistentHashMapValueStorage.CreationTimeOptions.HAS_NO_CHUNKS.get(); PersistentHashMapValueStorage.CreationTimeOptions.HAS_NO_CHUNKS.set(!myUseChunks); + Boolean previousReadOnly = PersistentHashMapValueStorage.CreationTimeOptions.READONLY.get(); + PersistentHashMapValueStorage.CreationTimeOptions.READONLY.set(myReadOnly); try { return new PersistentHashMap<>(file, EnumeratorIntegerDescriptor.INSTANCE, ByteSequenceDataExternalizer.INSTANCE); } finally { PersistentHashMapValueStorage.CreationTimeOptions.HAS_NO_CHUNKS.set(oldHasNoChunksValue); + PersistentHashMapValueStorage.CreationTimeOptions.READONLY.set(previousReadOnly); } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPathsIndex.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPathsIndex.java index 190ea7c6f726..e1cdfdee9c1c 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPathsIndex.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPathsIndex.java @@ -59,7 +59,7 @@ public class VcsLogPathsIndex extends VcsLogFullDetailsIndex>> createdForwardIndex() throws IOException { if (!isPathsForwardIndexRequired()) return null; - return Pair.create(new PersistentMapBasedForwardIndex(myStorageId.getStorageFile(myName + ".idx")), + return Pair.create(new PersistentMapBasedForwardIndex(myStorageId.getStorageFile(myName + ".idx"), false), new KeyCollectionForwardIndexAccessor>(new IntCollectionDataExternalizer()) { @Nullable @Override diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogUserIndex.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogUserIndex.java index 9df80592203f..5d553d13d6a5 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogUserIndex.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogUserIndex.java @@ -52,7 +52,7 @@ public class VcsLogUserIndex extends VcsLogFullDetailsIndex> createdForwardIndex() throws IOException { - return Pair.create(new PersistentMapBasedForwardIndex(myStorageId.getStorageFile(myName + ".idx")), + return Pair.create(new PersistentMapBasedForwardIndex(myStorageId.getStorageFile(myName + ".idx"), false ), new KeyCollectionForwardIndexAccessor<>(new IntCollectionDataExternalizer())); }