From fbbd510088031f2460619c9e5280463cc27e65c8 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 6 Jul 2016 09:56:45 +0200 Subject: [PATCH] vendor: Update to latest github.com/syndtr/goleveldb --- vendor/github.com/syndtr/goleveldb/README.md | 105 ------------------ .../syndtr/goleveldb/leveldb/batch.go | 1 + .../syndtr/goleveldb/leveldb/batch_test.go | 3 + .../syndtr/goleveldb/leveldb/bench2_test.go | 58 ---------- .../goleveldb/leveldb/cache/bench2_test.go | 30 ----- .../syndtr/goleveldb/leveldb/db_compaction.go | 4 +- .../leveldb/storage/file_storage_nacl.go | 34 ++++++ .../syndtr/goleveldb/leveldb/util/hash.go | 28 ++--- .../goleveldb/leveldb/util/hash_test.go | 46 ++++++++ .../syndtr/goleveldb/leveldb/util/pool.go | 21 ---- .../goleveldb/leveldb/util/pool_legacy.go | 33 ------ vendor/manifest | 2 +- 12 files changed, 101 insertions(+), 264 deletions(-) delete mode 100644 vendor/github.com/syndtr/goleveldb/README.md delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/bench2_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/cache/bench2_test.go create mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_nacl.go create mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/hash_test.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/pool.go delete mode 100644 vendor/github.com/syndtr/goleveldb/leveldb/util/pool_legacy.go diff --git a/vendor/github.com/syndtr/goleveldb/README.md b/vendor/github.com/syndtr/goleveldb/README.md deleted file mode 100644 index 259286f55..000000000 --- a/vendor/github.com/syndtr/goleveldb/README.md +++ /dev/null @@ -1,105 +0,0 @@ -This is an implementation of the [LevelDB key/value database](http:code.google.com/p/leveldb) in the [Go programming language](http:golang.org). - -[![Build Status](https://travis-ci.org/syndtr/goleveldb.png?branch=master)](https://travis-ci.org/syndtr/goleveldb) - -Installation ------------ - - go get github.com/syndtr/goleveldb/leveldb - -Requirements ------------ - -* Need at least `go1.4` or newer. - -Usage ------------ - -Create or open a database: -```go -db, err := leveldb.OpenFile("path/to/db", nil) -... -defer db.Close() -... -``` -Read or modify the database content: -```go -// Remember that the contents of the returned slice should not be modified. -data, err := db.Get([]byte("key"), nil) -... -err = db.Put([]byte("key"), []byte("value"), nil) -... -err = db.Delete([]byte("key"), nil) -... -``` - -Iterate over database content: -```go -iter := db.NewIterator(nil, nil) -for iter.Next() { - // Remember that the contents of the returned slice should not be modified, and - // only valid until the next call to Next. - key := iter.Key() - value := iter.Value() - ... -} -iter.Release() -err = iter.Error() -... -``` -Seek-then-Iterate: -```go -iter := db.NewIterator(nil, nil) -for ok := iter.Seek(key); ok; ok = iter.Next() { - // Use key/value. - ... -} -iter.Release() -err = iter.Error() -... -``` -Iterate over subset of database content: -```go -iter := db.NewIterator(&util.Range{Start: []byte("foo"), Limit: []byte("xoo")}, nil) -for iter.Next() { - // Use key/value. - ... -} -iter.Release() -err = iter.Error() -... -``` -Iterate over subset of database content with a particular prefix: -```go -iter := db.NewIterator(util.BytesPrefix([]byte("foo-")), nil) -for iter.Next() { - // Use key/value. - ... -} -iter.Release() -err = iter.Error() -... -``` -Batch writes: -```go -batch := new(leveldb.Batch) -batch.Put([]byte("foo"), []byte("value")) -batch.Put([]byte("bar"), []byte("another value")) -batch.Delete([]byte("baz")) -err = db.Write(batch, nil) -... -``` -Use bloom filter: -```go -o := &opt.Options{ - Filter: filter.NewBloomFilter(10), -} -db, err := leveldb.OpenFile("path/to/db", o) -... -defer db.Close() -... -``` -Documentation ------------ - -You can read package documentation [here](http:godoc.org/github.com/syndtr/goleveldb). diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/batch.go b/vendor/github.com/syndtr/goleveldb/leveldb/batch.go index 652fa4124..501006717 100644 --- a/vendor/github.com/syndtr/goleveldb/leveldb/batch.go +++ b/vendor/github.com/syndtr/goleveldb/leveldb/batch.go @@ -158,6 +158,7 @@ func (b *Batch) append(p *Batch) { b.grow(len(p.data) - batchHdrLen) b.data = append(b.data, p.data[batchHdrLen:]...) b.rLen += p.rLen + b.bLen += p.bLen } if p.sync { b.sync = true diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/batch_test.go b/vendor/github.com/syndtr/goleveldb/leveldb/batch_test.go index 3504f08b3..ce0925e08 100644 --- a/vendor/github.com/syndtr/goleveldb/leveldb/batch_test.go +++ b/vendor/github.com/syndtr/goleveldb/leveldb/batch_test.go @@ -100,6 +100,9 @@ func TestBatch_Append(t *testing.T) { b2b.Put([]byte("bar"), []byte("barvalue")) b2a.append(b2b) compareBatch(t, b1, b2a) + if b1.size() != b2a.size() { + t.Fatalf("invalid batch size want %d, got %d", b1.size(), b2a.size()) + } } func TestBatch_Size(t *testing.T) { diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/bench2_test.go b/vendor/github.com/syndtr/goleveldb/leveldb/bench2_test.go deleted file mode 100644 index 0dd60fd82..000000000 --- a/vendor/github.com/syndtr/goleveldb/leveldb/bench2_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2012, Suryandaru Triandana -// All rights reserved. -// -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// +build !go1.2 - -package leveldb - -import ( - "sync/atomic" - "testing" -) - -func BenchmarkDBReadConcurrent(b *testing.B) { - p := openDBBench(b, false) - p.populate(b.N) - p.fill() - p.gc() - defer p.close() - - b.ResetTimer() - b.SetBytes(116) - - b.RunParallel(func(pb *testing.PB) { - iter := p.newIter() - defer iter.Release() - for pb.Next() && iter.Next() { - } - }) -} - -func BenchmarkDBReadConcurrent2(b *testing.B) { - p := openDBBench(b, false) - p.populate(b.N) - p.fill() - p.gc() - defer p.close() - - b.ResetTimer() - b.SetBytes(116) - - var dir uint32 - b.RunParallel(func(pb *testing.PB) { - iter := p.newIter() - defer iter.Release() - if atomic.AddUint32(&dir, 1)%2 == 0 { - for pb.Next() && iter.Next() { - } - } else { - if pb.Next() && iter.Last() { - for pb.Next() && iter.Prev() { - } - } - } - }) -} diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/cache/bench2_test.go b/vendor/github.com/syndtr/goleveldb/leveldb/cache/bench2_test.go deleted file mode 100644 index 175e22203..000000000 --- a/vendor/github.com/syndtr/goleveldb/leveldb/cache/bench2_test.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2012, Suryandaru Triandana -// All rights reserved. -// -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// +build !go1.2 - -package cache - -import ( - "math/rand" - "testing" -) - -func BenchmarkLRUCache(b *testing.B) { - c := NewCache(NewLRU(10000)) - - b.SetParallelism(10) - b.RunParallel(func(pb *testing.PB) { - r := rand.New(rand.NewSource(time.Now().UnixNano())) - - for pb.Next() { - key := uint64(r.Intn(1000000)) - c.Get(0, key, func() (int, Value) { - return 1, key - }).Release() - } - }) -} diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go index 9664e64d0..659f00dc6 100644 --- a/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go +++ b/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go @@ -172,7 +172,7 @@ func (db *DB) compactionTransact(name string, t compactionTransactInterface) { disableBackoff = db.s.o.GetDisableCompactionBackoff() ) for n := 0; ; n++ { - // Check wether the DB is closed. + // Check whether the DB is closed. if db.isClosed() { db.logf("%s exiting", name) db.compactionExitTransact() @@ -688,7 +688,7 @@ func (db *DB) compTrigger(compC chan<- cCmd) { } } -// This will trigger auto compation and/or wait for all compaction to be done. +// This will trigger auto compaction and/or wait for all compaction to be done. func (db *DB) compTriggerWait(compC chan<- cCmd) (err error) { ch := make(chan error) defer close(ch) diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_nacl.go b/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_nacl.go new file mode 100644 index 000000000..5545aeef2 --- /dev/null +++ b/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_nacl.go @@ -0,0 +1,34 @@ +// Copyright (c) 2012, Suryandaru Triandana +// All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// +build nacl + +package storage + +import ( + "os" + "syscall" +) + +func newFileLock(path string, readOnly bool) (fl fileLock, err error) { + return nil, syscall.ENOTSUP +} + +func setFileLock(f *os.File, readOnly, lock bool) error { + return syscall.ENOTSUP +} + +func rename(oldpath, newpath string) error { + return syscall.ENOTSUP +} + +func isErrInvalid(err error) bool { + return false +} + +func syncDir(name string) error { + return syscall.ENOTSUP +} diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go b/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go index 54903660f..7f3fa4e2c 100644 --- a/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go +++ b/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go @@ -7,38 +7,38 @@ package util import ( - "bytes" "encoding/binary" ) // Hash return hash of the given data. func Hash(data []byte, seed uint32) uint32 { // Similar to murmur hash - var m uint32 = 0xc6a4a793 - var r uint32 = 24 - h := seed ^ (uint32(len(data)) * m) + const ( + m = uint32(0xc6a4a793) + r = uint32(24) + ) + var ( + h = seed ^ (uint32(len(data)) * m) + i int + ) - buf := bytes.NewBuffer(data) - for buf.Len() >= 4 { - var w uint32 - binary.Read(buf, binary.LittleEndian, &w) - h += w + for n := len(data) - len(data)%4; i < n; i += 4 { + h += binary.LittleEndian.Uint32(data[i:]) h *= m h ^= (h >> 16) } - rest := buf.Bytes() - switch len(rest) { + switch len(data) - i { default: panic("not reached") case 3: - h += uint32(rest[2]) << 16 + h += uint32(data[i+2]) << 16 fallthrough case 2: - h += uint32(rest[1]) << 8 + h += uint32(data[i+1]) << 8 fallthrough case 1: - h += uint32(rest[0]) + h += uint32(data[i]) h *= m h ^= (h >> r) case 0: diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/util/hash_test.go b/vendor/github.com/syndtr/goleveldb/leveldb/util/hash_test.go new file mode 100644 index 000000000..a35d273ee --- /dev/null +++ b/vendor/github.com/syndtr/goleveldb/leveldb/util/hash_test.go @@ -0,0 +1,46 @@ +// Copyright (c) 2012, Suryandaru Triandana +// All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package util + +import ( + "testing" +) + +var hashTests = []struct { + data []byte + seed uint32 + hash uint32 +}{ + {nil, 0xbc9f1d34, 0xbc9f1d34}, + {[]byte{0x62}, 0xbc9f1d34, 0xef1345c4}, + {[]byte{0xc3, 0x97}, 0xbc9f1d34, 0x5b663814}, + {[]byte{0xe2, 0x99, 0xa5}, 0xbc9f1d34, 0x323c078f}, + {[]byte{0xe1, 0x80, 0xb9, 0x32}, 0xbc9f1d34, 0xed21633a}, + {[]byte{ + 0x01, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x14, + 0x00, 0x00, 0x00, 0x18, + 0x28, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }, 0x12345678, 0xf333dabb}, +} + +func TestHash(t *testing.T) { + for i, x := range hashTests { + h := Hash(x.data, x.seed) + if h != x.hash { + t.Fatalf("test-%d: invalid hash, %#x vs %#x", i, h, x.hash) + } + } +} diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/util/pool.go b/vendor/github.com/syndtr/goleveldb/leveldb/util/pool.go deleted file mode 100644 index 1f7fdd41f..000000000 --- a/vendor/github.com/syndtr/goleveldb/leveldb/util/pool.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2014, Suryandaru Triandana -// All rights reserved. -// -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// +build go1.3 - -package util - -import ( - "sync" -) - -type Pool struct { - sync.Pool -} - -func NewPool(cap int) *Pool { - return &Pool{} -} diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/util/pool_legacy.go b/vendor/github.com/syndtr/goleveldb/leveldb/util/pool_legacy.go deleted file mode 100644 index 27b8d03be..000000000 --- a/vendor/github.com/syndtr/goleveldb/leveldb/util/pool_legacy.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2014, Suryandaru Triandana -// All rights reserved. -// -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// +build !go1.3 - -package util - -type Pool struct { - pool chan interface{} -} - -func (p *Pool) Get() interface{} { - select { - case x := <-p.pool: - return x - default: - return nil - } -} - -func (p *Pool) Put(x interface{}) { - select { - case p.pool <- x: - default: - } -} - -func NewPool(cap int) *Pool { - return &Pool{pool: make(chan interface{}, cap)} -} diff --git a/vendor/manifest b/vendor/manifest index 5c175278e..2de298784 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -196,7 +196,7 @@ { "importpath": "github.com/syndtr/goleveldb", "repository": "https://github.com/syndtr/goleveldb", - "revision": "917f41c560270110ceb73c5b38be2a9127387071", + "revision": "ab8b5dcf1042e818ab68e770d465112a899b668e", "branch": "master" }, {