Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeValue(value interface{}) string
- func HashValue(value interface{}) uint64
- func NumValue(value interface{}) int64
- func ParseDayRange(dateRange string) ([]int, error)
- func ParseMonthRange(dateRange string) ([]int, error)
- func ParseYearRange(dateRange string) ([]int, error)
- type DateDayShard
- type DateMonthShard
- type DateYearShard
- type DefaultShard
- type HashShard
- type KeyError
- type NumKeyRange
- type NumRangeShard
- type RangeShard
- type Router
- type Rule
- type Shard
- type Uint64Key
Constants ¶
View Source
const ( MinNumKey = math.MinInt64 MaxNumKey = math.MaxInt64 )
Variables ¶
View Source
var ( DefaultRuleType = "default" HashRuleType = "hash" ModRuleType = "mod" RangeRuleType = "range" DateYearRuleType = "date_year" DateMonthRuleType = "date_month" DateDayRuleType = "date_day" MinMonthDaysCount = 28 MaxMonthDaysCount = 31 MonthsCount = 12 )
Functions ¶
func EncodeValue ¶
func EncodeValue(value interface{}) string
func ParseDayRange ¶
ParseDayRange return date of daynumber by order 20151201-20151205 20151201,20151202,20151203,20151204,20151205
func ParseMonthRange ¶
return date of month by order 201510-201512 201510,201511,201512
func ParseYearRange ¶
return date of year by order 2013-2015 2013,2014,2015
Types ¶
type DateDayShard ¶
type DateDayShard struct { }
func (*DateDayShard) FindForKey ¶
func (s *DateDayShard) FindForKey(key interface{}) (int, error)
FindForKey the format of date is: YYYY-MM-DD HH:MM:SS,YYYY-MM-DD or unix timestamp(int)
type DateMonthShard ¶
type DateMonthShard struct { }
func (*DateMonthShard) FindForKey ¶
func (s *DateMonthShard) FindForKey(key interface{}) (int, error)
FindForKey the format of date is: YYYY-MM-DD HH:MM:SS,YYYY-MM-DD or unix timestamp(int)
type DateYearShard ¶
type DateYearShard struct { }
func (*DateYearShard) FindForKey ¶
func (s *DateYearShard) FindForKey(key interface{}) (int, error)
FindForKey the format of date is: YYYY-MM-DD HH:MM:SS,YYYY-MM-DD or unix timestamp(int)
type DefaultShard ¶
type DefaultShard struct { }
func (*DefaultShard) FindForKey ¶
func (s *DefaultShard) FindForKey(key interface{}) (int, error)
type NumKeyRange ¶
[start,end)
func ParseNumSharding ¶
func ParseNumSharding(Locations []int, TableRowLimit int) ([]NumKeyRange, error)
func (NumKeyRange) Contains ¶
func (kr NumKeyRange) Contains(i int64) bool
func (NumKeyRange) MapKey ¶
func (kr NumKeyRange) MapKey() string
func (NumKeyRange) String ¶
func (kr NumKeyRange) String() string
type NumRangeShard ¶
type NumRangeShard struct {
Shards []NumKeyRange
}
func (*NumRangeShard) EqualStart ¶
func (s *NumRangeShard) EqualStart(key interface{}, index int) bool
func (*NumRangeShard) EqualStop ¶
func (s *NumRangeShard) EqualStop(key interface{}, index int) bool
func (*NumRangeShard) FindForKey ¶
func (s *NumRangeShard) FindForKey(key interface{}) (int, error)
type RangeShard ¶
type RangeShard interface { Shard EqualStart(key interface{}, index int) bool EqualStop(key interface{}, index int) bool }
RangeShard /*一个范围的分片,例如[start,end)*/
type Router ¶
func ParseRouter ¶
func ParseRouter(cfgList []config.TableConfig, cfg *config.SchemaConfig) (router *Router, err error)
func (*Router) FindNodeIndex ¶
type Rule ¶
type Rule struct { Table string Key string Type string ReferenceTable *config.AssociatedTableConfig IsAssociated bool DefaultNode string NodeList []string SubTableIndexList []int //SubTableIndexList store all the index of sharding sub-table,sequential TableToNode map[int]int //key is table index, and value is node index Shard Shard // contains filtered or unexported fields }
func NewDefaultRule ¶
func ParseRule ¶
func ParseRule(cfg config.TableConfig, cfgList []config.TableConfig) (*Rule, error)
func (*Rule) FindNodeIndex ¶
func (*Rule) FindTableIndex ¶
Click to show internal directories.
Click to hide internal directories.