Skip to content

Commit 1823b9b

Browse files
author
Jake Luciani
authored
Switch from syncronized to concurrent map for pq codebook (#518)
* Switch from syncronized to concurrent map for pq codebook Signed-off-by: Jake Luciani <jake@datastax.com> * Remove synchronized --------- Signed-off-by: Jake Luciani <jake@datastax.com>
1 parent 6d590ad commit 1823b9b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

jvector-base/src/main/java/io/github/jbellis/jvector/quantization/ImmutablePQVectors.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import io.github.jbellis.jvector.vector.types.ByteSequence;
2323
import io.github.jbellis.jvector.vector.types.VectorFloat;
2424

25-
import java.util.HashMap;
2625
import java.util.Map;
26+
import java.util.concurrent.ConcurrentHashMap;
2727

2828
public class ImmutablePQVectors extends PQVectors {
2929
private final int vectorCount;
@@ -41,7 +41,7 @@ public ImmutablePQVectors(ProductQuantization pq, ByteSequence<?>[] compressedDa
4141
this.compressedDataChunks = compressedDataChunks;
4242
this.vectorCount = vectorCount;
4343
this.vectorsPerChunk = vectorsPerChunk;
44-
this.codebookPartialSumsMap = new HashMap<>();
44+
this.codebookPartialSumsMap = new ConcurrentHashMap<>();
4545
}
4646

4747
@Override
@@ -54,7 +54,7 @@ public int count() {
5454
return vectorCount;
5555
}
5656

57-
private synchronized VectorFloat<?> getOrCreateCodebookPartialSums(VectorSimilarityFunction vsf) {
57+
private VectorFloat<?> getOrCreateCodebookPartialSums(VectorSimilarityFunction vsf) {
5858
return codebookPartialSumsMap.computeIfAbsent(vsf, pq::createCodebookPartialSums);
5959
}
6060

0 commit comments

Comments
 (0)