chunk

package
v0.0.0-...-b679430 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitChunk

func InitChunk(chunk *Range, t Type, firstBucketID, lastBucketID int, collation, limits string)

InitChunk initialize the chunk

func InitChunks

func InitChunks(chunks []*Range, t Type, firstBucketID, lastBucketID int, index int, collation, limits string, chunkCnt int)

InitChunks init the given chunks Notice: chunk may contain not only one bucket, which can be expressed as a range [3, 5],

And `lastBucketID` means the `5` and `firstBucketID` means the `3`.

Types

type Bound

type Bound struct {
	Column string `json:"column"`
	Lower  string `json:"lower"`
	Upper  string `json:"upper"`

	HasLower bool `json:"has-lower"`
	HasUpper bool `json:"has-upper"`
}

Bound represents a bound for a column

type CID

type CID struct {
	TableIndex int `json:"table-index"`
	// we especially treat random split has only one bucket
	// which is the whole table
	// range is [left, right]
	BucketIndexLeft  int `json:"bucket-index-left"`
	BucketIndexRight int `json:"bucket-index-right"`
	ChunkIndex       int `json:"chunk-index"`
	//  `ChunkCnt` is the number of chunks in this bucket
	//  We can compare `ChunkIndex` and `ChunkCnt` to know
	// whether this chunk is the last one
	ChunkCnt int `json:"chunk-count"`
}

CID is to identify the sequence of chunks

func GetInitChunkID

func GetInitChunkID() *CID

GetInitChunkID return an empty CID

func (*CID) Compare

func (c *CID) Compare(o *CID) int

Compare compare two CIDs

func (*CID) Copy

func (c *CID) Copy() *CID

Copy return a same CID

func (*CID) FromString

func (c *CID) FromString(s string) error

FromString get CID from given string

func (*CID) ToString

func (c *CID) ToString() string

ToString return string for CID

type Range

type Range struct {
	Index   *CID     `json:"index"`
	Type    Type     `json:"type"`
	Bounds  []*Bound `json:"bounds"`
	IsFirst bool     `json:"is-first"`
	IsLast  bool     `json:"is-last"`

	Where string        `json:"where"`
	Args  []interface{} `json:"args"`
	// contains filtered or unexported fields
}

Range represents chunk range

func NewChunkRange

func NewChunkRange() *Range

NewChunkRange return a Range.

func NewChunkRangeOffset

func NewChunkRangeOffset(columnOffset map[string]int) *Range

NewChunkRangeOffset return a Range in sequence

func (*Range) Clone

func (r *Range) Clone() *Range

Clone return a new range

func (*Range) Copy

func (r *Range) Copy() *Range

Copy return a new range

func (*Range) CopyAndUpdate

func (r *Range) CopyAndUpdate(column, lower, upper string, updateLower, updateUpper bool) *Range

CopyAndUpdate update the range

func (*Range) IsFirstChunkForBucket

func (r *Range) IsFirstChunkForBucket() bool

IsFirstChunkForBucket return true if it's the first chunk

func (*Range) IsFirstChunkForTable

func (r *Range) IsFirstChunkForTable() bool

IsFirstChunkForTable return true if it's the first chunk

func (*Range) IsLastChunkForBucket

func (r *Range) IsLastChunkForBucket() bool

IsLastChunkForBucket return true if it's the last chunk

func (*Range) IsLastChunkForTable

func (r *Range) IsLastChunkForTable() bool

IsLastChunkForTable return true if it's the last chunk

func (*Range) String

func (r *Range) String() string

String returns the string of Range, used for log.

func (*Range) ToMeta

func (r *Range) ToMeta() string

ToMeta return string for range

func (*Range) ToString

func (r *Range) ToString(collation string) (string, []interface{})

ToString return string for range

func (*Range) Update

func (r *Range) Update(column, lower, upper string, updateLower, updateUpper bool)

Update update the range

type Type

type Type int

Type is the type of the chunk

const (
	Bucket Type = iota + 1
	Random
	Limit
	Others
	Empty
)

List all chunk types

Jump to

Keyboard shortcuts

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