key

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2017 License: BSD-3-Clause Imports: 7 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvenShardsKeyRange

func EvenShardsKeyRange(i, n int) (*topodatapb.KeyRange, error)

EvenShardsKeyRange returns a key range definition for a shard at index "i", assuming range based sharding with "n" equal-width shards in total. i starts at 0.

Example: (1, 2) returns the second out of two shards in total i.e. "80-".

This function must not be used in the Vitess code base because Vitess also supports shards with different widths. In that case, the output of this function would be wrong.

Note: start and end values have trailing zero bytes omitted. For example, "80-" has only the first byte (0x80) set. We do this to produce the same KeyRange objects as ParseKeyRangeParts() does. Because it's using the Go hex methods, it's omitting trailing zero bytes as well.

func KeyRangeContains

func KeyRangeContains(kr *topodatapb.KeyRange, id []byte) bool

KeyRangeContains returns true if the provided id is in the keyrange.

func KeyRangeEndEqual

func KeyRangeEndEqual(left, right *topodatapb.KeyRange) bool

KeyRangeEndEqual returns true if both key ranges have the same end

func KeyRangeEqual

func KeyRangeEqual(left, right *topodatapb.KeyRange) bool

KeyRangeEqual returns true if both key ranges cover the same area

func KeyRangeIncludes

func KeyRangeIncludes(big, small *topodatapb.KeyRange) bool

KeyRangeIncludes returns true if the first provided KeyRange, big, contains the second KeyRange, small. If they intersect, but small spills out, this returns false.

func KeyRangeIsPartial

func KeyRangeIsPartial(kr *topodatapb.KeyRange) bool

KeyRangeIsPartial returns true if the KeyRange does not cover the entire space.

func KeyRangeStartEqual

func KeyRangeStartEqual(left, right *topodatapb.KeyRange) bool

KeyRangeStartEqual returns true if both key ranges have the same start

func KeyRangeString

func KeyRangeString(k *topodatapb.KeyRange) string

KeyRangeString prints a topodatapb.KeyRange

func KeyRangesIntersect

func KeyRangesIntersect(first, second *topodatapb.KeyRange) bool

KeyRangesIntersect returns true if some Keyspace values exist in both ranges.

func KeyRangesOverlap

func KeyRangesOverlap(first, second *topodatapb.KeyRange) (*topodatapb.KeyRange, error)

KeyRangesOverlap returns the overlap between two KeyRanges. They need to overlap, otherwise an error is returned.

func ParseKeyRangeParts

func ParseKeyRangeParts(start, end string) (*topodatapb.KeyRange, error)

ParseKeyRangeParts parses a start and end hex values and build a proto KeyRange

func ParseKeyspaceIDType

func ParseKeyspaceIDType(param string) (topodatapb.KeyspaceIdType, error)

ParseKeyspaceIDType parses the keyspace id type into the enum

func ParseShardingSpec

func ParseShardingSpec(spec string) ([]*topodatapb.KeyRange, 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.

Types

type Uint64Key

type Uint64Key uint64

Uint64Key is a uint64 that can be converted into a KeyspaceId.

func (Uint64Key) Bytes

func (i Uint64Key) Bytes() []byte

Bytes returns the keyspace id (as bytes) associated with a Uint64Key.

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