Skip to content

Commit

Permalink
Merge pull request #8280 from dolthub/daylon/revert-changes
Browse files Browse the repository at this point in the history
[no-release-notes] Revert PR causing index issues
  • Loading branch information
Hydrocharged authored Aug 16, 2024
2 parents bea0d0d + 277c1d7 commit d56e177
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 40 deletions.
24 changes: 3 additions & 21 deletions go/libraries/doltcore/sqle/index/dolt_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/sqle/index/index_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/sqle/kvexec/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 1 addition & 9 deletions go/store/prolly/tuple_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions go/store/prolly/tuple_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d56e177

Please sign in to comment.