Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint committed Dec 6, 2024
1 parent 5ea6f1f commit b76c8bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion runtime/collections/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func newCollection() *collection {
}

func (c *collection) getCollectionNamespaceMap() map[string]interfaces.CollectionNamespace {
m := make(map[string]interfaces.CollectionNamespace)
m := make(map[string]interfaces.CollectionNamespace, c.collectionNamespaceMap.Size())
c.collectionNamespaceMap.Range(func(key string, value interfaces.CollectionNamespace) bool {
m[key] = value
return true
Expand Down
5 changes: 3 additions & 2 deletions runtime/collections/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/hypermodeinc/modus/runtime/collections/index/interfaces"
"github.com/hypermodeinc/modus/runtime/db"
"github.com/hypermodeinc/modus/runtime/logger"
"github.com/puzpuzpuz/xsync/v3"
)

const collectionFactoryWriteInterval = 1
Expand All @@ -40,7 +41,7 @@ func newCollectionFactory() *collectionFactory {
return &collectionFactory{
collectionMap: map[string]*collection{
"": {
collectionNamespaceMap: map[string]interfaces.CollectionNamespace{},
collectionNamespaceMap: xsync.NewMapOf[string, interfaces.CollectionNamespace](),
},
},
quit: make(chan struct{}),
Expand Down Expand Up @@ -86,7 +87,7 @@ func (cf *collectionFactory) readFromPostgres(ctx context.Context) bool {
resetTimerFaster := false
var err error
for _, namespaceCollectionFactory := range cf.collectionMap {
for _, col := range namespaceCollectionFactory.collectionNamespaceMap {
for _, col := range namespaceCollectionFactory.getCollectionNamespaceMap() {
resetTimerFaster, err = loadTextsIntoCollection(ctx, col)
if err != nil {
logger.Err(ctx, err).
Expand Down
4 changes: 2 additions & 2 deletions runtime/collections/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func deleteIndexesNotInManifest(ctx context.Context, man *manifest.Manifest) {
Msg("Failed to find collection.")
continue
}
for _, collNs := range col.collectionNamespaceMap {
for _, collNs := range col.getCollectionNamespaceMap() {
vectorIndexMap := collNs.GetVectorIndexMap()
if vectorIndexMap == nil {
continue
Expand Down Expand Up @@ -160,7 +160,7 @@ func processManifestCollections(ctx context.Context, man *manifest.Manifest) {
}
}
}
for _, collNs := range col.collectionNamespaceMap {
for _, collNs := range col.getCollectionNamespaceMap() {
for searchMethodName, searchMethod := range collectionInfo.SearchMethods {
vi, err := collNs.GetVectorIndex(ctx, searchMethodName)

Expand Down

0 comments on commit b76c8bb

Please sign in to comment.