mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'db/index-id'
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.index;
|
||||
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.indexing.*;
|
||||
import com.intellij.util.indexing.impl.IndexStorage;
|
||||
@@ -46,11 +47,11 @@ public class StringIndex {
|
||||
final PersistentHashMap<Integer, Collection<String>> inputIndex,
|
||||
boolean failOnRebuildRequest)
|
||||
throws IOException {
|
||||
ID<String, String> id = ID.create(testName + "string_index");
|
||||
IndexId<String, String> id = IndexId.create(testName + "string_index");
|
||||
IndexExtension<String, String, PathContentPair> extension = new IndexExtension<String, String, PathContentPair>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public ID<String, String> getName() {
|
||||
public IndexId<String, String> getName() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -77,13 +78,18 @@ public class StringIndex {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
myIndex = new VfsAwareMapReduceIndex<String, String, PathContentPair>(extension, storage, new MapBasedForwardIndex<String, String>(extension) {
|
||||
myIndex = new MapReduceIndex<String, String, PathContentPair>(extension, storage, new MapBasedForwardIndex<String, String>(extension) {
|
||||
@NotNull
|
||||
@Override
|
||||
public PersistentHashMap<Integer, Collection<String>> createMap() throws IOException {
|
||||
return inputIndex;
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
public void checkCanceled() {
|
||||
ProgressManager.checkCanceled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestRebuild(@NotNull Exception ex) {
|
||||
if (failOnRebuildRequest) {
|
||||
|
||||
+7
-7
@@ -21,8 +21,8 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.indexing.ID;
|
||||
import com.intellij.util.indexing.IndexExtension;
|
||||
import com.intellij.util.indexing.IndexId;
|
||||
import com.intellij.util.indexing.InvertedIndex;
|
||||
import com.intellij.util.indexing.impl.*;
|
||||
import com.intellij.util.io.*;
|
||||
@@ -43,7 +43,7 @@ public class CompilerBackwardReferenceIndex {
|
||||
private final static String NAME_ENUM_TAB = "name.tab";
|
||||
|
||||
private static final String VERSION_FILE = "version";
|
||||
private final Map<ID<?, ?>, InvertedIndex<?, ?, CompiledFileData>> myIndices;
|
||||
private final Map<IndexId<?, ?>, InvertedIndex<?, ?, CompiledFileData>> myIndices;
|
||||
private final NameEnumerator myNameEnumerator;
|
||||
private final PersistentStringEnumerator myFilePathEnumerator;
|
||||
private final File myIndicesDir;
|
||||
@@ -102,7 +102,7 @@ public class CompilerBackwardReferenceIndex {
|
||||
return myIndices.values();
|
||||
}
|
||||
|
||||
public <K, V> InvertedIndex<K, V, CompiledFileData> get(ID<K, V> key) {
|
||||
public <K, V> InvertedIndex<K, V, CompiledFileData> get(IndexId<K, V> key) {
|
||||
//noinspection unchecked
|
||||
return (InvertedIndex<K, V, CompiledFileData>)myIndices.get(key);
|
||||
}
|
||||
@@ -255,8 +255,8 @@ public class CompilerBackwardReferenceIndex {
|
||||
@NotNull
|
||||
@Override
|
||||
public PersistentHashMap<Integer, Collection<Key>> createMap() throws IOException {
|
||||
ID<Key, Value> id = extension.getName();
|
||||
return new PersistentHashMap<>(new File(indexDir, id + ".inputs"),
|
||||
IndexId<Key, Value> id = extension.getName();
|
||||
return new PersistentHashMap<>(new File(indexDir, id.getName() + ".inputs"),
|
||||
EnumeratorIntegerDescriptor.INSTANCE,
|
||||
new InputIndexDataExternalizer<>(extension.getKeyDescriptor(),
|
||||
id));
|
||||
@@ -277,10 +277,10 @@ public class CompilerBackwardReferenceIndex {
|
||||
|
||||
private static <Key, Value> IndexStorage<Key, Value> createIndexStorage(@NotNull KeyDescriptor<Key> keyDescriptor,
|
||||
@NotNull DataExternalizer<Value> valueExternalizer,
|
||||
@NotNull ID<Key, Value> indexId,
|
||||
@NotNull IndexId<Key, Value> indexId,
|
||||
@NotNull File indexDir,
|
||||
boolean readOnly) throws IOException {
|
||||
return new MapIndexStorage<Key, Value>(new File(indexDir, indexId.toString()),
|
||||
return new MapIndexStorage<Key, Value>(new File(indexDir, indexId.getName()),
|
||||
keyDescriptor,
|
||||
valueExternalizer,
|
||||
16 * 1024,
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
package org.jetbrains.jps.backwardRefs.index;
|
||||
|
||||
import com.intellij.openapi.util.io.DataInputOutputUtilRt;
|
||||
import com.intellij.util.indexing.DataIndexer;
|
||||
import com.intellij.util.indexing.ID;
|
||||
import com.intellij.util.indexing.IndexExtension;
|
||||
import com.intellij.util.indexing.*;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
import com.intellij.util.io.DataInputOutputUtil;
|
||||
import com.intellij.util.io.KeyDescriptor;
|
||||
@@ -39,10 +37,10 @@ public class CompilerIndices {
|
||||
//TODO manage version separately
|
||||
public final static int VERSION = 5;
|
||||
|
||||
public final static ID<LightRef, Integer> BACK_USAGES = ID.create("back.refs");
|
||||
public final static ID<LightRef, Collection<LightRef>> BACK_HIERARCHY = ID.create("back.hierarchy");
|
||||
public final static ID<LightRef, Void> BACK_CLASS_DEF = ID.create("back.class.def");
|
||||
public final static ID<SignatureData, Collection<LightRef>> BACK_MEMBER_SIGN = ID.create("back.member.sign");
|
||||
public final static IndexId<LightRef, Integer> BACK_USAGES = IndexId.create("back.refs");
|
||||
public final static IndexId<LightRef, Collection<LightRef>> BACK_HIERARCHY = IndexId.create("back.hierarchy");
|
||||
public final static IndexId<LightRef, Void> BACK_CLASS_DEF = IndexId.create("back.class.def");
|
||||
public final static IndexId<SignatureData, Collection<LightRef>> BACK_MEMBER_SIGN = IndexId.create("back.member.sign");
|
||||
|
||||
public static List<IndexExtension<?, ?, CompiledFileData>> getIndices() {
|
||||
return Arrays.asList(createBackwardClassDefinitionExtension(),
|
||||
@@ -59,7 +57,7 @@ public class CompilerIndices {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ID<LightRef, Integer> getName() {
|
||||
public IndexId<LightRef, Integer> getName() {
|
||||
return BACK_USAGES;
|
||||
}
|
||||
|
||||
@@ -104,7 +102,7 @@ public class CompilerIndices {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ID<LightRef, Collection<LightRef>> getName() {
|
||||
public IndexId<LightRef, Collection<LightRef>> getName() {
|
||||
return BACK_HIERARCHY;
|
||||
}
|
||||
|
||||
@@ -133,7 +131,7 @@ public class CompilerIndices {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ID<LightRef, Void> getName() {
|
||||
public IndexId<LightRef, Void> getName() {
|
||||
return BACK_CLASS_DEF;
|
||||
}
|
||||
|
||||
@@ -158,7 +156,7 @@ public class CompilerIndices {
|
||||
return new IndexExtension<SignatureData, Collection<LightRef>, CompiledFileData>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public ID<SignatureData, Collection<LightRef>> getName() {
|
||||
public IndexId<SignatureData, Collection<LightRef>> getName() {
|
||||
return BACK_MEMBER_SIGN;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.references
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vfs.CharsetToolkit
|
||||
import com.intellij.util.PathUtil
|
||||
import com.intellij.util.indexing.ID
|
||||
import com.intellij.util.indexing.IndexId
|
||||
import com.intellij.util.indexing.impl.MapIndexStorage
|
||||
import com.intellij.util.indexing.impl.MapReduceIndex
|
||||
import com.intellij.util.io.PersistentStringEnumerator
|
||||
@@ -168,7 +168,7 @@ abstract class ReferenceIndexTestBase : JpsBuildTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun <K, V> storage(index: CompilerBackwardReferenceIndex, id: ID<K, V>) = (index[id] as MapReduceIndex<K, V, CompiledFileData>).storage as MapIndexStorage<K, V>
|
||||
private fun <K, V> storage(index: CompilerBackwardReferenceIndex, id: IndexId<K, V>) = (index[id] as MapReduceIndex<K, V, CompiledFileData>).storage as MapIndexStorage<K, V>
|
||||
|
||||
private fun getTestDataPath() = testDataRootPath + "/" + getTestName(true) + "/"
|
||||
|
||||
|
||||
+6
-4
@@ -31,12 +31,11 @@ import java.io.*;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Feb 12, 2008
|
||||
*/
|
||||
public class ID<K, V> {
|
||||
public class ID<K, V> extends IndexId<K,V> {
|
||||
private static final ConcurrentIntObjectMap<ID> ourRegistry = ContainerUtil.createConcurrentIntObjectMap();
|
||||
private static final TObjectIntHashMap<String> ourNameToIdRegistry = new TObjectIntHashMap<String>();
|
||||
static final int MAX_NUMBER_OF_INDICES = Short.MAX_VALUE;
|
||||
|
||||
private final String myName;
|
||||
private final short myUniqueId;
|
||||
|
||||
static {
|
||||
@@ -83,7 +82,7 @@ public class ID<K, V> {
|
||||
}
|
||||
|
||||
protected ID(String name) {
|
||||
myName = name;
|
||||
super(name);
|
||||
myUniqueId = stringToId(name);
|
||||
|
||||
final ID old = ourRegistry.put(myUniqueId, this);
|
||||
@@ -155,8 +154,11 @@ public class ID<K, V> {
|
||||
return (int)myUniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consider to use {@link ID#getName()} instead of this method
|
||||
*/
|
||||
public String toString() {
|
||||
return myName;
|
||||
return getName();
|
||||
}
|
||||
|
||||
public int getUniqueId() {
|
||||
@@ -32,6 +32,10 @@ public abstract class FileBasedIndexExtension<K, V> extends IndexExtension<K, V,
|
||||
public static final ExtensionPointName<FileBasedIndexExtension> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.fileBasedIndex");
|
||||
public static final int DEFAULT_CACHE_SIZE = 1024;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public abstract ID<K, V> getName();
|
||||
|
||||
@NotNull
|
||||
public abstract FileBasedIndex.InputFilter getInputFilter();
|
||||
|
||||
|
||||
@@ -538,7 +538,7 @@ public class StubIndexImpl extends StubIndex implements PersistentStateComponent
|
||||
final Set<String> indicesToDrop =
|
||||
new HashSet<>(myPreviouslyRegistered != null ? myPreviouslyRegistered.registeredIndices : Collections.emptyList());
|
||||
for (ID<?, ?> key : state.myIndices.keySet()) {
|
||||
indicesToDrop.remove(key.toString());
|
||||
indicesToDrop.remove(key.getName());
|
||||
}
|
||||
|
||||
if (!indicesToDrop.isEmpty()) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class StubIndexState {
|
||||
|
||||
public StubIndexState(@NotNull Collection<StubIndexKey<?, ?>> keys) {
|
||||
for (StubIndexKey key : keys) {
|
||||
registeredIndices.add(key.toString());
|
||||
registeredIndices.add(key.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent,
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
for (ID<?, ?> key : ids) {
|
||||
indicesToDrop.remove(key.toString());
|
||||
indicesToDrop.remove(key.getName());
|
||||
}
|
||||
if (!indicesToDrop.isEmpty()) {
|
||||
LOG.info("Dropping indices:" + StringUtil.join(indicesToDrop, ","));
|
||||
@@ -441,7 +441,7 @@ public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent,
|
||||
try (DataOutputStream os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(registeredIndicesFile)))) {
|
||||
os.writeInt(ids.size());
|
||||
for (ID<?, ?> id : ids) {
|
||||
IOUtil.writeString(id.toString(), os);
|
||||
IOUtil.writeString(id.getName(), os);
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
|
||||
@@ -31,8 +31,8 @@ public class IndexAccessValidator {
|
||||
final ID<?, ?> alreadyProcessingIndex = ourAlreadyProcessingIndices.get();
|
||||
if (alreadyProcessingIndex != null && alreadyProcessingIndex != indexKey) {
|
||||
final String message = MessageFormat.format("Accessing ''{0}'' during processing ''{1}''. Nested different indices processing may cause deadlock",
|
||||
indexKey.toString(),
|
||||
alreadyProcessingIndex.toString());
|
||||
indexKey.getName(),
|
||||
alreadyProcessingIndex.getUniqueId());
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) throw new RuntimeException(message);
|
||||
Logger.getInstance(FileBasedIndexImpl.class).error(message); // RuntimeException to skip rebuild
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class IndexInfrastructure {
|
||||
|
||||
@NotNull
|
||||
public static File getStorageFile(@NotNull ID<?, ?> indexName) {
|
||||
return new File(getIndexRootDir(indexName), indexName.toString());
|
||||
return new File(getIndexRootDir(indexName), indexName.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -97,7 +97,7 @@ public class IndexInfrastructure {
|
||||
|
||||
@NotNull
|
||||
private static File getIndexDirectory(@NotNull ID<?, ?> indexName, boolean forVersion, String relativePath) {
|
||||
final String dirName = indexName.toString().toLowerCase(Locale.US);
|
||||
final String dirName = indexName.getName().toLowerCase(Locale.US);
|
||||
File indexDir;
|
||||
|
||||
if (indexName instanceof StubIndexKey) {
|
||||
|
||||
@@ -40,14 +40,14 @@ class SharedMapBasedForwardIndex<Key, Value> extends AbstractForwardIndex<Key,Va
|
||||
@Override
|
||||
public InputDataDiffBuilder<Key, Value> getDiffBuilder(int inputId) throws IOException {
|
||||
if (SharedIndicesData.ourFileSharedIndicesEnabled) {
|
||||
Collection<Key> keys = SharedIndicesData.recallFileData(inputId, myIndexId, mySnapshotIndexExternalizer);
|
||||
Collection<Key> keys = SharedIndicesData.recallFileData(inputId, (ID<Key, ?>)myIndexId, mySnapshotIndexExternalizer);
|
||||
if (myUnderlying != null) {
|
||||
Collection<Key> keysFromInputsIndex = myUnderlying.getInputsIndex().get(inputId);
|
||||
|
||||
if (keys == null && keysFromInputsIndex != null ||
|
||||
!DebugAssertions.equals(keysFromInputsIndex, keys, myKeyDescriptor)
|
||||
) {
|
||||
SharedIndicesData.associateFileData(inputId, myIndexId, keysFromInputsIndex, mySnapshotIndexExternalizer);
|
||||
SharedIndicesData.associateFileData(inputId, (ID<Key, ?>)myIndexId, keysFromInputsIndex, mySnapshotIndexExternalizer);
|
||||
if (keys != null) {
|
||||
DebugAssertions.error(
|
||||
"Unexpected indexing diff " + myIndexId + ", file:" + IndexInfrastructure.findFileById(PersistentFS.getInstance(), inputId)
|
||||
@@ -68,7 +68,7 @@ class SharedMapBasedForwardIndex<Key, Value> extends AbstractForwardIndex<Key,Va
|
||||
if (myUnderlying != null) myUnderlying.putData(inputId, keySeq);
|
||||
if (SharedIndicesData.ourFileSharedIndicesEnabled) {
|
||||
if (keySeq.isEmpty()) keySeq = null;
|
||||
SharedIndicesData.associateFileData(inputId, myIndexId, keySeq, mySnapshotIndexExternalizer);
|
||||
SharedIndicesData.associateFileData(inputId, (ID<Key, ?>)myIndexId, keySeq, mySnapshotIndexExternalizer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SnapshotInputMappings<Key, Value, Input> {
|
||||
private boolean myIsPsiBackedIndex;
|
||||
|
||||
public SnapshotInputMappings(IndexExtension<Key, Value, Input> indexExtension) throws IOException {
|
||||
myIndexId = indexExtension.getName();
|
||||
myIndexId = (ID<Key, Value>)indexExtension.getName();
|
||||
myIsPsiBackedIndex = indexExtension instanceof PsiDependentIndex;
|
||||
mySnapshotIndexExternalizer = VfsAwareMapReduceIndex.createInputsIndexExternalizer(indexExtension);
|
||||
myValueExternalizer = indexExtension.getValueExternalizer();
|
||||
|
||||
@@ -63,7 +63,10 @@ public class VfsAwareMapReduceIndex<Key, Value, Input> extends MapReduceIndex<Ke
|
||||
public VfsAwareMapReduceIndex(@NotNull IndexExtension<Key, Value, Input> extension,
|
||||
@NotNull IndexStorage<Key, Value> storage) throws IOException {
|
||||
super(extension, storage, getForwardIndex(extension));
|
||||
SharedIndicesData.registerIndex(myIndexId, extension);
|
||||
if (!(myIndexId instanceof ID<?, ?>)) {
|
||||
throw new IllegalArgumentException("myIndexId should be instance of com.intellij.util.indexing.ID");
|
||||
}
|
||||
SharedIndicesData.registerIndex((ID<Key, Value>)myIndexId, extension);
|
||||
mySnapshotInputMappings = myForwardIndex == null ?
|
||||
new SnapshotInputMappings<>(extension) :
|
||||
null;
|
||||
@@ -75,7 +78,7 @@ public class VfsAwareMapReduceIndex<Key, Value, Input> extends MapReduceIndex<Ke
|
||||
@NotNull IndexStorage<Key, Value> storage,
|
||||
@NotNull ForwardIndex<Key, Value> forwardIndex) throws IOException {
|
||||
super(extension, storage, forwardIndex);
|
||||
SharedIndicesData.registerIndex(myIndexId, extension);
|
||||
SharedIndicesData.registerIndex((ID<Key, Value>)myIndexId, extension);
|
||||
mySnapshotInputMappings = myForwardIndex == null ?
|
||||
new SnapshotInputMappings<>(extension) :
|
||||
null;
|
||||
@@ -133,17 +136,17 @@ public class VfsAwareMapReduceIndex<Key, Value, Input> extends MapReduceIndex<Ke
|
||||
|
||||
@Override
|
||||
public void setIndexedStateForFile(int fileId, @NotNull VirtualFile file) {
|
||||
IndexingStamp.setFileIndexedStateCurrent(fileId, myIndexId);
|
||||
IndexingStamp.setFileIndexedStateCurrent(fileId, (ID<?, ?>)myIndexId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetIndexedStateForFile(int fileId) {
|
||||
IndexingStamp.setFileIndexedStateOutdated(fileId, myIndexId);
|
||||
IndexingStamp.setFileIndexedStateOutdated(fileId, (ID<?, ?>)myIndexId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndexedStateForFile(int fileId, @NotNull VirtualFile file) {
|
||||
return IndexingStamp.isFileIndexedStateCurrent(fileId, myIndexId);
|
||||
return IndexingStamp.isFileIndexedStateCurrent(fileId, (ID<?, ?>)myIndexId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,7 +168,7 @@ public class VfsAwareMapReduceIndex<Key, Value, Input> extends MapReduceIndex<Ke
|
||||
|
||||
@Override
|
||||
protected void requestRebuild(@NotNull Exception ex) {
|
||||
Runnable action = () -> FileBasedIndex.getInstance().requestRebuild(myIndexId, ex);
|
||||
Runnable action = () -> FileBasedIndex.getInstance().requestRebuild((ID<?, ?>)myIndexId, ex);
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (application.isUnitTestMode() || application.isHeadlessEnvironment()) {
|
||||
// avoid deadlock due to synchronous update in DumbServiceImpl#queueTask
|
||||
@@ -229,7 +232,7 @@ public class VfsAwareMapReduceIndex<Key, Value, Input> extends MapReduceIndex<Ke
|
||||
|
||||
@NotNull
|
||||
private static <K> PersistentHashMap<Integer, Collection<K>> createIdToDataKeysIndex(@NotNull IndexExtension<K, ?, ?> extension) throws IOException {
|
||||
final File indexStorageFile = IndexInfrastructure.getInputIndexStorageFile(extension.getName());
|
||||
final File indexStorageFile = IndexInfrastructure.getInputIndexStorageFile((ID<?, ?>)extension.getName());
|
||||
return new PersistentHashMap<>(indexStorageFile, EnumeratorIntegerDescriptor.INSTANCE, createInputsIndexExternalizer(extension));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public abstract class IndexExtension<K, V, I> {
|
||||
@NotNull
|
||||
public abstract ID<K, V> getName();
|
||||
public abstract IndexId<K, V> getName();
|
||||
|
||||
@NotNull
|
||||
public abstract DataIndexer<K, V, I> getIndexer();
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.indexing;
|
||||
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public class IndexId<K, V> {
|
||||
private static final Map<String, IndexId<?, ?>> ourInstances = new THashMap<String, IndexId<?, ?>>();
|
||||
|
||||
@NotNull
|
||||
private final String myName;
|
||||
|
||||
protected IndexId(@NotNull String name) {myName = name;}
|
||||
|
||||
@NotNull
|
||||
public final String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public static <K, V> IndexId<K, V> create(String name) {
|
||||
@SuppressWarnings("unchecked")
|
||||
IndexId<K, V> id = (IndexId<K, V>)ourInstances.get(name);
|
||||
if (id == null) {
|
||||
ourInstances.put(name, id = new IndexId<K, V>(name));
|
||||
}
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package com.intellij.util.indexing.impl;
|
||||
|
||||
import com.intellij.util.indexing.ID;
|
||||
import com.intellij.util.indexing.IndexExtension;
|
||||
import com.intellij.util.indexing.IndexId;
|
||||
import com.intellij.util.io.KeyDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractForwardIndex<Key, Value> implements ForwardIndex<Key,Value> {
|
||||
protected final ID<Key, Value> myIndexId;
|
||||
protected final IndexId<Key, Value> myIndexId;
|
||||
protected final KeyDescriptor<Key> myKeyDescriptor;
|
||||
protected final IndexExtension<Key, Value, ?> myIndexExtension;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.util.indexing.impl;
|
||||
|
||||
import com.intellij.util.indexing.ID;
|
||||
import com.intellij.util.indexing.IndexId;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
import com.intellij.util.io.DataInputOutputUtil;
|
||||
import com.intellij.util.io.KeyDescriptor;
|
||||
@@ -33,9 +33,9 @@ import java.util.List;
|
||||
*/
|
||||
public class InputIndexDataExternalizer<K> implements DataExternalizer<Collection<K>> {
|
||||
private final KeyDescriptor<K> myKeyDescriptor;
|
||||
private final ID<K, ?> myIndexId;
|
||||
private final IndexId<K, ?> myIndexId;
|
||||
|
||||
public InputIndexDataExternalizer(KeyDescriptor<K> keyDescriptor, ID<K, ?> indexId) {
|
||||
public InputIndexDataExternalizer(KeyDescriptor<K> keyDescriptor, IndexId<K, ?> indexId) {
|
||||
myKeyDescriptor = keyDescriptor;
|
||||
myIndexId = indexId;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
@ApiStatus.Experimental
|
||||
public abstract class MapReduceIndex<Key,Value, Input> implements InvertedIndex<Key, Value, Input> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.indexing.impl.MapReduceIndex");
|
||||
@NotNull protected final ID<Key, Value> myIndexId;
|
||||
@NotNull protected final IndexId<Key, Value> myIndexId;
|
||||
@NotNull protected final IndexStorage<Key, Value> myStorage;
|
||||
|
||||
protected final DataExternalizer<Value> myValueExternalizer;
|
||||
@@ -314,7 +314,7 @@ public abstract class MapReduceIndex<Key,Value, Input> implements InvertedIndex<
|
||||
}
|
||||
|
||||
public static <Key, Value> void checkValuesHaveProperEqualsAndHashCode(@NotNull Map<Key, Value> data,
|
||||
@NotNull ID<Key, Value> indexId,
|
||||
@NotNull IndexId<Key, Value> indexId,
|
||||
@NotNull DataExternalizer<Value> valueExternalizer) {
|
||||
if (DebugAssertions.DEBUG) {
|
||||
for (Map.Entry<Key, Value> e : data.entrySet()) {
|
||||
|
||||
@@ -17,7 +17,7 @@ package com.intellij.util.indexing.impl;
|
||||
|
||||
import com.intellij.openapi.util.ThrowableComputable;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.indexing.ID;
|
||||
import com.intellij.util.indexing.IndexId;
|
||||
import com.intellij.util.indexing.StorageException;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,12 +30,12 @@ import java.util.Map;
|
||||
public class UpdateData<Key, Value> {
|
||||
protected final Map<Key, Value> myNewData;
|
||||
protected final ThrowableComputable<InputDataDiffBuilder<Key, Value>, IOException> myCurrentDataEvaluator;
|
||||
private final ID<Key, Value> myIndexId;
|
||||
private final IndexId<Key, Value> myIndexId;
|
||||
private final ThrowableRunnable<IOException> myForwardIndexUpdate;
|
||||
|
||||
public UpdateData(@NotNull Map<Key, Value> newData,
|
||||
@NotNull ThrowableComputable<InputDataDiffBuilder<Key, Value>, IOException> currentDataEvaluator,
|
||||
@NotNull ID<Key, Value> indexId,
|
||||
@NotNull IndexId<Key, Value> indexId,
|
||||
@Nullable ThrowableRunnable<IOException> forwardIndexUpdate) {
|
||||
myNewData = newData;
|
||||
myCurrentDataEvaluator = currentDataEvaluator;
|
||||
@@ -64,7 +64,7 @@ public class UpdateData<Key, Value> {
|
||||
return myNewData;
|
||||
}
|
||||
|
||||
public ID<Key, Value> getIndexId() {
|
||||
public IndexId<Key, Value> getIndexId() {
|
||||
return myIndexId;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.intellij.util.indexing.impl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.EmptyIterator;
|
||||
import com.intellij.util.indexing.ID;
|
||||
import com.intellij.util.indexing.IndexId;
|
||||
import com.intellij.util.indexing.ValueContainer;
|
||||
import com.intellij.util.indexing.containers.ChangeBufferingList;
|
||||
import com.intellij.util.indexing.containers.IdSet;
|
||||
@@ -80,7 +80,7 @@ class ValueContainerImpl<Value> extends UpdatableValueContainer<Value> implement
|
||||
return myInputIdMapping != null ? myInputIdMapping instanceof THashMap ? ((THashMap)myInputIdMapping).size(): 1 : 0;
|
||||
}
|
||||
|
||||
static final ThreadLocal<ID> ourDebugIndexInfo = new ThreadLocal<ID>();
|
||||
static final ThreadLocal<IndexId> ourDebugIndexInfo = new ThreadLocal<IndexId>();
|
||||
|
||||
@Override
|
||||
public void removeAssociatedValue(int inputId) {
|
||||
|
||||
+3
-3
@@ -44,7 +44,7 @@ import static com.intellij.vcs.log.data.index.VcsLogPersistentIndex.getVersion;
|
||||
public class VcsLogFullDetailsIndex<T> implements Disposable {
|
||||
protected static final String INDEX = "index";
|
||||
@NotNull protected final MyMapReduceIndex myMapReduceIndex;
|
||||
@NotNull private final ID<Integer, T> myID;
|
||||
@NotNull private final IndexId<Integer, T> myID;
|
||||
@NotNull private final String myLogId;
|
||||
@NotNull private final String myName;
|
||||
@NotNull protected final DataIndexer<Integer, T, VcsFullCommitDetails> myIndexer;
|
||||
@@ -59,7 +59,7 @@ public class VcsLogFullDetailsIndex<T> implements Disposable {
|
||||
@NotNull FatalErrorHandler fatalErrorHandler,
|
||||
@NotNull Disposable disposableParent)
|
||||
throws IOException {
|
||||
myID = ID.create(name);
|
||||
myID = IndexId.create(name);
|
||||
myName = name;
|
||||
myLogId = logId;
|
||||
myIndexer = indexer;
|
||||
@@ -181,7 +181,7 @@ public class VcsLogFullDetailsIndex<T> implements Disposable {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ID<Integer, T> getName() {
|
||||
public IndexId<Integer, T> getName() {
|
||||
return myID;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user