-
Notifications
You must be signed in to change notification settings - Fork 468
/
overlap.go
67 lines (58 loc) · 2.04 KB
/
overlap.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
// Copyright 2024 The LevelDB-Go and Pebble Authors. All rights reserved. Use
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
package pebble
import (
"context"
"github.com/cockroachdb/pebble/internal/base"
"github.com/cockroachdb/pebble/internal/keyspan"
"github.com/cockroachdb/pebble/internal/manifest"
"github.com/cockroachdb/pebble/internal/overlap"
)
// An overlapChecker provides facilities for checking whether any keys within a
// particular LSM version overlap a set of bounds. It is a thin wrapper for
// dataoverlap.Checker.
type overlapChecker struct {
comparer *base.Comparer
newIters tableNewIters
opts IterOptions
v *version
}
// DetermineLSMOverlap calculates the overlap.WithLSM for the given bounds.
func (c *overlapChecker) DetermineLSMOverlap(
ctx context.Context, bounds base.UserKeyBounds,
) (overlap.WithLSM, error) {
checker := overlap.MakeChecker(c.comparer.Compare, c)
return checker.LSMOverlap(ctx, bounds, c.v)
}
var _ overlap.IteratorFactory = (*overlapChecker)(nil)
// Points is part of the overlap.IteratorFactory implementation.
func (c *overlapChecker) Points(
ctx context.Context, m *manifest.FileMetadata,
) (base.InternalIterator, error) {
iters, err := c.newIters(ctx, m, &c.opts, internalIterOpts{}, iterPointKeys)
if err != nil {
return nil, err
}
return iters.point, nil
}
// RangeDels is part of the overlap.IteratorFactory implementation.
func (c *overlapChecker) RangeDels(
ctx context.Context, m *manifest.FileMetadata,
) (keyspan.FragmentIterator, error) {
iters, err := c.newIters(ctx, m, &c.opts, internalIterOpts{}, iterRangeDeletions)
if err != nil {
return nil, err
}
return iters.rangeDeletion, nil
}
// RangeKeys is part of the overlap.IteratorFactory implementation.
func (c *overlapChecker) RangeKeys(
ctx context.Context, m *manifest.FileMetadata,
) (keyspan.FragmentIterator, error) {
iters, err := c.newIters(ctx, m, &c.opts, internalIterOpts{}, iterRangeKeys)
if err != nil {
return nil, err
}
return iters.rangeKey, nil
}