mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
avoid extra log messages
fix https://github.com/chrislusf/seaweedfs/issues/689
This commit is contained in:
parent
9e974f6a1b
commit
a51aa4c586
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
||||||
. "github.com/chrislusf/seaweedfs/weed/storage/types"
|
. "github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BoltDbNeedleMap struct {
|
type BoltDbNeedleMap struct {
|
||||||
|
@ -20,6 +21,8 @@ type BoltDbNeedleMap struct {
|
||||||
|
|
||||||
var boltdbBucket = []byte("weed")
|
var boltdbBucket = []byte("weed")
|
||||||
|
|
||||||
|
var NotFound = errors.New("not found")
|
||||||
|
|
||||||
// TODO avoid using btree to count deletions.
|
// TODO avoid using btree to count deletions.
|
||||||
func NewBoltDbNeedleMap(dbFileName string, indexFile *os.File) (m *BoltDbNeedleMap, err error) {
|
func NewBoltDbNeedleMap(dbFileName string, indexFile *os.File) (m *BoltDbNeedleMap, err error) {
|
||||||
m = &BoltDbNeedleMap{dbFileName: dbFileName}
|
m = &BoltDbNeedleMap{dbFileName: dbFileName}
|
||||||
|
@ -88,9 +91,13 @@ func (m *BoltDbNeedleMap) Get(key NeedleId) (element *needle.NeedleValue, ok boo
|
||||||
|
|
||||||
data := bucket.Get(bytes)
|
data := bucket.Get(bytes)
|
||||||
|
|
||||||
|
if len(data) == 0 {
|
||||||
|
return NotFound
|
||||||
|
}
|
||||||
|
|
||||||
if len(data) != OffsetSize+SizeSize {
|
if len(data) != OffsetSize+SizeSize {
|
||||||
glog.V(0).Infof("wrong data length: %d", len(data))
|
glog.V(0).Infof("key:%v has wrong data length: %d", key, len(data))
|
||||||
return fmt.Errorf("wrong data length: %d", len(data))
|
return fmt.Errorf("key:%v has wrong data length: %d", key, len(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = BytesToOffset(data[0:OffsetSize])
|
offset = BytesToOffset(data[0:OffsetSize])
|
||||||
|
@ -102,7 +109,7 @@ func (m *BoltDbNeedleMap) Get(key NeedleId) (element *needle.NeedleValue, ok boo
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
return &needle.NeedleValue{Key: NeedleId(key), Offset: offset, Size: size}, true
|
return &needle.NeedleValue{Key: key, Offset: offset, Size: size}, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *BoltDbNeedleMap) Put(key NeedleId, offset Offset, size uint32) error {
|
func (m *BoltDbNeedleMap) Put(key NeedleId, offset Offset, size uint32) error {
|
||||||
|
|
Loading…
Reference in a new issue