ranger

package
v0.0.0-...-3633c1a Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeUnsupportedType terror.ErrCode = 1
)

Error codes.

Variables

View Source
var (
	ErrUnsupportedType = terror.ClassOptimizer.New(CodeUnsupportedType, "Unsupported type")
)

Error instances.

Functions

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.

func HandlePadCharToFullLength

func HandlePadCharToFullLength(sc *stmtctx.StatementContext, ft *types.FieldType, val types.Datum) (types.Datum, error)

HandlePadCharToFullLength handles the "PAD_CHAR_TO_FULL_LENGTH" sql mode for CHAR[N] index columns. NOTE: kv.ErrNotExist is returned to indicate that this value can not match

any (key, value) pair in tikv storage. This error should be handled by
the caller.

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 (*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) 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