Documentation ¶
Index ¶
- func EvenShardsKeyRange(i, n int) (*topodatapb.KeyRange, error)
- func KeyRangeContains(kr *topodatapb.KeyRange, id []byte) bool
- func KeyRangeEndEqual(left, right *topodatapb.KeyRange) bool
- func KeyRangeEqual(left, right *topodatapb.KeyRange) bool
- func KeyRangeIncludes(big, small *topodatapb.KeyRange) bool
- func KeyRangeIsPartial(kr *topodatapb.KeyRange) bool
- func KeyRangeStartEqual(left, right *topodatapb.KeyRange) bool
- func KeyRangeString(k *topodatapb.KeyRange) string
- func KeyRangesIntersect(first, second *topodatapb.KeyRange) bool
- func KeyRangesOverlap(first, second *topodatapb.KeyRange) (*topodatapb.KeyRange, error)
- func ParseKeyRangeParts(start, end string) (*topodatapb.KeyRange, error)
- func ParseKeyspaceIDType(param string) (topodatapb.KeyspaceIdType, error)
- func ParseShardingSpec(spec string) ([]*topodatapb.KeyRange, error)
- type Uint64Key
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.