mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[indexes] IJPL-176982: make shared index compatible with sharded index regardless of shards count
+ Change in `shardsCount` changes `index.version`, which makes the index incompatible with the downloaded shared index version => `ShardableIndexExtension.shardlessVersion` was introduced, and used in shared index compatibility check, instead of generic `index.version` (cherry picked from commit 23bbb5523453f1d2d2ef6a9e7dc23a99a96d1db4) IJ-CR-159317 GitOrigin-RevId: 3a8d08729a94aa01d9d026e7b82be39d24a3f830
This commit is contained in:
committed by
intellij-monorepo-bot
parent
44f780da95
commit
e2bf59ed12
@@ -91,9 +91,15 @@ public final class TrigramIndex extends ScalarIndexExtension<Integer> implements
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Internal
|
||||
public int shardlessVersion() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 4 + (SHARDS - 1);
|
||||
return shardlessVersion() + (SHARDS - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util.indexing.storage.sharding;
|
||||
|
||||
import com.intellij.util.indexing.IndexExtension;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
@@ -48,4 +49,14 @@ public interface ShardableIndexExtension {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation version, without taking shards# into account.
|
||||
* Motivation: generally, shards count should be a part of {@link IndexExtension#getVersion()} -- e.g. change in shardsCount _must_
|
||||
* trigger re-indexing -- but in some cases shards count is not important. It all comes down to the exact interpretation of
|
||||
* {@link IndexExtension#getVersion()}: is it a version of current index layout, or it is a version of index layout that could be
|
||||
* _open-and-read_ by current code? This method returns "version that could be open-and-read", while {@link IndexExtension#getVersion()}
|
||||
* returns a current layout version.
|
||||
*/
|
||||
int shardlessVersion();
|
||||
}
|
||||
|
||||
@@ -43,8 +43,13 @@ public final class IdIndexImpl extends IdIndex implements CustomInputsIndexFileB
|
||||
return SHARDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int shardlessVersion() {
|
||||
return super.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return super.getVersion() + (SHARDS - 1);
|
||||
return shardlessVersion() + (SHARDS - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.vfs.newvfs.persistent.indexes;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -157,6 +157,11 @@ public class IndexStorageLayoutBenchmark {
|
||||
public int shardsCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int shardlessVersion() {
|
||||
return super.getVersion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package com.intellij.util.indexing;
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Represents index data format specification, namely serialization format for keys & values, and a mapping from input to
|
||||
* indexing data.
|
||||
*
|
||||
* <p>
|
||||
* To create index corresponding to any extension one could use {@link com.intellij.util.indexing.impl.MapReduceIndex}.
|
||||
*/
|
||||
public abstract class IndexExtension<Key, Value, Input> {
|
||||
@@ -25,6 +25,15 @@ public abstract class IndexExtension<Key, Value, Input> {
|
||||
|
||||
public abstract @NotNull DataExternalizer<Value> getValueExternalizer();
|
||||
|
||||
/** Version of index format/algo. Generally, if the version is changed -- index must be rebuilt. */
|
||||
/**
|
||||
* Version of index format/algo.
|
||||
* Generally, if the version is changed -- index must be rebuilt.
|
||||
* <p>
|
||||
* Discussion: "index version" is quite ill-defined concept, because really it should be not a single version, but a few separate
|
||||
* versions for "binary layout to be written version", "binary layout compatible to read version", "indexer algo version", etc.
|
||||
* Currently, all those 'versions' are merged into a single version -- which simplifies things a bit, but causes issues from time to time.
|
||||
*
|
||||
* @see ShardableIndexExtension#shardlessVersion
|
||||
*/
|
||||
public abstract int getVersion();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util.indexing;
|
||||
|
||||
import com.intellij.openapi.util.io.ByteArraySequence;
|
||||
@@ -538,6 +538,11 @@ public abstract class IndexStorageLayoutProviderTestBase {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int shardlessVersion() {
|
||||
return VERSION + (shardsCount() - 1) * 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int shardsCount() {
|
||||
return 3;
|
||||
|
||||
Reference in New Issue
Block a user