kr

package
v0.0.0-...-963c118 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: PostgreSQL Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MissTypedKeyRange = fmt.Errorf("key range bound is mistyped")

TODO: use it

Functions

func CmpRangesEqual

func CmpRangesEqual(bound KeyRangeBound, key KeyRangeBound, types []string) bool

func CmpRangesLess

func CmpRangesLess(bound KeyRangeBound, key KeyRangeBound, types []string) bool

CmpRangesLess compares two byte slices, kr and other, and returns true if kr is less than other. The comparison is based on the length of the slices and the lexicographic order of their string representations.

Parameters:

  • kr: The first byte slice to compare.
  • other: The second byte slice to compare.

Returns:

  • bool: True if kr is less than other, false otherwise.

TODO : unit tests

func CmpRangesLessEqual

func CmpRangesLessEqual(bound KeyRangeBound, key KeyRangeBound, types []string) bool

func CmpRangesLessStringsDeprecated

func CmpRangesLessStringsDeprecated(bound string, key string) bool

* Old style key ranges comparation

TODO : unit tests

func GetKRCondition

func GetKRCondition(rel *distributions.DistributedRelation, kRange *KeyRange, upperBound KeyRangeBound, prefix string) (string, error)

GetKRCondition returns SQL condition for elements of distributed relation between two key ranges TODO support multidimensional key ranges

Parameters:

  • ds: The distribution object.
  • rel: The distributed relation object.
  • kRange: The key range object.
  • upperBound: The upper bound of the key range.
  • prefix: The prefix to use for the column names.

Returns:

  • string: The SQL condition for the key range.

func KeyRangeBoundFromStrings

func KeyRangeBoundFromStrings(colTypes []string, vals []string) ([]interface{}, error)

Types

type BatchMoveKeyRange

type BatchMoveKeyRange struct {
	KrId    string // KrId is the source key range id
	ShardId string // ShardId is the destination shard id
	Limit   int64  /* Limit is kr.RedistributeKeyLimit value specifying the number of keys to transfer.
	Can be either negative, in which case the whole key range will be moved,
	or non-negative, where circa specified amount of keys will be moved. */
	BatchSize int    // BatchSize is the amount of keys to be transferred in every transaction.
	DestKrId  string /* DestKrId is the destination key range id.
	If the whole key range is being moved, it's still renamed. */

	Type tasks.SplitType // Type is the tasks.SplitType value specifying if leftmost or rightmost portion of the key range will be moved
}

type KeyRange

type KeyRange struct {
	LowerBound   KeyRangeBound
	ShardID      string
	ID           string
	Distribution string

	ColumnTypes []string
}

qdb KeyRange with its distibtion column types stored in case struct for fast convertion/access

func KeyRangeFromBytes

func KeyRangeFromBytes(val [][]byte, colTypes []string) *KeyRange

func KeyRangeFromDB

func KeyRangeFromDB(krdb *qdb.KeyRange, colTypes []string) *KeyRange

KeyRangeFromDB converts a qdb.KeyRange object to a KeyRange object. It creates a new KeyRange object with the values from the qdb.KeyRange object. It returns a pointer to the new KeyRange object.

Parameters:

  • kr: The qdb.KeyRange object to convert.

Returns:

  • *KeyRange: A pointer to the new KeyRange object.

TODO : unit tests

func KeyRangeFromProto

func KeyRangeFromProto(krproto *proto.KeyRangeInfo, colTypes []string) *KeyRange

KeyRangeFromProto converts a protobuf KeyRangeInfo to a KeyRange object. If the input KeyRangeInfo is nil, it returns nil. Otherwise, it creates a new KeyRange object with the values from the KeyRangeInfo object and returns a pointer to it.

Parameters:

  • kr: The protobuf KeyRangeInfo to convert.
  • colTypes: the column types list

Returns:

  • *KeyRange: A pointer to the new KeyRange object.

TODO : unit tests

func KeyRangeFromSQL

