mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 17:48:29 +08:00
Co-authored-by: Zach41 <zongmei.zhang@zilliz.com> Signed-off-by: cai.zhang <cai.zhang@zilliz.com> Signed-off-by: cai.zhang <cai.zhang@zilliz.com> Co-authored-by: Zach41 <zongmei.zhang@zilliz.com>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package indexnode
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"sync"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/indexpb"
|
|
"github.com/milvus-io/milvus/internal/storage"
|
|
)
|
|
|
|
type StorageFactory interface {
|
|
NewChunkManager(ctx context.Context, config *indexpb.StorageConfig) (storage.ChunkManager, error)
|
|
}
|
|
|
|
type chunkMgr struct {
|
|
cached sync.Map
|
|
}
|
|
|
|
func (m *chunkMgr) NewChunkManager(ctx context.Context, config *indexpb.StorageConfig) (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.Address(config.Address),
|
|
storage.AccessKeyID(config.AccessKeyID),
|
|
storage.SecretAccessKeyID(config.SecretAccessKey),
|
|
storage.UseSSL(config.UseSSL),
|
|
storage.BucketName(config.BucketName),
|
|
storage.UseIAM(config.UseIAM),
|
|
storage.IAMEndpoint(config.IAMEndpoint),
|
|
}
|
|
factory := storage.NewChunkManagerFactory("local", "minio", opts...)
|
|
mgr, err := factory.NewVectorStorageChunkManager(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
//v, _ := m.cached.LoadOrStore(key, mgr)
|
|
return mgr, nil
|
|
}
|
|
|
|
func (m *chunkMgr) cacheKey(bucket, storageAccessKey string) string {
|
|
return fmt.Sprintf("%s/%s", bucket, storageAccessKey)
|
|
}
|