Skip to content

Commit ceb583b

Browse files
committed
chore(InMemoryEmbeddingSearchIndex): replace custom concurrent set with ConcurrentHashMap.newKeySet #200
This change improves the performance and memory usage by utilizing the built-in `ConcurrentHashMap.newKeySet()` for the `uncheckedIds` set, which provides a more efficient concurrent implementation.
1 parent 73459d2 commit ceb583b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/kotlin/cc/unitmesh/devti/embedding/InMemoryEmbeddingSearchIndex.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import kotlin.to
2727
*/
2828
class InMemoryEmbeddingSearchIndex(root: Path, limit: Int? = null) : EmbeddingSearchIndex {
2929
private var idToEmbedding: MutableMap<String, FloatArray> = CollectionFactory.createSmallMemoryFootprintMap()
30-
private val uncheckedIds: MutableSet<String> = ConcurrentCollectionFactory.createConcurrentSet()
30+
private val uncheckedIds: MutableSet<String> = java.util.concurrent.ConcurrentHashMap.newKeySet()
3131
private val lock = ReentrantReadWriteLock()
3232

3333
private val fileManager = LocalEmbeddingIndexFileManager(root)

0 commit comments

Comments
 (0)