From 277c1d7d8b42de4338b06305cc4d78c90755c775 Mon Sep 17 00:00:00 2001 From: Daylon Wilkins Date: Fri, 16 Aug 2024 04:26:58 -0700 Subject: [PATCH] Revert "Skip filterIter match check when a key range is contiguous (#8242)" This reverts commit c33943f6b888e60bd33dffba01e7794a3847cdc1. --- .../doltcore/sqle/index/dolt_index.go | 24 +++---------------- .../doltcore/sqle/index/index_reader.go | 2 +- go/libraries/doltcore/sqle/kvexec/builder.go | 2 +- go/store/prolly/tuple_map.go | 10 +------- go/store/prolly/tuple_range.go | 8 ------- 5 files changed, 6 insertions(+), 40 deletions(-) diff --git a/go/libraries/doltcore/sqle/index/dolt_index.go b/go/libraries/doltcore/sqle/index/dolt_index.go index 134bc413847..9f06bcd732d 100644 --- a/go/libraries/doltcore/sqle/index/dolt_index.go +++ b/go/libraries/doltcore/sqle/index/dolt_index.go @@ -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 diff --git a/go/libraries/doltcore/sqle/index/index_reader.go b/go/libraries/doltcore/sqle/index/index_reader.go index e30a6ad3aae..b33f446c294 100644 --- a/go/libraries/doltcore/sqle/index/index_reader.go +++ b/go/libraries/doltcore/sqle/index/index_reader.go @@ -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 } diff --git a/go/libraries/doltcore/sqle/kvexec/builder.go b/go/libraries/doltcore/sqle/kvexec/builder.go index af0cd870798..ae22c10553f 100644 --- a/go/libraries/doltcore/sqle/kvexec/builder.go +++ b/go/libraries/doltcore/sqle/kvexec/builder.go @@ -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 } diff --git a/go/store/prolly/tuple_map.go b/go/store/prolly/tuple_map.go index ececf4eb251..1323ea1d5db 100644 --- a/go/store/prolly/tuple_map.go +++ b/go/store/prolly/tuple_map.go @@ -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. diff --git a/go/store/prolly/tuple_range.go b/go/store/prolly/tuple_range.go index 844d568714a..32af35dbcf3 100644 --- a/go/store/prolly/tuple_range.go +++ b/go/store/prolly/tuple_range.go @@ -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.