func KeyRangeFromSQL(krsql *spqrparser.KeyRangeDefinition, colTypes []string) (*KeyRange, error)

KeyRangeFromSQL converts a spqrparser.KeyRangeDefinition into a KeyRange. If kr is nil, it returns nil. Otherwise, it creates a new KeyRange with the provided values and returns a pointer to it.

Parameters:

  • kr: The spqrparser.KeyRangeDefinition to convert.

Returns:

  • *KeyRange: A pointer to the new KeyRange object.

TODO : unit tests

func (*KeyRange) InFunc

func (kr *KeyRange) InFunc(attribInd int, raw []byte)

func (*KeyRange) InFuncSQL

func (kr *KeyRange) InFuncSQL(attribInd int, raw []byte)

func (*KeyRange) OutFunc

func (kr *KeyRange) OutFunc(attribInd int) []byte

func (*KeyRange) Raw

func (kr *KeyRange) Raw() [][]byte

func (*KeyRange) RecvFunc

func (kr *KeyRange) RecvFunc(attribInd int, val string) error

func (*KeyRange) RecvRaw

func (kr *KeyRange) RecvRaw(vals []string) error

func (*KeyRange) SendFunc

func (kr *KeyRange) SendFunc(attribInd int) string

func (*KeyRange) SendRaw

func (kr *KeyRange) SendRaw() []string

func (*KeyRange) ToDB

func (kr *KeyRange) ToDB() *qdb.KeyRange

ToDB converts the KeyRange struct to a qdb.KeyRange struct. It returns a pointer to the converted qdb.KeyRange struct.

Returns:

  • *qdb.KeyRange: A pointer to the converted qdb.KeyRange struct.

TODO : unit tests

func (*KeyRange) ToProto

func (kr *KeyRange) ToProto() *proto.KeyRangeInfo

ToProto converts the KeyRange struct to a protobuf KeyRangeInfo message. It returns a pointer to the converted KeyRangeInfo message.

Returns:

  • *proto.KeyRangeInfo: A pointer to the converted KeyRangeInfo message.

TODO : unit tests

type KeyRangeBound

type KeyRangeBound []interface{}

type KeyRangeMgr

type KeyRangeMgr interface {
	GetKeyRange(ctx context.Context, krId string) (*KeyRange, error)
	ListKeyRanges(ctx context.Context, distribution string) ([]*KeyRange, error)
	ListAllKeyRanges(ctx context.Context) ([]*KeyRange, error)
	CreateKeyRange(ctx context.Context, kr *KeyRange) error
	LockKeyRange(ctx context.Context, krid string) (*KeyRange, error)
	UnlockKeyRange(ctx context.Context, krid string) error
	Split(ctx context.Context, split *SplitKeyRange) error
	Unite(ctx context.Context, unite *UniteKeyRange) error
	Move(ctx context.Context, move *MoveKeyRange) error
	DropKeyRange(ctx context.Context, krid string) error
	DropKeyRangeAll(ctx context.Context) error
	BatchMoveKeyRange(ctx context.Context, req *BatchMoveKeyRange) error
	RedistributeKeyRange(ctx context.Context, req *RedistributeKeyRange) error
	RenameKeyRange(ctx context.Context, krId, krIdNew string) error
}

type MoveKeyRange

type MoveKeyRange struct {
	ShardId string
	Krid    string
}

type RedistributeKeyRange

type RedistributeKeyRange struct {
	KrId      string // KrId is the source key range id
	ShardId   string // ShardId is the destination shard id
	BatchSize int    // BatchSize is the amount of keys to be transferred in every transaction.
}

type ShardKey

type ShardKey struct {
	Name string
	RW   bool
}

type SplitKeyRange

type SplitKeyRange struct {
	Bound     [][]byte // KeyRangeBound raw
	SourceID  string
	Krid      string
	SplitLeft bool
}

type UniteKeyRange

type UniteKeyRange struct {
	BaseKeyRangeId      string
	AppendageKeyRangeId string
}

Jump to

Keyboard shortcuts

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