mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-15 00:50:22 -06:00
Revert "Skip filterIter match check when a key range is contiguous (#8242)"
This reverts commit c33943f6b8.
This commit is contained in:
@@ -1206,12 +1206,7 @@ func (di *doltIndex) prollyRangesFromSqlRanges(ctx context.Context, ns tree.Node
|
||||
pranges := make([]prolly.Range, len(ranges))
|
||||
for k, rng := range ranges {
|
||||
fields := make([]prolly.RangeField, len(rng))
|
||||
onlyPreciseTypes := true
|
||||
for j, expr := range rng {
|
||||
if !(sqltypes.IsInteger(expr.Typ) || sqltypes.IsText(expr.Typ)) {
|
||||
// decimal, float, datetime are imperfectly serialized
|
||||
onlyPreciseTypes = false
|
||||
}
|
||||
if rangeCutIsBinding(expr.LowerBound) {
|
||||
// accumulate bound values in |tb|
|
||||
v, err := getRangeCutValue(expr.LowerBound, rng[j].Typ)
|
||||
@@ -1271,8 +1266,6 @@ func (di *doltIndex) prollyRangesFromSqlRanges(ctx context.Context, ns tree.Node
|
||||
}
|
||||
|
||||
order := di.keyBld.Desc.Comparator()
|
||||
var foundDiscontinuity bool
|
||||
var isContiguous bool = true
|
||||
for i, field := range fields {
|
||||
// lookups on non-unique indexes can't be point lookups
|
||||
typ := di.keyBld.Desc.Types[i]
|
||||
@@ -1286,22 +1279,11 @@ func (di *doltIndex) prollyRangesFromSqlRanges(ctx context.Context, ns tree.Node
|
||||
// infinity bound
|
||||
fields[i].BoundsAreEqual = false
|
||||
}
|
||||
|
||||
nilBound := field.Lo.Value == nil && field.Hi.Value == nil
|
||||
if foundDiscontinuity || nilBound {
|
||||
// A discontinous variable followed by any restriction
|
||||
// can partition the key space.
|
||||
isContiguous = false
|
||||
}
|
||||
foundDiscontinuity = foundDiscontinuity || !fields[i].BoundsAreEqual || nilBound
|
||||
|
||||
}
|
||||
pranges[k] = prolly.Range{
|
||||
Fields: fields,
|
||||
Desc: di.keyBld.Desc,
|
||||
Tup: tup,
|
||||
PreciseTypes: onlyPreciseTypes,
|
||||
IsContiguous: isContiguous,
|
||||
Fields: fields,
|
||||
Desc: di.keyBld.Desc,
|
||||
Tup: tup,
|
||||
}
|
||||
}
|
||||
return pranges, nil
|
||||
|
||||
@@ -421,7 +421,7 @@ type coveringIndexImplBuilder struct {
|
||||
keyMap, valMap, ordMap val.OrdinalMapping
|
||||
}
|
||||
|
||||
func NewSequenceRangeIter(ctx context.Context, ib IndexScanBuilder, ranges []prolly.Range, reverse bool) (prolly.MapIter, error) {
|
||||
func NewSequenceMapIter(ctx context.Context, ib IndexScanBuilder, ranges []prolly.Range, reverse bool) (prolly.MapIter, error) {
|
||||
if len(ranges) == 0 {
|
||||
return &strictLookupIter{}, nil
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ func getSourceKv(ctx *sql.Context, n sql.Node, isSrc bool) (prolly.Map, prolly.M
|
||||
return prolly.Map{}, nil, nil, nil, nil, nil, err
|
||||
}
|
||||
|
||||
srcIter, err = index.NewSequenceRangeIter(ctx, lb, prollyRanges, l.IsReverse)
|
||||
srcIter, err = index.NewSequenceMapIter(ctx, lb, prollyRanges, l.IsReverse)
|
||||
if err != nil {
|
||||
return prolly.Map{}, nil, nil, nil, nil, nil, err
|
||||
}
|
||||
|
||||
@@ -314,15 +314,7 @@ func (m Map) IterRange(ctx context.Context, rng Range) (iter MapIter, err error)
|
||||
} else {
|
||||
iter, err = treeIterFromRange(ctx, m.tuples.Root, m.tuples.NodeStore, rng)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !rng.PreciseTypes || !rng.IsContiguous {
|
||||
// range.Matches check is required if a type is imprecise
|
||||
// or a key range is non-contiguous on disk
|
||||
iter = filteredIter{iter: iter, rng: rng}
|
||||
}
|
||||
return iter, nil
|
||||
return filteredIter{iter: iter, rng: rng}, nil
|
||||
}
|
||||
|
||||
// IterRangeReverse returns a mutableMapIter that iterates over a Range backwards.
|
||||
|
||||
@@ -58,14 +58,6 @@ type Range struct {
|
||||
Fields []RangeField
|
||||
Desc val.TupleDesc
|
||||
Tup val.Tuple
|
||||
// PreciseTypes is false if any type in the range
|
||||
// expression can be serialized with a loss of precision.
|
||||
PreciseTypes bool
|
||||
// IsContiguous indicates whether this range expression is a
|
||||
// single contiguous set of keys on disk. Permit a sequence of
|
||||
// (1) zero or more equality restrictions, (2) zero or one
|
||||
// non-equality, and (3) no further restrictions.
|
||||
IsContiguous bool
|
||||
}
|
||||
|
||||
// RangeField bounds one dimension of a Range.
|
||||
|
||||
Reference in New Issue
Block a user