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

@@ -36,22 +36,23 @@ func NewMem() *MemFS {
// at which point they are discarded and no longer visible.
//
// Expected usage:
// strictFS := NewStrictMem()
// db := Open(..., &Options{FS: strictFS})
// // Do and commit various operations.
// ...
// // Prevent any more changes to finalized state.
// strictFS.SetIgnoreSyncs(true)
// // This will finish any ongoing background flushes, compactions but none of these writes will
// // be finalized since syncs are being ignored.
// db.Close()
// // Discard unsynced state.
// strictFS.ResetToSyncedState()
// // Allow changes to finalized state.
// strictFS.SetIgnoreSyncs(false)
// // Open the DB. This DB should have the same state as if the earlier strictFS operations and
// // db.Close() were not called.
// db := Open(..., &Options{FS: strictFS})
//
// strictFS := NewStrictMem()
// db := Open(..., &Options{FS: strictFS})
// // Do and commit various operations.
// ...
// // Prevent any more changes to finalized state.
// strictFS.SetIgnoreSyncs(true)
// // This will finish any ongoing background flushes, compactions but none of these writes will
// // be finalized since syncs are being ignored.
// db.Close()
// // Discard unsynced state.
// strictFS.ResetToSyncedState()
// // Allow changes to finalized state.
// strictFS.SetIgnoreSyncs(false)
// // Open the DB. This DB should have the same state as if the earlier strictFS operations and
// // db.Close() were not called.
// db := Open(..., &Options{FS: strictFS})
func NewStrictMem() *MemFS {
return &MemFS{
root: newRootMemNode(),
@@ -141,6 +142,7 @@ func (y *MemFS) ResetToSyncedState() {
// - "/", "foo", false
// - "/foo/", "bar", false
// - "/foo/bar/", "x", true
//
// Similarly, walking "/y/z/", with a trailing slash, will result in 3 calls to f:
// - "/", "y", false
// - "/y/", "z", false
@@ -624,6 +626,8 @@ type memFile struct {
read, write bool
}
var _ File = (*memFile)(nil)
func (f *memFile) Close() error {
if n := atomic.AddInt32(&f.n.refs, -1); n < 0 {
panic(fmt.Sprintf("pebble: close of unopened file: %d", n))
@@ -661,7 +665,11 @@ func (f *memFile) ReadAt(p []byte, off int64) (int, error) {
if off >= int64(len(f.n.mu.data)) {
return 0, io.EOF
}
return copy(p, f.n.mu.data[off:]), nil
n := copy(p, f.n.mu.data[off:])
if n < len(p) {
return n, io.EOF
}
return n, nil
}
func (f *memFile) Write(p []byte) (int, error) {
@@ -694,6 +702,9 @@ func (f *memFile) Write(p []byte) (int, error) {
return len(p), nil
}
func (f *memFile) Prefetch(offset int64, length int64) error { return nil }
func (f *memFile) Preallocate(offset, length int64) error { return nil }
func (f *memFile) Stat() (os.FileInfo, error) {
return f.n, nil
}
@@ -719,6 +730,22 @@ func (f *memFile) Sync() error {
return nil
}
func (f *memFile) SyncData() error {
return f.Sync()
}
func (f *memFile) SyncTo(length int64) (fullSync bool, err error) {
// NB: This SyncTo implementation lies, with its return values claiming it
// synced the data up to `length`. When fullSync=false, SyncTo provides no
// durability guarantees, so this can help surface bugs where we improperly
// rely on SyncTo providing durability.
return false, nil
}
func (f *memFile) Fd() uintptr {
return InvalidFd
}
// Flush is a no-op and present only to prevent buffering at higher levels
// (e.g. it prevents sstable.Writer from using a bufio.Writer).
func (f *memFile) Flush() error {