ranger

package
v3.1.0-fork Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Error instances.

Functions

func CutDatumByPrefixLen

func CutDatumByPrefixLen(v *types.Datum, length int, tp *types.FieldType) bool

CutDatumByPrefixLen cuts the datum according to the prefix length. If it's UTF8 encoded, we will cut it by characters rather than bytes.

func DetachCondsForColumn

func DetachCondsForColumn(sctx sessionctx.Context, conds []expression.Expression, col *expression.Column) (accessConditions, otherConditions []expression.Expression)

DetachCondsForColumn detaches access conditions for specified column from other filter conditions.

func ExtractAccessConditionsForColumn

func ExtractAccessConditionsForColumn(conds []expression.Expression, uniqueID int64) []expression.Expression

ExtractAccessConditionsForColumn extracts the access conditions used for range calculation. Since we don't need to return the remained filter conditions, it is much simpler than DetachCondsForColumn.

func ExtractEqAndInCondition

func ExtractEqAndInCondition(sctx sessionctx.Context, conditions []expression.Expression,
	cols []*expression.Column, lengths []int) ([]expression.Expression, []expression.Expression, []expression.Expression, bool)

ExtractEqAndInCondition will split the given condition into three parts by the information of index columns and their lengths. accesses: The condition will be used to build range. filters: filters is the part that some access conditions need to be evaluate again since it's only the prefix part of char column. newConditions: We'll simplify the given conditions if there're multiple in conditions or eq conditions on the same column.

e.g. if there're a in (1, 2, 3) and a in (2, 3, 4). This two will be combined to a in (2, 3) and pushed to newConditions.

bool: indicate whether there's nil range when merging eq and in conditions.

Types

type DetachRangeResult

type DetachRangeResult struct {
	// Ranges is the ranges extracted and built from conditions.
	Ranges []*Range
	// AccessConds is the extracted conditions for access.
	AccessConds []expression.Expression
	// RemainedConds is the filter conditions which should be kept after access.
	RemainedConds []expression.Expression
	// EqCondCount is the number of equal conditions extracted.
	EqCondCount int
	// EqOrInCount is the number of equal/in conditions extracted.
	EqOrInCount int
	// IsDNFCond indicates if the top layer of conditions are in DNF.
	IsDNFCond bool
}

DetachRangeResult wraps up results when detaching conditions and builing ranges.

func DetachCondAndBuildRangeForIndex

func DetachCondAndBuildRangeForIndex(sctx sessionctx.Context, conditions []expression.Expression, cols []*expression.Column,
	lengths []int) (*DetachRangeResult, error)

DetachCondAndBuildRangeForIndex will detach the index filters from table filters. The returned values are encapsulated into a struct DetachRangeResult, see its comments for explanation.

type Range

type Range struct {
	LowVal  []types.Datum
	HighVal []types.Datum

	LowExclude  bool // Low value is exclusive.
	HighExclude bool // High value is exclusive.
}

Range represents a range generated in physical plan building phase.

func BuildColumnRange

func BuildColumnRange(conds []expression.Expression, sc *stmtctx.StatementContext, tp *types.FieldType, colLen int) ([]*Range, error)

BuildColumnRange builds range from access conditions for general columns.

func BuildTableRange

func BuildTableRange(accessConditions []expression.Expression, sc *stmtctx.StatementContext, tp *types.FieldType) ([]*Range, error)

BuildTableRange builds range of PK column for PhysicalTableScan.

func DetachSimpleCondAndBuildRangeForIndex

func DetachSimpleCondAndBuildRangeForIndex(sctx sessionctx.Context, conditions []expression.Expression,
	cols []*expression.Column, lengths []int) ([]*Range, []expression.Expression, error)

DetachSimpleCondAndBuildRangeForIndex will detach the index filters from table filters. It will find the point query column firstly and then extract the range query column.

func FullIntRange

func FullIntRange(isUnsigned bool) []*Range

FullIntRange is used for table range. Since table range cannot accept MaxValueDatum as the max value. So we need to set it to MaxInt64.

func FullNotNullRange

func FullNotNullRange() []*Range

FullNotNullRange is (-∞, +∞) for Range.

func FullRange

func FullRange() []*Range

FullRange is [null, +∞) for Range.

func NullRange

func NullRange() []*Range

NullRange is [null, null] for Range.

func UnionRanges

func UnionRanges(sc *stmtctx.StatementContext, ranges []*Range) ([]*Range, error)

UnionRanges sorts `ranges`, union adjacent ones if possible. For two intervals [a, b], [c, d], we have guaranteed that a <= c. If b >= c. Then two intervals are overlapped. And this two can be merged as [a, max(b, d)]. Otherwise they aren't overlapped.

func (*Range) Clone

func (ran *Range) Clone() *Range

Clone clones a Range.

func (*Range) Encode

func (ran *Range) Encode(sc *stmtctx.StatementContext, lowBuffer, highBuffer []byte) ([]byte, []byte, error)

Encode encodes the range to its encoded value.

func (*Range) IsFullRange

func (ran *Range) IsFullRange() bool

IsFullRange check if the range is full scan range

func (*Range) IsPoint

func (ran *Range) IsPoint(sc *stmtctx.StatementContext) bool

IsPoint returns if the range is a point.

func (*Range) PrefixEqualLen

func (ran *Range) PrefixEqualLen(sc *stmtctx.StatementContext) (int, error)

PrefixEqualLen tells you how long the prefix of the range is a point. e.g. If this range is (1 2 3, 1 2 +inf), then the return value is 2.

func (*Range) String

func (ran *Range) String() string

String implements the Stringer interface.

type RangeType

type RangeType int

RangeType is alias for int.

const (
	IntRangeType RangeType = iota
	ColumnRangeType
	IndexRangeType
)

RangeType constants.

Jump to

Keyboard shortcuts

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