kr

package
v0.0.0-...-f948758 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: PostgreSQL Imports: 9 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(ds *distributions.Distribution, rel *distributions.DistributedRelation, kRange *KeyRange, upperBound KeyRangeBound, prefix string) string

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 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) 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
}

type MoveKeyRange

type MoveKeyRange struct {
	ShardId string
	Krid    string
}

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