key

package
v0.0.0-...-8e4f697 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2013 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxKey = KeyspaceId("")
View Source
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 KeyError

type KeyError string

func NewKeyError

func NewKeyError(format string, args ...interface{}) KeyError

func (KeyError) Error

func (ke KeyError) Error() string

type KeyRange

type KeyRange struct {
	Start KeyspaceId
	End   KeyspaceId
}

func (KeyRange) Contains

func (kr KeyRange) Contains(i KeyspaceId) bool

func (KeyRange) IsPartial

func (kr KeyRange) IsPartial() bool

func (KeyRange) MapKey

func (kr KeyRange) MapKey() string

func (KeyRange) String

func (kr KeyRange) String() string

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)

type KeyspaceRange

type KeyspaceRange struct {
	Keyspace string
	KeyRange
}

type Uint64Key

type Uint64Key uint64

NOTE(msolomon) not sure about all these types - feels like it will create hoops later.

func (Uint64Key) KeyspaceId

func (i Uint64Key) KeyspaceId() KeyspaceId

func (Uint64Key) String

func (i Uint64Key) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL