[vcs-log] make index version depend on storage version

This commit is contained in:
Julia Beliaeva
2016-09-20 00:15:17 +03:00
parent 8564c3413f
commit 37af75f498
5 changed files with 18 additions and 10 deletions
@@ -52,7 +52,7 @@ public class VcsLogStorageImpl implements Disposable, VcsLogStorage {
@NotNull private static final String REFS_STORAGE = "refs";
@NotNull public static final VcsLogStorage EMPTY = new EmptyLogStorage();
private static final int VERSION = 5;
public static final int VERSION = 5;
@NotNull private static final String ROOT_STORAGE_KIND = "roots";
private static final int ROOTS_STORAGE_VERSION = 0;
@@ -37,17 +37,18 @@ import java.util.Set;
public class VcsLogMessagesTrigramIndex extends VcsLogFullDetailsIndex<Void> {
private static final Logger LOG = Logger.getInstance(VcsLogMessagesTrigramIndex.class);
private static final int VERSION = 0;
private static final String TRIGRAMS = "trigrams";
private static final int VALUE = 239;
@NotNull private final PersistentHashMap<Integer, Integer> myNoTrigramsCommits;
public VcsLogMessagesTrigramIndex(@NotNull String logId, @NotNull Disposable disposableParent) throws IOException {
super(logId, TRIGRAMS, VERSION, new TrigramMessageIndexer(), ScalarIndexExtension.VOID_DATA_EXTERNALIZER, disposableParent);
super(logId, TRIGRAMS, VcsLogPersistentIndex.getVersion(), new TrigramMessageIndexer(), ScalarIndexExtension.VOID_DATA_EXTERNALIZER,
disposableParent);
myNoTrigramsCommits =
PersistentUtil.createPersistentHashMap(EnumeratorIntegerDescriptor.INSTANCE, "index-no-" + TRIGRAMS, logId, VERSION);
PersistentUtil.createPersistentHashMap(EnumeratorIntegerDescriptor.INSTANCE, "index-no-" + TRIGRAMS, logId,
VcsLogPersistentIndex.getVersion());
}
@Nullable
@@ -44,7 +44,6 @@ import java.util.stream.Collectors;
public class VcsLogPathsIndex extends VcsLogFullDetailsIndex<Integer> {
private static final Logger LOG = Logger.getInstance(VcsLogPathsIndex.class);
private static final String NAME = "paths";
private static final int VERSION = 0;
private static final int VALUE = 239;
@NotNull private final PersistentHashMap<Integer, Integer> myEmptyCommits;
@@ -53,11 +52,13 @@ public class VcsLogPathsIndex extends VcsLogFullDetailsIndex<Integer> {
public VcsLogPathsIndex(@NotNull String logId,
@NotNull Set<VirtualFile> roots,
@NotNull Disposable disposableParent) throws IOException {
super(logId, NAME, VERSION, new PathsIndexer(
PersistentUtil.createPersistentEnumerator(EnumeratorStringDescriptor.INSTANCE, "index-paths-ids", logId, VERSION), roots),
super(logId, NAME, VcsLogPersistentIndex.getVersion(), new PathsIndexer(
PersistentUtil.createPersistentEnumerator(EnumeratorStringDescriptor.INSTANCE, "index-paths-ids", logId,
VcsLogPersistentIndex.getVersion()), roots),
new NullableIntKeyDescriptor(), disposableParent);
myEmptyCommits = PersistentUtil.createPersistentHashMap(EnumeratorIntegerDescriptor.INSTANCE, "index-no-" + NAME, logId, VERSION);
myEmptyCommits = PersistentUtil.createPersistentHashMap(EnumeratorIntegerDescriptor.INSTANCE, "index-no-" + NAME, logId,
VcsLogPersistentIndex.getVersion());
myPathsIndexer = (PathsIndexer)myIndexer;
}
@@ -43,6 +43,7 @@ import com.intellij.util.io.PersistentMap;
import com.intellij.vcs.log.*;
import com.intellij.vcs.log.data.InMemoryMap;
import com.intellij.vcs.log.data.TroveUtil;
import com.intellij.vcs.log.data.VcsLogStorageImpl;
import com.intellij.vcs.log.data.VcsUserRegistryImpl;
import com.intellij.vcs.log.ui.filter.VcsLogUserFilterImpl;
import com.intellij.vcs.log.util.PersistentUtil;
@@ -60,6 +61,7 @@ import java.util.stream.IntStream;
public class VcsLogPersistentIndex implements VcsLogIndex, Disposable {
private static final Logger LOG = Logger.getInstance(VcsLogPersistentIndex.class);
private static final int BATCH_SIZE = 1000;
private static final int VERSION = 0;
@NotNull private final Project myProject;
@NotNull private final Consumer<Exception> myFatalErrorsConsumer;
@@ -110,6 +112,10 @@ public class VcsLogPersistentIndex implements VcsLogIndex, Disposable {
Disposer.register(disposableParent, this);
}
public static int getVersion() {
return VcsLogStorageImpl.VERSION + VERSION;
}
@Nullable
private <I extends VcsLogFullDetailsIndex> I createIndex(@NotNull ThrowableComputable<I, IOException> computable) {
try {
@@ -34,13 +34,13 @@ import java.util.Set;
public class VcsLogUserIndex extends VcsLogFullDetailsIndex<Void> {
private static final Logger LOG = Logger.getInstance(VcsLogUserIndex.class);
private static final int VERSION = 0;
@NotNull private final VcsUserRegistryImpl myUserRegistry;
public VcsLogUserIndex(@NotNull String logId,
@NotNull VcsUserRegistryImpl userRegistry,
@NotNull Disposable disposableParent) throws IOException {
super(logId, "users", VERSION, new UserIndexer(userRegistry), ScalarIndexExtension.VOID_DATA_EXTERNALIZER, disposableParent);
super(logId, "users", VcsLogPersistentIndex.getVersion(), new UserIndexer(userRegistry), ScalarIndexExtension.VOID_DATA_EXTERNALIZER,
disposableParent);
myUserRegistry = userRegistry;
}