-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Zach41 <[email protected]>
- Loading branch information
Showing
24 changed files
with
3,219 additions
and
2,225 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package indexnode | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"sync" | ||
|
||
"github.com/milvus-io/milvus/internal/storage" | ||
) | ||
|
||
type StorageFactory interface { | ||
NewChunkManager(ctx context.Context, bucket, storageAccessKey string) (storage.ChunkManager, error) | ||
} | ||
|
||
type chunkMgr struct { | ||
cached sync.Map | ||
} | ||
|
||
func (m *chunkMgr) NewChunkManager(ctx context.Context, bucket, storageAccessKey string) (storage.ChunkManager, error) { | ||
key := m.cacheKey(bucket, storageAccessKey) | ||
if v, ok := m.cached.Load(key); ok { | ||
return v.(storage.ChunkManager), nil | ||
} | ||
opts := []storage.Option{ | ||
storage.AccessKeyID(storageAccessKey), | ||
storage.BucketName(bucket), | ||
} | ||
factory := storage.NewChunkManagerFactory("local", "minio", opts...) | ||
mgr, err := factory.NewVectorStorageChunkManager(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
v, _ := m.cached.LoadOrStore(key, mgr) | ||
return v.(storage.ChunkManager), nil | ||
} | ||
|
||
func (m *chunkMgr) cacheKey(bucket, storageAccessKey string) string { | ||
return fmt.Sprintf("%s/%s", bucket, storageAccessKey) | ||
} |
Oops, something went wrong.