go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/key Index | Files

package key

import "gopkg.in/src-d/go-vitess.v1/vt/key"

Index

Package Files

destination.go key.go

func DestinationsString Uses

func DestinationsString(destinations []Destination) string

DestinationsString returns a printed version of the destination array.

func EvenShardsKeyRange Uses

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 GetShardForKeyspaceID Uses

func GetShardForKeyspaceID(allShards []*topodatapb.ShardReference, keyspaceID []byte) (string, error)

GetShardForKeyspaceID finds the right shard for a keyspace id.

func KeyRangeContains Uses

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

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

func KeyRangeEndEqual Uses

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

KeyRangeEndEqual returns true if both key ranges have the same end

func KeyRangeEqual Uses

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

KeyRangeEqual returns true if both key ranges cover the same area

func KeyRangeIncludes Uses

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 Uses

func KeyRangeIsPartial(kr *topodatapb.KeyRange) bool

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

func KeyRangeStartEqual Uses

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

KeyRangeStartEqual returns true if both key ranges have the same start

func KeyRangeString Uses

func KeyRangeString(k *topodatapb.KeyRange) string

KeyRangeString prints a topodatapb.KeyRange

func KeyRangesIntersect Uses

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

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

func KeyRangesOverlap Uses

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 Uses

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

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

func ParseKeyspaceIDType Uses

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

ParseKeyspaceIDType parses the keyspace id type into the enum

func ParseShardingSpec Uses

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.

type Destination Uses

type Destination interface {
    // Resolve calls the callback for every shard Destination
    // resolves into, given the shards list.
    // The returned error must be generated by vterrors.
    Resolve([]*topodatapb.ShardReference, func(shard string) error) error

    // IsUnique returns true if this is a single destination.
    // It returns false if this type can map to multiple destinations.
    //
    // TODO(alainjobart) That is just a method I think will be useful.
    // Mainly, in v3, once we Map(), each returned result should
    // be IsUnique=true for a Unique vindex.
    IsUnique() bool

    // String returns a printable version of the Destination.
    String() string
}

Destination is an interface definition for a query destination, within a given Keyspace / Tablet Type. It is meant to be an internal data structure, with multiple possible implementations. The srvtopo package can resolve Destinations into actual Targets.

type DestinationAllShards Uses

type DestinationAllShards struct{}

DestinationAllShards is the destination for all the shards in the keyspace. This usually maps to the first one in the list. It implements the Destination interface.

func (DestinationAllShards) IsUnique Uses

func (d DestinationAllShards) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationAllShards) Resolve Uses

func (d DestinationAllShards) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationAllShards) String Uses

func (d DestinationAllShards) String() string

String is part of the Destination interface.

type DestinationAnyShard Uses

type DestinationAnyShard struct{}

DestinationAnyShard is the destination for any one shard in the keyspace. It implements the Destination interface.

func (DestinationAnyShard) IsUnique Uses

func (d DestinationAnyShard) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationAnyShard) Resolve Uses

func (d DestinationAnyShard) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationAnyShard) String Uses

func (d DestinationAnyShard) String() string

String is part of the Destination interface.

type DestinationAnyShardPicker Uses

type DestinationAnyShardPicker interface {
    // PickShard picks a shard given a number of shards
    PickShard(shardCount int) int
}

DestinationAnyShardPicker exposes an interface that will pick an index given a number of available shards.

var AnyShardPicker DestinationAnyShardPicker = DestinationAnyShardPickerRandomShard{}

AnyShardPicker makes a choice on what shard to use when any shard will do. Used for testing.

type DestinationAnyShardPickerRandomShard Uses

type DestinationAnyShardPickerRandomShard struct{}

DestinationAnyShardPickerRandomShard picks a random shard.

func (DestinationAnyShardPickerRandomShard) PickShard Uses

func (dp DestinationAnyShardPickerRandomShard) PickShard(shardCount int) int

PickShard is DestinationAnyShardPickerRandomShard's implmentation.

type DestinationExactKeyRange Uses

type DestinationExactKeyRange struct {
    KeyRange *topodatapb.KeyRange
}

DestinationExactKeyRange is the destination for a single KeyRange. The KeyRange must map exactly to one or more shards, and cannot start or end in the middle of a shard. It implements the Destination interface. (it cannot be just a type *topodatapb.KeyRange, as then the receiver methods don't work. And it can't be topodatapb.KeyRange either, as then the methods are on *DestinationExactKeyRange, and the original KeyRange cannot be returned).

func (DestinationExactKeyRange) IsUnique Uses

