mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] extract requestRebuild and overwrite it in log indexes to not use FileBasedIndex
This commit is contained in:
@@ -94,7 +94,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
|
||||
flush();
|
||||
} catch (StorageException e) {
|
||||
LOG.info(e);
|
||||
FileBasedIndex.getInstance().requestRebuild(myIndexId);
|
||||
requestRebuild(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -585,9 +585,9 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (application.isUnitTestMode() || application.isHeadlessEnvironment()) {
|
||||
// avoid deadlock due to synchronous update in DumbServiceImpl#queueTask
|
||||
application.invokeLater(() -> 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<Key, Value, Input> implements UpdatableIndex<Key,Val
|
||||
};
|
||||
}
|
||||
|
||||
protected void requestRebuild(@Nullable Exception ex) {
|
||||
if (ex == null) {
|
||||
FileBasedIndex.getInstance().requestRebuild(myIndexId);
|
||||
}
|
||||
else {
|
||||
FileBasedIndex.getInstance().requestRebuild(myIndexId, ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected UpdateData<Key, Value> buildUpdateData(Map<Key, Value> data, NotNullComputable<Collection<Key>> oldKeysGetter, int savedInputId) {
|
||||
return new SimpleUpdateData(myIndexId, savedInputId, data, oldKeysGetter);
|
||||
}
|
||||
|
||||
@@ -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<T> implements Disposable {
|
||||
@NotNull private final String myLogId;
|
||||
@NotNull private final String myName;
|
||||
@NotNull protected final DataIndexer<Integer, T, VcsFullCommitDetails> myIndexer;
|
||||
@NotNull private final FatalErrorHandler myFatalErrorHandler;
|
||||
|
||||
public VcsLogFullDetailsIndex(@NotNull String logId,
|
||||
@NotNull String name,
|
||||
final int version,
|
||||
@NotNull DataIndexer<Integer, T, VcsFullCommitDetails> indexer,
|
||||
@NotNull DataExternalizer<T> 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<T> 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<Integer, T, VcsFullCommitDetails> {
|
||||
|
||||
+5
-2
@@ -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<Void> {
|
||||
|
||||
@NotNull private final PersistentSet<Integer> 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,
|
||||
|
||||
@@ -61,7 +61,7 @@ public class VcsLogPathsIndex extends VcsLogFullDetailsIndex<Integer> {
|
||||
@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());
|
||||
|
||||
+1
-1
@@ -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));
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class VcsLogUserIndex extends VcsLogFullDetailsIndex<Void> {
|
||||
@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);
|
||||
|
||||
Reference in New Issue
Block a user