From 0ff6d44aa76cf60dafacd9d3ec16054433b31516 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Thu, 13 Oct 2016 20:57:01 +0300 Subject: [PATCH] [vcs-log] extract requestRebuild and overwrite it in log indexes to not use FileBasedIndex --- .../intellij/util/indexing/MapReduceIndex.java | 15 ++++++++++++--- .../log/data/index/VcsLogFullDetailsIndex.java | 9 +++++++++ .../data/index/VcsLogMessagesTrigramIndex.java | 7 +++++-- .../vcs/log/data/index/VcsLogPathsIndex.java | 2 +- .../vcs/log/data/index/VcsLogPersistentIndex.java | 2 +- .../vcs/log/data/index/VcsLogUserIndex.java | 2 +- 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java index e61f70b4ffbb..602f0defcdad 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java @@ -94,7 +94,7 @@ public class MapReduceIndex implements UpdatableIndex implements UpdatableIndex FileBasedIndex.getInstance().requestRebuild(myIndexId, ex), ModalityState.any()); + application.invokeLater(() -> requestRebuild(ex), ModalityState.any()); } else { - FileBasedIndex.getInstance().requestRebuild(myIndexId, ex); + requestRebuild(ex); } return Boolean.FALSE; } @@ -596,6 +596,15 @@ public class MapReduceIndex implements UpdatableIndex buildUpdateData(Map data, NotNullComputable> oldKeysGetter, int savedInputId) { return new SimpleUpdateData(myIndexId, savedInputId, data, oldKeysGetter); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogFullDetailsIndex.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogFullDetailsIndex.java index 1ac482522e6f..24659ac7a733 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogFullDetailsIndex.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogFullDetailsIndex.java @@ -22,6 +22,7 @@ import com.intellij.util.PathUtilRt; import com.intellij.util.indexing.*; import com.intellij.util.io.*; import com.intellij.vcs.log.VcsFullCommitDetails; +import com.intellij.vcs.log.impl.FatalErrorHandler; import com.intellij.vcs.log.util.PersistentUtil; import gnu.trove.TIntHashSet; import org.jetbrains.annotations.NotNull; @@ -41,18 +42,21 @@ public class VcsLogFullDetailsIndex implements Disposable { @NotNull private final String myLogId; @NotNull private final String myName; @NotNull protected final DataIndexer myIndexer; + @NotNull private final FatalErrorHandler myFatalErrorHandler; public VcsLogFullDetailsIndex(@NotNull String logId, @NotNull String name, final int version, @NotNull DataIndexer indexer, @NotNull DataExternalizer externalizer, + @NotNull FatalErrorHandler fatalErrorHandler, @NotNull Disposable disposableParent) throws IOException { myID = ID.create(name); myName = name; myLogId = logId; myIndexer = indexer; + myFatalErrorHandler = fatalErrorHandler; MyMapReduceIndex result = IOUtil.openCleanOrResetBroken(() -> new MyMapReduceIndex(myIndexer, externalizer, version), () -> { @@ -193,6 +197,11 @@ public class VcsLogFullDetailsIndex implements Disposable { public void markCorrupted() { myInputsIndex.markCorrupted(); } + + @Override + protected void requestRebuild(@Nullable Exception ex) { + myFatalErrorHandler.consume(this, ex != null ? ex : new Exception("Index rebuild requested")); + } } private class MyIndexExtension extends IndexExtension { diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogMessagesTrigramIndex.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogMessagesTrigramIndex.java index 4228950f2ac2..03a80d3cf63b 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogMessagesTrigramIndex.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogMessagesTrigramIndex.java @@ -24,6 +24,7 @@ import com.intellij.util.indexing.StorageException; import com.intellij.util.indexing.ValueContainer; import com.intellij.util.io.EnumeratorIntegerDescriptor; import com.intellij.vcs.log.VcsFullCommitDetails; +import com.intellij.vcs.log.impl.FatalErrorHandler; import com.intellij.vcs.log.util.PersistentSet; import com.intellij.vcs.log.util.PersistentUtil; import gnu.trove.THashMap; @@ -40,9 +41,11 @@ public class VcsLogMessagesTrigramIndex extends VcsLogFullDetailsIndex { @NotNull private final PersistentSet myNoTrigramsCommits; - public VcsLogMessagesTrigramIndex(@NotNull String logId, @NotNull Disposable disposableParent) throws IOException { + public VcsLogMessagesTrigramIndex(@NotNull String logId, + @NotNull FatalErrorHandler fatalErrorHandler, + @NotNull Disposable disposableParent) throws IOException { super(logId, TRIGRAMS, VcsLogPersistentIndex.getVersion(), new TrigramMessageIndexer(), ScalarIndexExtension.VOID_DATA_EXTERNALIZER, - disposableParent); + fatalErrorHandler, disposableParent); myNoTrigramsCommits = PersistentUtil.createPersistentSet(EnumeratorIntegerDescriptor.INSTANCE, "index-no-" + TRIGRAMS, logId, 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 7dabdfa0bded..76c0dc173fd8 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 @@ -61,7 +61,7 @@ public class VcsLogPathsIndex extends VcsLogFullDetailsIndex { @NotNull FatalErrorHandler fatalErrorHandler, @NotNull Disposable disposableParent) throws IOException { super(logId, NAME, VcsLogPersistentIndex.getVersion(), new PathsIndexer(createPathsEnumerator(logId), roots), - new NullableIntKeyDescriptor(), disposableParent); + new NullableIntKeyDescriptor(), fatalErrorHandler, disposableParent); myEmptyCommits = PersistentUtil.createPersistentSet(EnumeratorIntegerDescriptor.INSTANCE, "index-no-" + NAME, logId, VcsLogPersistentIndex.getVersion()); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPersistentIndex.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPersistentIndex.java index 402266529a5a..3ca28ee70b36 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPersistentIndex.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPersistentIndex.java @@ -102,7 +102,7 @@ public class VcsLogPersistentIndex implements VcsLogIndex, Disposable { String logId = PersistentUtil.calcLogId(myProject, providers); myMessagesIndex = createMap(EnumeratorStringDescriptor.INSTANCE, "messages", logId, 0); - myTrigramIndex = createIndex(() -> new VcsLogMessagesTrigramIndex(logId, this)); + myTrigramIndex = createIndex(() -> new VcsLogMessagesTrigramIndex(logId, fatalErrorsConsumer, this)); myUserIndex = createIndex(() -> new VcsLogUserIndex(logId, myUserRegistry, fatalErrorsConsumer, this)); myPathsIndex = createIndex(() -> new VcsLogPathsIndex(logId, myRoots, fatalErrorsConsumer, this)); 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 405b75f0b09d..7a448b9c171c 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 @@ -45,7 +45,7 @@ public class VcsLogUserIndex extends VcsLogFullDetailsIndex { @NotNull FatalErrorHandler consumer, @NotNull Disposable disposableParent) throws IOException { super(logId, "users", VcsLogPersistentIndex.getVersion(), new UserIndexer(userRegistry), ScalarIndexExtension.VOID_DATA_EXTERNALIZER, - disposableParent); + consumer, disposableParent); myUserRegistry = userRegistry; ((UserIndexer)myIndexer).setFatalErrorConsumer(e -> { consumer.consume(this, e);