func (d DestinationExactKeyRange) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationExactKeyRange) Resolve Uses

func (d DestinationExactKeyRange) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationExactKeyRange) String Uses

func (d DestinationExactKeyRange) String() string

String is part of the Destination interface.

type DestinationExactKeyRanges Uses

type DestinationExactKeyRanges []*topodatapb.KeyRange

DestinationExactKeyRanges is the destination for multiple KeyRanges. The KeyRanges must map exactly to one or more shards, and cannot start or end in the middle of a shard. It implements the Destination interface.

func (DestinationExactKeyRanges) IsUnique Uses

func (d DestinationExactKeyRanges) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationExactKeyRanges) Resolve Uses

func (d DestinationExactKeyRanges) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationExactKeyRanges) String Uses

func (d DestinationExactKeyRanges) String() string

String is part of the Destination interface.

type DestinationKeyRange Uses

type DestinationKeyRange struct {
    KeyRange *topodatapb.KeyRange
}

DestinationKeyRange is the destination for a single KeyRange. It implements the Destination interface. (it cannot be just a type *topodatapb.KeyRange, as then the receiver methods don't work. And it can't be topodatapb.KeyRange either, as then the methods are on *DestinationKeyRange, and the original KeyRange cannot be returned).

func (DestinationKeyRange) IsUnique Uses

func (d DestinationKeyRange) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationKeyRange) Resolve Uses

func (d DestinationKeyRange) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationKeyRange) String Uses

func (d DestinationKeyRange) String() string

String is part of the Destination interface.

type DestinationKeyRanges Uses

type DestinationKeyRanges []*topodatapb.KeyRange

DestinationKeyRanges is the destination for multiple KeyRanges. It implements the Destination interface.

func (DestinationKeyRanges) IsUnique Uses

func (d DestinationKeyRanges) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationKeyRanges) Resolve Uses

func (d DestinationKeyRanges) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationKeyRanges) String Uses

func (d DestinationKeyRanges) String() string

String is part of the Destination interface.

type DestinationKeyspaceID Uses

type DestinationKeyspaceID []byte

DestinationKeyspaceID is the destination for a single KeyspaceID. It implements the Destination interface.

func (DestinationKeyspaceID) IsUnique Uses

func (d DestinationKeyspaceID) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationKeyspaceID) Resolve Uses

func (d DestinationKeyspaceID) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationKeyspaceID) String Uses

func (d DestinationKeyspaceID) String() string

String is part of the Destination interface.

type DestinationKeyspaceIDs Uses

type DestinationKeyspaceIDs [][]byte

DestinationKeyspaceIDs is the destination for multiple KeyspaceIDs. It implements the Destination interface.

func (DestinationKeyspaceIDs) IsUnique Uses

func (d DestinationKeyspaceIDs) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationKeyspaceIDs) Resolve Uses

func (d DestinationKeyspaceIDs) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationKeyspaceIDs) String Uses

func (d DestinationKeyspaceIDs) String() string

String is part of the Destination interface.

type DestinationNone Uses

type DestinationNone struct{}

DestinationNone is a destination that doesn't resolve to any shard. It implements the Destination interface.

func (DestinationNone) IsUnique Uses

func (d DestinationNone) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationNone) Resolve Uses

func (d DestinationNone) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationNone) String Uses

func (d DestinationNone) String() string

String is part of the Destination interface.

type DestinationShard Uses

type DestinationShard string

DestinationShard is the destination for a single Shard. It implements the Destination interface.

func (DestinationShard) IsUnique Uses

func (d DestinationShard) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationShard) Resolve Uses

func (d DestinationShard) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationShard) String Uses

func (d DestinationShard) String() string

String is part of the Destination interface.

type DestinationShards Uses

type DestinationShards []string

DestinationShards is the destination for multiple shards. It implements the Destination interface.

func (DestinationShards) IsUnique Uses

func (d DestinationShards) IsUnique() bool

IsUnique is part of the Destination interface.

func (DestinationShards) Resolve Uses

func (d DestinationShards) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error

Resolve is part of the Destination interface.

func (DestinationShards) String Uses

func (d DestinationShards) String() string

String is part of the Destination interface.

type Uint64Key Uses

type Uint64Key uint64

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

func (Uint64Key) Bytes Uses

func (i Uint64Key) Bytes() []byte

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

func (Uint64Key) String Uses

func (i Uint64Key) String() string

Package key imports 10 packages (graph) and is imported by 34 packages. Updated 2019-06-13. Refresh now. Tools for package owners.