Documentation ¶
Index ¶
- func CutDatumByPrefixLen(v *types.Datum, length int, tp *types.FieldType) bool
- func DetachCondsForColumn(sctx sessionctx.Context, conds []expression.Expression, col *expression.Column) (accessConditions, otherConditions []expression.Expression)
- func ExtractAccessConditionsForColumn(conds []expression.Expression, uniqueID int64) []expression.Expression
- func ExtractEqAndInCondition(sctx sessionctx.Context, conditions []expression.Expression, ...) ([]expression.Expression, []expression.Expression, []expression.Expression, ...)
- func HasFullRange(ranges []*Range) bool
- func MergeDNFItems4Col(ctx sessionctx.Context, dnfItems []expression.Expression) []expression.Expression
- func ReachPrefixLen(v *types.Datum, length int, tp *types.FieldType) bool
- type DetachRangeResult
- type Key
- type Range
- func BuildColumnRange(conds []expression.Expression, sc *stmtctx.StatementContext, ...) ([]*Range, error)
- func BuildTableRange(accessConditions []expression.Expression, sc *stmtctx.StatementContext, ...) ([]*Range, error)
- func FullIntRange(isUnsigned bool) []*Range
- func FullNotNullRange() []*Range
- func FullRange() []*Range
- func UnionRanges(sc *stmtctx.StatementContext, ranges []*Range, mergeConsecutive bool) ([]*Range, error)
- func (ran *Range) Clone() *Range
- func (ran *Range) Encode(sc *stmtctx.StatementContext, lowBuffer, highBuffer []byte) ([]byte, []byte, error)
- func (ran *Range) IsFullRange() bool
- func (ran *Range) IsPoint(sc *stmtctx.StatementContext) bool
- func (ran *Range) IsPointNullable(sc *stmtctx.StatementContext) bool
- func (ran *Range) PrefixEqualLen(sc *stmtctx.StatementContext) (int, error)
- func (ran *Range) String() string
- type RangeType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CutDatumByPrefixLen ¶
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.
func HasFullRange ¶
HasFullRange checks if any range in the slice is a full range.
func MergeDNFItems4Col ¶
func MergeDNFItems4Col(ctx sessionctx.Context, dnfItems []expression.Expression) []expression.Expression
MergeDNFItems4Col receives a slice of DNF conditions, merges some of them which can be built into ranges on a single column, then returns. For example, [a > 5, b > 6, c > 7, a = 1, b > 3] will become [a > 5 or a = 1, b > 6 or b > 3, c > 7].
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 Key ¶
type Key []byte
Key represents high-level Key type.
func (Key) PrefixNext ¶
PrefixNext returns the next prefix key.
Assume there are keys like:
rowkey1 rowkey1_column1 rowkey1_column2 rowKey2
If we seek 'rowkey1' Next, we will get 'rowkey1_column1'. If we seek 'rowkey1' PrefixNext, we will get 'rowkey2'.
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 FullIntRange ¶
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 UnionRanges ¶
func UnionRanges(sc *stmtctx.StatementContext, ranges []*Range, mergeConsecutive bool) ([]*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) 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 ¶
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) IsPointNullable ¶
func (ran *Range) IsPointNullable(sc *stmtctx.StatementContext) bool
IsPointNullable 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.