mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package writebuffer
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/milvus-io/milvus/internal/allocator"
|
|
"github.com/milvus-io/milvus/internal/datanode/metacache"
|
|
"github.com/milvus-io/milvus/internal/datanode/syncmgr"
|
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
|
)
|
|
|
|
type WriteBufferOption func(opt *writeBufferOption)
|
|
|
|
type writeBufferOption struct {
|
|
idAllocator allocator.Interface
|
|
syncPolicies []SyncPolicy
|
|
|
|
pkStatsFactory metacache.PkStatsFactory
|
|
metaWriter syncmgr.MetaWriter
|
|
}
|
|
|
|
func defaultWBOption(metacache metacache.MetaCache) *writeBufferOption {
|
|
return &writeBufferOption{
|
|
syncPolicies: []SyncPolicy{
|
|
GetFullBufferPolicy(),
|
|
GetSyncStaleBufferPolicy(paramtable.Get().DataNodeCfg.SyncPeriod.GetAsDuration(time.Second)),
|
|
GetSealedSegmentsPolicy(metacache),
|
|
GetDroppedSegmentPolicy(metacache),
|
|
},
|
|
}
|
|
}
|
|
|
|
func WithIDAllocator(allocator allocator.Interface) WriteBufferOption {
|
|
return func(opt *writeBufferOption) {
|
|
opt.idAllocator = allocator
|
|
}
|
|
}
|
|
|
|
func WithPKStatsFactory(factory metacache.PkStatsFactory) WriteBufferOption {
|
|
return func(opt *writeBufferOption) {
|
|
opt.pkStatsFactory = factory
|
|
}
|
|
}
|
|
|
|
func WithMetaWriter(writer syncmgr.MetaWriter) WriteBufferOption {
|
|
return func(opt *writeBufferOption) {
|
|
opt.metaWriter = writer
|
|
}
|
|
}
|
|
|
|
func WithSyncPolicy(policy SyncPolicy) WriteBufferOption {
|
|
return func(opt *writeBufferOption) {
|
|
opt.syncPolicies = append(opt.syncPolicies, policy)
|
|
}
|
|
}
|