浏览代码

Update goleveldb (fixes #1414)

Jakob Borg 10 年之前
父节点
当前提交
2fdc578a88

+ 1 - 1
Godeps/Godeps.json

@@ -35,7 +35,7 @@
 		},
 		{
 			"ImportPath": "github.com/syndtr/goleveldb/leveldb",
-			"Rev": "63c9e642efad852f49e20a6f90194cae112fd2ac"
+			"Rev": "e3f32eb300aa1e514fe8ba58d008da90a062273d"
 		},
 		{
 			"ImportPath": "github.com/syndtr/gosnappy/snappy",

+ 1 - 1
Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/go13_bench_test.go → Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/bench2_test.go

@@ -4,7 +4,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// +build go1.3
+// +build !go1.2
 
 package leveldb
 

+ 30 - 0
Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/cache/bench2_test.go

@@ -0,0 +1,30 @@
+// Copyright (c) 2012, Suryandaru Triandana <[email protected]>
+// 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()
+		}
+	})
+}

+ 0 - 16
Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/cache/cache_test.go

@@ -552,19 +552,3 @@ func TestLRUCache_Close(t *testing.T) {
 		t.Errorf("delFunc isn't called 1 times: got=%d", delFuncCalled)
 	}
 }
-
-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()
-		}
-	})
-}

+ 8 - 6
Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db.go

@@ -347,12 +347,14 @@ func recoverTable(s *session, o *opt.Options) error {
 			return err
 		}
 		iter := tr.NewIterator(nil, nil)
-		iter.(iterator.ErrorCallbackSetter).SetErrorCallback(func(err error) {
-			if errors.IsCorrupted(err) {
-				s.logf("table@recovery block corruption @%d %q", file.Num(), err)
-				tcorruptedBlock++
-			}
-		})
+		if itererr, ok := iter.(iterator.ErrorCallbackSetter); ok {
+			itererr.SetErrorCallback(func(err error) {
+				if errors.IsCorrupted(err) {
+					s.logf("table@recovery block corruption @%d %q", file.Num(), err)
+					tcorruptedBlock++
+				}
+			})
+		}
 
 		// Scan the table.
 		for iter.Next() {