0

Upgrade versions of vendored libs

This commit is contained in:
eleksir
2023-05-18 23:55:10 +03:00
parent 4869c146fe
commit 7958db9c0d
555 changed files with 36170 additions and 15565 deletions

View File

@@ -5,10 +5,10 @@
package pebble
import (
"context"
"fmt"
"io"
"sort"
"sync/atomic"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/pebble/internal/base"
@@ -59,7 +59,7 @@ type simpleMergingIterLevel struct {
type simpleMergingIter struct {
levels []simpleMergingIterLevel
snapshot uint64
heap mergingIterHeap
heap simpleMergingIterHeap
// The last point's key and level. For validation.
lastKey InternalKey
lastLevel int
@@ -86,12 +86,12 @@ func (m *simpleMergingIter) init(
m.snapshot = snapshot
m.lastLevel = -1
m.heap.cmp = cmp
m.heap.items = make([]mergingIterItem, 0, len(levels))
m.heap.items = make([]simpleMergingIterItem, 0, len(levels))
for i := range m.levels {
l := &m.levels[i]
l.iterKey, l.iterValue = l.iter.First()
if l.iterKey != nil {
item := mergingIterItem{
item := simpleMergingIterItem{
index: i,
value: l.iterValue,
}
@@ -117,7 +117,7 @@ func (m *simpleMergingIter) positionRangeDels() {
if l.rangeDelIter == nil {
continue
}
l.tombstone = keyspan.SeekGE(m.heap.cmp, l.rangeDelIter, item.key.UserKey)
l.tombstone = l.rangeDelIter.SeekGE(item.key.UserKey)
}
}
@@ -378,7 +378,8 @@ func checkRangeTombstones(c *checkConfig) error {
lf := files.Take()
atomicUnit, _ := expandToAtomicUnit(c.cmp, lf.Slice(), true /* disableIsCompacting */)
lower, upper := manifest.KeyRange(c.cmp, atomicUnit.Iter())
iterToClose, iter, err := c.newIters(lf.FileMetadata, nil, internalIterOpts{})
iterToClose, iter, err := c.newIters(
context.Background(), lf.FileMetadata, nil, internalIterOpts{})
if err != nil {
return err
}
@@ -554,11 +555,11 @@ type CheckLevelsStats struct {
}
// CheckLevels checks:
// - Every entry in the DB is consistent with the level invariant. See the
// comment at the top of the file.
// - Point keys in sstables are ordered.
// - Range delete tombstones in sstables are ordered and fragmented.
// - Successful processing of all MERGE records.
// - Every entry in the DB is consistent with the level invariant. See the
// comment at the top of the file.
// - Point keys in sstables are ordered.
// - Range delete tombstones in sstables are ordered and fragmented.
// - Successful processing of all MERGE records.
func (d *DB) CheckLevels(stats *CheckLevelsStats) error {
// Grab and reference the current readState.
readState := d.loadReadState()
@@ -566,7 +567,7 @@ func (d *DB) CheckLevels(stats *CheckLevelsStats) error {
// Determine the seqnum to read at after grabbing the read state (current and
// memtables) above.
seqNum := atomic.LoadUint64(&d.mu.versions.atomic.visibleSeqNum)
seqNum := d.mu.versions.visibleSeqNum.Load()
checkConfig := &checkConfig{
logger: d.opts.Logger,
@@ -638,7 +639,7 @@ func checkLevelsInternal(c *checkConfig) (err error) {
manifestIter := current.L0SublevelFiles[sublevel].Iter()
iterOpts := IterOptions{logger: c.logger}
li := &levelIter{}
li.init(iterOpts, c.cmp, nil /* split */, c.newIters, manifestIter,
li.init(context.Background(), iterOpts, c.cmp, nil /* split */, c.newIters, manifestIter,
manifest.L0Sublevel(sublevel), internalIterOpts{})
li.initRangeDel(&mlevelAlloc[0].rangeDelIter)
li.initBoundaryContext(&mlevelAlloc[0].levelIterBoundaryContext)
@@ -652,7 +653,7 @@ func checkLevelsInternal(c *checkConfig) (err error) {
iterOpts := IterOptions{logger: c.logger}
li := &levelIter{}
li.init(iterOpts, c.cmp, nil /* split */, c.newIters,
li.init(context.Background(), iterOpts, c.cmp, nil /* split */, c.newIters,
current.Levels[level].Iter(), manifest.Level(level), internalIterOpts{})
li.initRangeDel(&mlevelAlloc[0].rangeDelIter)
li.initBoundaryContext(&mlevelAlloc[0].levelIterBoundaryContext)
@@ -674,3 +675,92 @@ func checkLevelsInternal(c *checkConfig) (err error) {
// Phase 2: Check that the tombstones are mutually consistent.
return checkRangeTombstones(c)
}
type simpleMergingIterItem struct {
index int
key InternalKey
value base.LazyValue
}
type simpleMergingIterHeap struct {
cmp Compare
reverse bool
items []simpleMergingIterItem
}
func (h *simpleMergingIterHeap) len() int {
return len(h.items)
}
func (h *simpleMergingIterHeap) less(i, j int) bool {
ikey, jkey := h.items[i].key, h.items[j].key
if c := h.cmp(ikey.UserKey, jkey.UserKey); c != 0 {
if h.reverse {
return c > 0
}
return c < 0
}
if h.reverse {
return ikey.Trailer < jkey.Trailer
}
return ikey.Trailer > jkey.Trailer
}
func (h *simpleMergingIterHeap) swap(i, j int) {
h.items[i], h.items[j] = h.items[j], h.items[i]
}
// init, fix, up and down are copied from the go stdlib.
func (h *simpleMergingIterHeap) init() {
// heapify
n := h.len()
for i := n/2 - 1; i >= 0; i-- {
h.down(i, n)
}
}
func (h *simpleMergingIterHeap) fix(i int) {
if !h.down(i, h.len()) {
h.up(i)
}
}
func (h *simpleMergingIterHeap) pop() *simpleMergingIterItem {
n := h.len() - 1
h.swap(0, n)
h.down(0, n)
item := &h.items[n]
h.items = h.items[:n]
return item
}
func (h *simpleMergingIterHeap) up(j int) {
for {
i := (j - 1) / 2 // parent
if i == j || !h.less(j, i) {
break
}
h.swap(i, j)
j = i
}
}
func (h *simpleMergingIterHeap) down(i0, n int) bool {
i := i0
for {
j1 := 2*i + 1
if j1 >= n || j1 < 0 { // j1 < 0 after int overflow
break
}
j := j1 // left child
if j2 := j1 + 1; j2 < n && h.less(j2, j1) {
j = j2 // = 2*i + 2 // right child
}
if !h.less(j, i) {
break
}
h.swap(i, j)
i = j
}
return i > i0
}