diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-09-07 06:51:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-06 18:51:14 -0400 |
commit | d17efaa1146bf0ec9a52b004e6d79f971253b1a2 (patch) | |
tree | 23b05001ad7b32f170b63f63a2c5509a517aec51 /vendor/go.etcd.io/bbolt/tx.go | |
parent | 1b9d5074a7ebb1b470f468cc9195d54915291ee3 (diff) | |
download | gitea-d17efaa1146bf0ec9a52b004e6d79f971253b1a2.tar.gz gitea-d17efaa1146bf0ec9a52b004e6d79f971253b1a2.zip |
Upgrade bleve to v1.0.10 (#12737)
* Fix bug on migration 111
* Upgrade bleve to 1.0.10
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'vendor/go.etcd.io/bbolt/tx.go')
-rw-r--r-- | vendor/go.etcd.io/bbolt/tx.go | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/vendor/go.etcd.io/bbolt/tx.go b/vendor/go.etcd.io/bbolt/tx.go index 13937cdbf6..4b1a64a8b8 100644 --- a/vendor/go.etcd.io/bbolt/tx.go +++ b/vendor/go.etcd.io/bbolt/tx.go @@ -4,7 +4,6 @@ import ( "fmt" "io" "os" - "reflect" "sort" "strings" "time" @@ -524,24 +523,18 @@ func (tx *Tx) write() error { // Write pages to disk in order. for _, p := range pages { - size := (int(p.overflow) + 1) * tx.db.pageSize + rem := (uint64(p.overflow) + 1) * uint64(tx.db.pageSize) offset := int64(p.id) * int64(tx.db.pageSize) + var written uintptr // Write out page in "max allocation" sized chunks. - ptr := uintptr(unsafe.Pointer(p)) for { - // Limit our write to our max allocation size. - sz := size + sz := rem if sz > maxAllocSize-1 { sz = maxAllocSize - 1 } + buf := unsafeByteSlice(unsafe.Pointer(p), written, 0, int(sz)) - // Write chunk to disk. - buf := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ - Data: ptr, - Len: sz, - Cap: sz, - })) if _, err := tx.db.ops.writeAt(buf, offset); err != nil { return err } @@ -550,14 +543,14 @@ func (tx *Tx) write() error { tx.stats.Write++ // Exit inner for loop if we've written all the chunks. - size -= sz - if size == 0 { + rem -= sz + if rem == 0 { break } // Otherwise move offset forward and move pointer to next chunk. offset += int64(sz) - ptr += uintptr(sz) + written += uintptr(sz) } } @@ -576,11 +569,7 @@ func (tx *Tx) write() error { continue } - buf := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ - Data: uintptr(unsafe.Pointer(p)), - Len: tx.db.pageSize, - Cap: tx.db.pageSize, - })) + buf := unsafeByteSlice(unsafe.Pointer(p), 0, 0, tx.db.pageSize) // See https://go.googlesource.com/go/+/f03c9202c43e0abb130669852082117ca50aa9b1 for i := range buf { |