SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
fix boltdb variable usage
Chris Lu69b9d8c3c25f
diff --git a/weed/storage/needle_map_boltdb.go b/weed/storage/needle_map_boltdb.goindex 96c29cab64..cd15607bb2 100644--- a/weed/storage/needle_map_boltdb.go+++ b/weed/storage/needle_map_boltdb.go@@ -75,8 +75,8 @@ func generateBoltDbFile(dbFileName string, indexFile *os.File) error {}func (m *BoltDbNeedleMap) Get(key uint64) (element *needle.NeedleValue, ok bool) {+ var offset, size uint32bytes := make([]byte, 8)- var data []byteutil.Uint64toBytes(bytes, key)err := m.db.View(func(tx *bolt.Tx) error {bucket := tx.Bucket(boltdbBucket)@@ -84,15 +84,22 @@ func (m *BoltDbNeedleMap) Get(key uint64) (element *needle.NeedleValue, ok bool)return fmt.Errorf("Bucket %q not found!", boltdbBucket)}- data = bucket.Get(bytes)+ data := bucket.Get(bytes)++ if len(data) != 8 {+ glog.V(0).Infof("wrong data length: %d", len(data))+ return fmt.Errorf("wrong data length: %d", len(data))+ }++ offset = util.BytesToUint32(data[0:4])+ size = util.BytesToUint32(data[4:8])+return nil})- if err != nil || len(data) != 8 {+ if err != nil {return nil, false}- offset := util.BytesToUint32(data[0:4])- size := util.BytesToUint32(data[4:8])return &needle.NeedleValue{Key: needle.Key(key), Offset: offset, Size: size}, true}