Documentation
¶
Index ¶
- Variables
- func EncodeValue(value interface{}) string
- func FindShardForKey(key interface{}, tabletKeys []KeyspaceId) (i int, err error)
- func FindShardForValue(value string, tabletKeys []KeyspaceId) int
- type HexKeyspaceId
- type KeyError
- type KeyRange
- type KeyRangeArray
- type KeyspaceId
- type KeyspaceIdArray
- type KeyspaceRange
- type Uint64Key
Constants ¶
This section is empty.
Variables ¶
var MaxKey = KeyspaceId("")
var MinKey = KeyspaceId("")
Functions ¶
func EncodeValue ¶
func EncodeValue(value interface{}) string
func FindShardForKey ¶
func FindShardForKey(key interface{}, tabletKeys []KeyspaceId) (i int, err error)
Finds the shard that covers the given interface. The returned index is between 0 and len(tabletKeys)-1). The tabletKeys is an ordered list of the End values of the KeyRange structures for the shards.
func FindShardForValue ¶
func FindShardForValue(value string, tabletKeys []KeyspaceId) int
Finds the shard that covers the given value. The returned index is between 0 and len(tabletKeys)-1). The tabletKeys is an ordered list of the End values of the KeyRange structures for the shards.
This function will not check the value is under the last shard's max (we assume it will be empty, as checked by RebuildKeyspace)
Types ¶
type HexKeyspaceId ¶
type HexKeyspaceId string
func (HexKeyspaceId) Unhex ¶
func (hkid HexKeyspaceId) Unhex() (KeyspaceId, error)
type KeyRange ¶
type KeyRange struct { Start KeyspaceId End KeyspaceId }
func (KeyRange) Contains ¶
func (kr KeyRange) Contains(i KeyspaceId) bool
type KeyRangeArray ¶
type KeyRangeArray []KeyRange
func ParseShardingSpec ¶
func ParseShardingSpec(spec string) (KeyRangeArray, error)
ParseShardingSpec parses a string that describes a sharding specification. a-b-c-d will be parsed as a-b, b-c, c-d. The empty string may serve both as the start and end of the keyspace: -a-b- will be parsed as start-a, a-b, b-end.
func (KeyRangeArray) Len ¶
func (p KeyRangeArray) Len() int
func (KeyRangeArray) Less ¶
func (p KeyRangeArray) Less(i, j int) bool
func (KeyRangeArray) Sort ¶
func (p KeyRangeArray) Sort()
func (KeyRangeArray) Swap ¶
func (p KeyRangeArray) Swap(i, j int)
type KeyspaceId ¶
type KeyspaceId string
func (KeyspaceId) Hex ¶
func (kid KeyspaceId) Hex() HexKeyspaceId
func (KeyspaceId) MarshalJSON ¶
func (kid KeyspaceId) MarshalJSON() ([]byte, error)
func (*KeyspaceId) UnmarshalJSON ¶
func (kid *KeyspaceId) UnmarshalJSON(data []byte) (err error)
type KeyspaceIdArray ¶
type KeyspaceIdArray []KeyspaceId
func (KeyspaceIdArray) Len ¶
func (p KeyspaceIdArray) Len() int
func (KeyspaceIdArray) Less ¶
func (p KeyspaceIdArray) Less(i, j int) bool
func (KeyspaceIdArray) Sort ¶
func (p KeyspaceIdArray) Sort()
func (KeyspaceIdArray) Swap ¶
func (p KeyspaceIdArray) Swap(i, j int)