-
-
Notifications
You must be signed in to change notification settings - Fork 527
/
Copy pathindex_lookup.go
659 lines (589 loc) · 19 KB
/
index_lookup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
// Copyright 2020 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package index
import (
"context"
"encoding/binary"
"fmt"
"io"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb/durable"
"github.com/dolthub/dolt/go/libraries/doltcore/row"
"github.com/dolthub/dolt/go/libraries/doltcore/table/typed/noms"
"github.com/dolthub/dolt/go/store/prolly"
"github.com/dolthub/dolt/go/store/prolly/tree"
"github.com/dolthub/dolt/go/store/types"
"github.com/dolthub/dolt/go/store/val"
)
func RowIterForIndexLookup(ctx *sql.Context, t DoltTableable, lookup sql.IndexLookup, pkSch sql.PrimaryKeySchema, columns []uint64) (sql.RowIter, error) {
idx := lookup.Index.(*doltIndex)
durableState, err := idx.getDurableState(ctx, t)
if err != nil {
return nil, err
}
if types.IsFormat_DOLT(idx.Format()) {
prollyRanges, err := idx.prollyRanges(ctx, idx.ns, lookup.Ranges...)
if len(prollyRanges) > 1 {
return nil, fmt.Errorf("expected a single index range")
}
if err != nil {
return nil, err
}
return RowIterForProllyRange(ctx, idx, prollyRanges[0], pkSch, columns, durableState)
} else {
nomsRanges, err := idx.nomsRanges(ctx, lookup.Ranges...)
if err != nil {
return nil, err
}
return RowIterForNomsRanges(ctx, idx, nomsRanges, columns, durableState)
}
}
func RowIterForProllyRange(ctx *sql.Context, idx DoltIndex, r prolly.Range, pkSch sql.PrimaryKeySchema, projections []uint64, durableState *durableIndexState) (sql.RowIter, error) {
if projections == nil {
projections = idx.Schema().GetAllCols().Tags
}
if sql.IsKeyless(pkSch.Schema) {
// in order to resolve row cardinality, keyless indexes must always perform
// an indirect lookup through the clustered index.
return newProllyKeylessIndexIter(ctx, idx, r, pkSch, projections, durableState.Primary, durableState.Secondary)
}
covers := idx.coversColumns(durableState, projections)
if covers {
return newProllyCoveringIndexIter(ctx, idx, r, pkSch, projections, durableState.Secondary)
}
return newProllyIndexIter(ctx, idx, r, pkSch, projections, durableState.Primary, durableState.Secondary)
}
func RowIterForNomsRanges(ctx *sql.Context, idx DoltIndex, ranges []*noms.ReadRange, columns []uint64, durableState *durableIndexState) (sql.RowIter, error) {
if len(columns) == 0 {
columns = idx.Schema().GetAllCols().Tags
}
m := durable.NomsMapFromIndex(durableState.Secondary)
nrr := noms.NewNomsRangeReader(idx.valueReadWriter(), idx.IndexSchema(), m, ranges)
covers := idx.coversColumns(durableState, columns)
if covers || idx.ID() == "PRIMARY" {
return NewCoveringIndexRowIterAdapter(ctx, idx, nrr, columns), nil
} else {
return NewIndexLookupRowIterAdapter(ctx, idx, durableState, nrr, columns)
}
}
type IndexLookupKeyIterator interface {
// NextKey returns the next key if it exists, and io.EOF if it does not.
NextKey(ctx *sql.Context) (row.TaggedValues, error)
}
func NewRangePartitionIter(ctx *sql.Context, t DoltTableable, lookup sql.IndexLookup, isDoltFmt bool) (sql.PartitionIter, error) {
idx := lookup.Index.(*doltIndex)
if lookup.IsPointLookup && isDoltFmt {
return newPointPartitionIter(ctx, lookup, idx)
}
var prollyRanges []prolly.Range
var nomsRanges []*noms.ReadRange
var err error
if isDoltFmt {
prollyRanges, err = idx.prollyRanges(ctx, idx.ns, lookup.Ranges...)
} else {
nomsRanges, err = idx.nomsRanges(ctx, lookup.Ranges...)
}
if err != nil {
return nil, err
}
return &rangePartitionIter{
nomsRanges: nomsRanges,
prollyRanges: prollyRanges,
curr: 0,
isDoltFmt: isDoltFmt,
isReverse: lookup.IsReverse,
}, nil
}
func newPointPartitionIter(ctx *sql.Context, lookup sql.IndexLookup, idx *doltIndex) (sql.PartitionIter, error) {
tb := idx.keyBld
rng := lookup.Ranges[0]
ns := idx.ns
for j, expr := range rng {
v, err := getRangeCutValue(expr.LowerBound, expr.Typ)
if err != nil {
return nil, err
}
if err = PutField(ctx, ns, tb, j, v); err != nil {
return nil, err
}
}
tup := tb.BuildPermissive(sharePool)
return &pointPartition{r: prolly.Range{Tup: tup, Desc: tb.Desc}}, nil
}
var _ sql.PartitionIter = (*pointPartition)(nil)
var _ sql.Partition = (*pointPartition)(nil)
type pointPartition struct {
r prolly.Range
used bool
}
func (p pointPartition) Key() []byte {
return []byte{0}
}
func (p *pointPartition) Close(c *sql.Context) error {
return nil
}
func (p *pointPartition) Next(c *sql.Context) (sql.Partition, error) {
if p.used {
return nil, io.EOF
}
p.used = true
return *p, nil
}
type rangePartitionIter struct {
nomsRanges []*noms.ReadRange
prollyRanges []prolly.Range
curr int
isDoltFmt bool
isReverse bool
}
// Close is required by the sql.PartitionIter interface. Does nothing.
func (itr *rangePartitionIter) Close(*sql.Context) error {
return nil
}
// Next returns the next partition if there is one, or io.EOF if there isn't.
func (itr *rangePartitionIter) Next(_ *sql.Context) (sql.Partition, error) {
if itr.isDoltFmt {
return itr.nextProllyPartition()
}
return itr.nextNomsPartition()
}
func (itr *rangePartitionIter) nextProllyPartition() (sql.Partition, error) {
if itr.curr >= len(itr.prollyRanges) {
return nil, io.EOF
}
var bytes [4]byte
binary.BigEndian.PutUint32(bytes[:], uint32(itr.curr))
pr := itr.prollyRanges[itr.curr]
itr.curr += 1
return rangePartition{
prollyRange: pr,
key: bytes[:],
isReverse: itr.isReverse,
}, nil
}
func (itr *rangePartitionIter) nextNomsPartition() (sql.Partition, error) {
if itr.curr >= len(itr.nomsRanges) {
return nil, io.EOF
}
var bytes [4]byte
binary.BigEndian.PutUint32(bytes[:], uint32(itr.curr))
nr := itr.nomsRanges[itr.curr]
itr.curr += 1
return rangePartition{
nomsRange: nr,
key: bytes[:],
isReverse: itr.isReverse,
}, nil
}
type rangePartition struct {
nomsRange *noms.ReadRange
prollyRange prolly.Range
key []byte
isReverse bool
}
func (rp rangePartition) Key() []byte {
return rp.key
}
// LookupBuilder generates secondary lookups for partitions and
// encapsulates fast path optimizations for certain point lookups.
type LookupBuilder interface {
// NewRowIter returns a new index iter for the given partition
NewRowIter(ctx *sql.Context, part sql.Partition) (sql.RowIter, error)
Key() doltdb.DataCacheKey
}
func NewLookupBuilder(
ctx *sql.Context,
tab DoltTableable,
idx DoltIndex,
key doltdb.DataCacheKey,
projections []uint64,
pkSch sql.PrimaryKeySchema,
isDoltFormat bool,
) (LookupBuilder, error) {
if projections == nil {
projections = idx.Schema().GetAllCols().Tags
}
di := idx.(*doltIndex)
s, err := di.getDurableState(ctx, tab)
if err != nil {
return nil, err
}
base := &baseLookupBuilder{
idx: di,
key: key,
sch: pkSch,
projections: projections,
}
if isDoltFormat {
base.sec = durable.ProllyMapFromIndex(s.Secondary)
base.secKd, base.secVd = base.sec.Descriptors()
base.ns = base.sec.NodeStore()
base.prefDesc = base.secKd.PrefixDesc(len(di.columns))
}
switch {
case !isDoltFormat:
return &nomsLookupBuilder{
baseLookupBuilder: base,
s: s,
}, nil
case sql.IsKeyless(pkSch.Schema):
return &keylessLookupBuilder{
baseLookupBuilder: base,
s: s,
}, nil
case idx.coversColumns(s, projections):
return newCoveringLookupBuilder(base), nil
case idx.ID() == "PRIMARY":
// If we are using the primary index, always use a covering lookup builder. In some cases, coversColumns
// can return false, for example if a column was modified in an older version and has a different tag than
// the current schema. In those cases, the primary index is still the best we have, so go ahead and use it.
return newCoveringLookupBuilder(base), nil
default:
return newNonCoveringLookupBuilder(s, base), nil
}
}
func newCoveringLookupBuilder(b *baseLookupBuilder) *coveringLookupBuilder {
var keyMap, valMap, ordMap val.OrdinalMapping
if b.idx.IsPrimaryKey() {
keyMap, valMap, ordMap = primaryIndexMapping(b.idx, b.sch, b.projections)
} else {
keyMap, ordMap = coveringIndexMapping(b.idx, b.projections)
}
return &coveringLookupBuilder{
baseLookupBuilder: b,
keyMap: keyMap,
valMap: valMap,
ordMap: ordMap,
}
}
func newNonCoveringLookupBuilder(s *durableIndexState, b *baseLookupBuilder) *nonCoveringLookupBuilder {
primary := durable.ProllyMapFromIndex(s.Primary)
priKd, _ := primary.Descriptors()
tbBld := val.NewTupleBuilder(priKd)
pkMap := ordinalMappingFromIndex(b.idx)
keyProj, valProj, ordProj := projectionMappings(b.idx.Schema(), b.projections)
return &nonCoveringLookupBuilder{
baseLookupBuilder: b,
pri: primary,
priKd: priKd,
pkBld: tbBld,
pkMap: pkMap,
keyMap: keyProj,
valMap: valProj,
ordMap: ordProj,
}
}
var _ LookupBuilder = (*baseLookupBuilder)(nil)
var _ LookupBuilder = (*nomsLookupBuilder)(nil)
var _ LookupBuilder = (*coveringLookupBuilder)(nil)
var _ LookupBuilder = (*keylessLookupBuilder)(nil)
var _ LookupBuilder = (*nonCoveringLookupBuilder)(nil)
// baseLookupBuilder is a common lookup builder for prolly covering and
// non covering index lookups.
type baseLookupBuilder struct {
key doltdb.DataCacheKey
idx *doltIndex
sch sql.PrimaryKeySchema
projections []uint64
sec prolly.Map
secKd, secVd val.TupleDesc
prefDesc val.TupleDesc
ns tree.NodeStore
}
func (lb *baseLookupBuilder) Key() doltdb.DataCacheKey {
return lb.key
}
// NewRowIter implements IndexLookup
func (lb *baseLookupBuilder) NewRowIter(ctx *sql.Context, part sql.Partition) (sql.RowIter, error) {
panic("cannot call NewRowIter on baseLookupBuilder")
}
// newPointLookup will create a cursor once, and then use the same cursor for
// every subsequent point lookup. Note that equality joins can have a mix of
// point lookups on concrete values, and range lookups for null matches.
func (lb *baseLookupBuilder) newPointLookup(ctx *sql.Context, rang prolly.Range) (iter prolly.MapIter, err error) {
err = lb.sec.GetPrefix(ctx, rang.Tup, lb.prefDesc, func(key val.Tuple, value val.Tuple) (err error) {
if key != nil && rang.Matches(key) {
iter = prolly.NewPointLookup(key, value)
} else {
iter = prolly.EmptyPointLookup
}
return
})
return
}
func (lb *baseLookupBuilder) rangeIter(ctx *sql.Context, part sql.Partition) (prolly.MapIter, error) {
switch p := part.(type) {
case pointPartition:
return lb.newPointLookup(ctx, p.r)
case rangePartition:
if p.isReverse {
return lb.sec.IterRangeReverse(ctx, p.prollyRange)
} else {
return lb.sec.IterRange(ctx, p.prollyRange)
}
default:
panic(fmt.Sprintf("unexpected prolly partition type: %T", part))
}
}
// coveringLookupBuilder constructs row iters for covering lookups,
// where we only need to cursor seek on a single index to both identify
// target keys and fill all requested projections
type coveringLookupBuilder struct {
*baseLookupBuilder
// keyMap transforms secondary index key tuples into SQL tuples.
// secondary index value tuples are assumed to be empty.
keyMap, valMap, ordMap val.OrdinalMapping
}
// NewRowIter implements IndexLookup
func (lb *coveringLookupBuilder) NewRowIter(ctx *sql.Context, part sql.Partition) (sql.RowIter, error) {
rangeIter, err := lb.rangeIter(ctx, part)
if err != nil {
return nil, err
}
return prollyCoveringIndexIter{
idx: lb.idx,
indexIter: rangeIter,
keyDesc: lb.secKd,
valDesc: lb.secVd,
keyMap: lb.keyMap,
valMap: lb.valMap,
ordMap: lb.ordMap,
sqlSch: lb.sch.Schema,
ns: lb.ns,
}, nil
}
// nonCoveringLookupBuilder constructs row iters for non-covering lookups,
// where we need to seek on the secondary table for key identity, and then
// the primary table to fill all requrested projections.
type nonCoveringLookupBuilder struct {
*baseLookupBuilder
pri prolly.Map
priKd val.TupleDesc
pkBld *val.TupleBuilder
pkMap, keyMap, valMap, ordMap val.OrdinalMapping
}
// NewRowIter implements IndexLookup
func (lb *nonCoveringLookupBuilder) NewRowIter(ctx *sql.Context, part sql.Partition) (sql.RowIter, error) {
rangeIter, err := lb.rangeIter(ctx, part)
if err != nil {
return nil, err
}
return prollyIndexIter{
idx: lb.idx,
indexIter: rangeIter,
primary: lb.pri,
pkBld: lb.pkBld,
pkMap: lb.pkMap,
keyMap: lb.keyMap,
valMap: lb.valMap,
ordMap: lb.ordMap,
sqlSch: lb.sch.Schema,
}, nil
}
// TODO keylessLookupBuilder should be similar to the non-covering
// index case, where we will need to reference the primary index,
// but can take advantage of point lookup optimizations
type keylessLookupBuilder struct {
*baseLookupBuilder
s *durableIndexState
}
// NewRowIter implements IndexLookup
func (lb *keylessLookupBuilder) NewRowIter(ctx *sql.Context, part sql.Partition) (sql.RowIter, error) {
var prollyRange prolly.Range
switch p := part.(type) {
case rangePartition:
prollyRange = p.prollyRange
case pointPartition:
prollyRange = p.r
}
return newProllyKeylessIndexIter(ctx, lb.idx, prollyRange, lb.sch, lb.projections, lb.s.Primary, lb.s.Secondary)
}
type nomsLookupBuilder struct {
*baseLookupBuilder
s *durableIndexState
}
// NewRowIter implements IndexLookup
func (lb *nomsLookupBuilder) NewRowIter(ctx *sql.Context, part sql.Partition) (sql.RowIter, error) {
p := part.(rangePartition)
ranges := []*noms.ReadRange{p.nomsRange}
return RowIterForNomsRanges(ctx, lb.idx, ranges, lb.projections, lb.s)
}
// boundsCase determines the case upon which the bounds are tested.
type boundsCase byte
// For each boundsCase, the first element is the lowerbound and the second element is the upperbound
const (
boundsCase_infinity_infinity boundsCase = iota
boundsCase_infinity_lessEquals
boundsCase_infinity_less
boundsCase_greaterEquals_infinity
boundsCase_greaterEquals_lessEquals
boundsCase_greaterEquals_less
boundsCase_greater_infinity
boundsCase_greater_lessEquals
boundsCase_greater_less
boundsCase_isNull
)
// columnBounds are used to compare a given value in the noms row iterator.
type columnBounds struct {
boundsCase
lowerbound types.Value
upperbound types.Value
}
// nomsRangeCheck is used to compare a tuple against a set of comparisons in the noms row iterator.
type nomsRangeCheck []columnBounds
var _ noms.InRangeCheck = nomsRangeCheck{}
// Between returns whether the given types.Value is between the bounds. In addition, this returns if the value is outside
// the bounds and above the upperbound.
func (cb columnBounds) Between(ctx context.Context, vr types.ValueReader, val types.Value) (ok bool, over bool, err error) {
// Only boundCase_isNull matches NULL values,
// otherwise we terminate the range scan.
// This is checked early to bypass unpredictable
// null type comparisons.
if val.Kind() == types.NullKind {
isNullCase := cb.boundsCase == boundsCase_isNull
return isNullCase, !isNullCase, nil
}
switch cb.boundsCase {
case boundsCase_infinity_infinity:
return true, false, nil
case boundsCase_infinity_lessEquals:
ok, err := cb.upperbound.Less(ctx, vr.Format(), val)
if err != nil || ok {
return false, true, err
}
case boundsCase_infinity_less:
ok, err := val.Less(ctx, vr.Format(), cb.upperbound)
if err != nil || !ok {
return false, true, err
}
case boundsCase_greaterEquals_infinity:
ok, err := val.Less(ctx, vr.Format(), cb.lowerbound)
if err != nil || ok {
return false, false, err
}
case boundsCase_greaterEquals_lessEquals:
ok, err := val.Less(ctx, vr.Format(), cb.lowerbound)
if err != nil || ok {
return false, false, err
}
ok, err = cb.upperbound.Less(ctx, vr.Format(), val)
if err != nil || ok {
return false, true, err
}
case boundsCase_greaterEquals_less:
ok, err := val.Less(ctx, vr.Format(), cb.lowerbound)
if err != nil || ok {
return false, false, err
}
ok, err = val.Less(ctx, vr.Format(), cb.upperbound)
if err != nil || !ok {
return false, true, err
}
case boundsCase_greater_infinity:
ok, err := cb.lowerbound.Less(ctx, vr.Format(), val)
if err != nil || !ok {
return false, false, err
}
case boundsCase_greater_lessEquals:
ok, err := cb.lowerbound.Less(ctx, vr.Format(), val)
if err != nil || !ok {
return false, false, err
}
ok, err = cb.upperbound.Less(ctx, vr.Format(), val)
if err != nil || ok {
return false, true, err
}
case boundsCase_greater_less:
ok, err := cb.lowerbound.Less(ctx, vr.Format(), val)
if err != nil || !ok {
return false, false, err
}
ok, err = val.Less(ctx, vr.Format(), cb.upperbound)
if err != nil || !ok {
return false, true, err
}
case boundsCase_isNull:
// an isNull scan skips non-nulls, but does not terminate
return false, false, nil
default:
return false, false, fmt.Errorf("unknown bounds")
}
return true, false, nil
}
// Equals returns whether the calling columnBounds is equivalent to the given columnBounds.
func (cb columnBounds) Equals(otherBounds columnBounds) bool {
if cb.boundsCase != otherBounds.boundsCase {
return false
}
if cb.lowerbound == nil || otherBounds.lowerbound == nil {
if cb.lowerbound != nil || otherBounds.lowerbound != nil {
return false
}
} else if !cb.lowerbound.Equals(otherBounds.lowerbound) {
return false
}
if cb.upperbound == nil || otherBounds.upperbound == nil {
if cb.upperbound != nil || otherBounds.upperbound != nil {
return false
}
} else if !cb.upperbound.Equals(otherBounds.upperbound) {
return false
}
return true
}
// Check implements the interface noms.InRangeCheck.
func (nrc nomsRangeCheck) Check(ctx context.Context, vr types.ValueReader, tuple types.Tuple) (valid bool, skip bool, err error) {
itr := types.TupleItrPool.Get().(*types.TupleIterator)
defer types.TupleItrPool.Put(itr)
err = itr.InitForTuple(tuple)
if err != nil {
return false, false, err
}
for i := 0; i < len(nrc) && itr.HasMore(); i++ {
if err := itr.Skip(); err != nil {
return false, false, err
}
_, val, err := itr.Next()
if err != nil {
return false, false, err
}
if val == nil {
break
}
ok, over, err := nrc[i].Between(ctx, vr, val)
if err != nil {
return false, false, err
}
if !ok {
return i != 0 || !over, true, nil
}
}
return true, false, nil
}
// Equals returns whether the calling nomsRangeCheck is equivalent to the given nomsRangeCheck.
func (nrc nomsRangeCheck) Equals(otherNrc nomsRangeCheck) bool {
if len(nrc) != len(otherNrc) {
return false
}
for i := range nrc {
if !nrc[i].Equals(otherNrc[i]) {
return false
}
}
return true
}
type nomsKeyIter interface {
ReadKey(ctx context.Context) (types.Tuple, error)
}