Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit b76c8bb

Browse files
.
1 parent 5ea6f1f commit b76c8bb

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

runtime/collections/collection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func newCollection() *collection {
2727
}
2828

2929
func (c *collection) getCollectionNamespaceMap() map[string]interfaces.CollectionNamespace {
30-
m := make(map[string]interfaces.CollectionNamespace)
30+
m := make(map[string]interfaces.CollectionNamespace, c.collectionNamespaceMap.Size())
3131
c.collectionNamespaceMap.Range(func(key string, value interfaces.CollectionNamespace) bool {
3232
m[key] = value
3333
return true

runtime/collections/factory.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/hypermodeinc/modus/runtime/collections/index/interfaces"
2020
"github.com/hypermodeinc/modus/runtime/db"
2121
"github.com/hypermodeinc/modus/runtime/logger"
22+
"github.com/puzpuzpuz/xsync/v3"
2223
)
2324

2425
const collectionFactoryWriteInterval = 1
@@ -40,7 +41,7 @@ func newCollectionFactory() *collectionFactory {
4041
return &collectionFactory{
4142
collectionMap: map[string]*collection{
4243
"": {
43-
collectionNamespaceMap: map[string]interfaces.CollectionNamespace{},
44+
collectionNamespaceMap: xsync.NewMapOf[string, interfaces.CollectionNamespace](),
4445
},
4546
},
4647
quit: make(chan struct{}),
@@ -86,7 +87,7 @@ func (cf *collectionFactory) readFromPostgres(ctx context.Context) bool {
8687
resetTimerFaster := false
8788
var err error
8889
for _, namespaceCollectionFactory := range cf.collectionMap {
89-
for _, col := range namespaceCollectionFactory.collectionNamespaceMap {
90+
for _, col := range namespaceCollectionFactory.getCollectionNamespaceMap() {
9091
resetTimerFaster, err = loadTextsIntoCollection(ctx, col)
9192
if err != nil {
9293
logger.Err(ctx, err).

runtime/collections/vector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func deleteIndexesNotInManifest(ctx context.Context, man *manifest.Manifest) {
9898
Msg("Failed to find collection.")
9999
continue
100100
}
101-
for _, collNs := range col.collectionNamespaceMap {
101+
for _, collNs := range col.getCollectionNamespaceMap() {
102102
vectorIndexMap := collNs.GetVectorIndexMap()
103103
if vectorIndexMap == nil {
104104
continue
@@ -160,7 +160,7 @@ func processManifestCollections(ctx context.Context, man *manifest.Manifest) {
160160
}
161161
}
162162
}
163-
for _, collNs := range col.collectionNamespaceMap {
163+
for _, collNs := range col.getCollectionNamespaceMap() {
164164
for searchMethodName, searchMethod := range collectionInfo.SearchMethods {
165165
vi, err := collNs.GetVectorIndex(ctx, searchMethodName)
166166

0 commit comments

Comments
 (0)