Documentation ¶
Index ¶
- Constants
- Variables
- func ChecksumKeyModulo(key bn.Key, length int) int
- type KeyModuloAlgorithm
- type ModuloShardingAlgorithm
- type ShardingAlgorithm
- type ShardingMilkyWay
- func (s *ShardingMilkyWay) Add(key bn.Key) error
- func (s *ShardingMilkyWay) Adds(keys []bn.Key) (err error)
- func (s *ShardingMilkyWay) AddsAndSetHeight(keys []bn.Key, height uint64) (result error)
- func (s *ShardingMilkyWay) Contains(key bn.Key, rules ...common.RuleType) (bool, error)
- func (s *ShardingMilkyWay) Deserialize() error
- func (s *ShardingMilkyWay) GetHeight() uint64
- func (s *ShardingMilkyWay) Info() []uint64
- func (s *ShardingMilkyWay) Infos() [][]uint64
- func (s *ShardingMilkyWay) Serialize() error
- func (s *ShardingMilkyWay) SetHeight(height uint64)
- func (s *ShardingMilkyWay) Start()
- func (s *ShardingMilkyWay) ValidateRule(key bn.Key, rules ...common.RuleType) error
Constants ¶
View Source
const (
Filepath = "sharding"
)
Variables ¶
View Source
var ( ErrAddsTimeout = errors.New("add multiple key timeout") ErrCannotModifyTheNestConfiguration = errors.New("when historical data exists, you cannot modify the nest " + "configuration") )
Functions ¶
Types ¶
type ModuloShardingAlgorithm ¶
type ModuloShardingAlgorithm struct {
Length int
}
func NewModuloSA ¶
func NewModuloSA(l int) *ModuloShardingAlgorithm
func (ModuloShardingAlgorithm) DoSharding ¶
func (a ModuloShardingAlgorithm) DoSharding(shardingValues []bn.Key) [][]bn.Key
DoSharding 如果传入 shardingValues 小于 Length 则 最小设置为1
func (ModuloShardingAlgorithm) DoShardingOnce ¶
func (a ModuloShardingAlgorithm) DoShardingOnce(key bn.Key) (index int)
type ShardingAlgorithm ¶
type ShardingMilkyWay ¶
type ShardingMilkyWay struct {
// contains filtered or unexported fields
}
func NewShardingMilkyWay ¶
func NewShardingMilkyWay(config *common.ShardingMilkyWayConfig, exitC chan struct{}, strategy bn.Strategy, alg ShardingAlgorithm, logger bn.Logger) (*ShardingMilkyWay, error)
func (*ShardingMilkyWay) AddsAndSetHeight ¶
func (s *ShardingMilkyWay) AddsAndSetHeight(keys []bn.Key, height uint64) (result error)
func (*ShardingMilkyWay) Deserialize ¶
func (s *ShardingMilkyWay) Deserialize() error
func (*ShardingMilkyWay) GetHeight ¶
func (s *ShardingMilkyWay) GetHeight() uint64
func (*ShardingMilkyWay) Info ¶
func (s *ShardingMilkyWay) Info() []uint64
func (*ShardingMilkyWay) Infos ¶
func (s *ShardingMilkyWay) Infos() [][]uint64
Infos index 0 sharding index index 0 height index 1 cuckoo size index 2 current index index 3 total cuckoo size index 4 total space occupied by cuckoo
func (*ShardingMilkyWay) Serialize ¶
func (s *ShardingMilkyWay) Serialize() error
func (*ShardingMilkyWay) SetHeight ¶
func (s *ShardingMilkyWay) SetHeight(height uint64)
func (*ShardingMilkyWay) Start ¶
func (s *ShardingMilkyWay) Start()
Start TODO Goroutinue should be turned off using context.Context here
func (*ShardingMilkyWay) ValidateRule ¶
Click to show internal directories.
Click to hide internal directories.