move debug index id field

GitOrigin-RevId: c16d843480ff6079ff8584ce1f725d5f26080aaa
This commit is contained in:
Dmitry Batkovich
2019-05-17 16:12:46 +03:00
committed by intellij-monorepo-bot
parent daa8dbe15b
commit 909f2e022f
3 changed files with 9 additions and 8 deletions
@@ -18,6 +18,7 @@ package com.intellij.util.indexing.impl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.hash.LinkedHashMap;
import com.intellij.util.indexing.IndexId;
import com.intellij.util.io.KeyDescriptor;
import java.util.Collection;
@@ -26,6 +27,8 @@ import java.util.Formatter;
public class DebugAssertions {
private static final Logger LOG = Logger.getInstance(DebugAssertions.class);
public static final ThreadLocal<IndexId> DEBUG_INDEX_ID = new ThreadLocal<>();
@SuppressWarnings("StaticNonFinalField")
public static volatile boolean DEBUG = SystemProperties.getBooleanProperty(
"intellij.idea.indices.debug",
@@ -236,11 +236,11 @@ public abstract class MapReduceIndex<Key,Value, Input> implements InvertedIndex<
if (myDisposed) {
return new ValueContainerImpl<>();
}
ValueContainerImpl.ourDebugIndexInfo.set(myIndexId);
DebugAssertions.DEBUG_INDEX_ID.set(myIndexId);
return myStorage.read(key);
}
finally {
ValueContainerImpl.ourDebugIndexInfo.set(null);
DebugAssertions.DEBUG_INDEX_ID.set(null);
lock.unlock();
}
}
@@ -354,9 +354,9 @@ public abstract class MapReduceIndex<Key,Value, Input> implements InvertedIndex<
@NotNull UpdateData<Key, Value> updateData) throws StorageException {
getWriteLock().lock();
try {
IndexId oldIndexId = ValueContainerImpl.ourDebugIndexInfo.get();
IndexId oldIndexId = DebugAssertions.DEBUG_INDEX_ID.get();
try {
ValueContainerImpl.ourDebugIndexInfo.set(myIndexId);
DebugAssertions.DEBUG_INDEX_ID.set(myIndexId);
boolean hasDifference = updateData.iterateKeys(myAddedKeyProcessor, myUpdatedKeyProcessor, myRemovedKeyProcessor);
if (hasDifference) updateData.updateForwardIndex();
}
@@ -367,7 +367,7 @@ public abstract class MapReduceIndex<Key,Value, Input> implements InvertedIndex<
throw new StorageException(e);
}
finally {
ValueContainerImpl.ourDebugIndexInfo.set(oldIndexId);
DebugAssertions.DEBUG_INDEX_ID.set(oldIndexId);
}
}
finally {
@@ -98,8 +98,6 @@ class ValueContainerImpl<Value> extends UpdatableValueContainer<Value> implement
return myInputIdMapping != null ? myInputIdMapping instanceof THashMap ? ((THashMap)myInputIdMapping).size(): 1 : 0;
}
static final ThreadLocal<IndexId> ourDebugIndexInfo = new ThreadLocal<>();
@Override
public void removeAssociatedValue(int inputId) {
if (myInputIdMapping == null) return;
@@ -114,7 +112,7 @@ class ValueContainerImpl<Value> extends UpdatableValueContainer<Value> implement
valueObjects = new SmartList<>();
}
else if (DebugAssertions.DEBUG) {
LOG.error("Expected only one value per-inputId for " + ourDebugIndexInfo.get(), String.valueOf(fileSetObjects.get(0)), String.valueOf(value));
LOG.error("Expected only one value per-inputId for " + DebugAssertions.DEBUG_INDEX_ID.get(), String.valueOf(fileSetObjects.get(0)), String.valueOf(value));
}
fileSetObjects.add(valueIterator.getFileSetObject());
valueObjects.add(value);