From f95c25e113c2c19353d91ad61e533567dfa877ba Mon Sep 17 00:00:00 2001 From: Guo Lei Date: Thu, 13 Oct 2022 13:59:07 +0800 Subject: [PATCH] types packages is imported more than onece (#3838) --- weed/storage/needle_map_leveldb.go | 9 ++++----- weed/storage/volume_vacuum.go | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/weed/storage/needle_map_leveldb.go b/weed/storage/needle_map_leveldb.go index 30ed96c3b..1566ca7a0 100644 --- a/weed/storage/needle_map_leveldb.go +++ b/weed/storage/needle_map_leveldb.go @@ -10,7 +10,6 @@ import ( "github.com/syndtr/goleveldb/leveldb/opt" "github.com/seaweedfs/seaweedfs/weed/storage/idx" - "github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/seaweedfs/seaweedfs/weed/util" "github.com/syndtr/goleveldb/leveldb" @@ -56,7 +55,7 @@ func NewLevelDbNeedleMap(dbFileName string, indexFile *os.File, opts *opt.Option } } glog.V(0).Infof("Loading %s... , watermark: %d", dbFileName, getWatermark(m.db)) - m.recordCount = uint64(m.indexFileOffset / types.NeedleMapEntrySize) + m.recordCount = uint64(m.indexFileOffset / NeedleMapEntrySize) watermark := (m.recordCount / watermarkBatchSize) * watermarkBatchSize err = setWatermark(m.db, watermark) if err != nil { @@ -100,10 +99,10 @@ func generateLevelDbFile(dbFileName string, indexFile *os.File) error { glog.Fatalf("stat file %s: %v", indexFile.Name(), err) return err } else { - if watermark*types.NeedleMapEntrySize > uint64(stat.Size()) { + if watermark*NeedleMapEntrySize > uint64(stat.Size()) { glog.Warningf("wrong watermark %d for filesize %d", watermark, stat.Size()) } - glog.V(0).Infof("generateLevelDbFile %s, watermark %d, num of entries:%d", dbFileName, watermark, (uint64(stat.Size())-watermark*types.NeedleMapEntrySize)/types.NeedleMapEntrySize) + glog.V(0).Infof("generateLevelDbFile %s, watermark %d, num of entries:%d", dbFileName, watermark, (uint64(stat.Size())-watermark*NeedleMapEntrySize)/NeedleMapEntrySize) } return idx.WalkIndexFile(indexFile, watermark, func(key NeedleId, offset Offset, size Size) error { if !offset.IsZero() && size.IsValid() { @@ -270,7 +269,7 @@ func (m *LevelDbNeedleMap) UpdateNeedleMap(v *Volume, indexFile *os.File, opts * return e } m.indexFileOffset = stat.Size() - m.recordCount = uint64(stat.Size() / types.NeedleMapEntrySize) + m.recordCount = uint64(stat.Size() / NeedleMapEntrySize) //set watermark watermark := (m.recordCount / watermarkBatchSize) * watermarkBatchSize diff --git a/weed/storage/volume_vacuum.go b/weed/storage/volume_vacuum.go index 38b5c0080..47b0800eb 100644 --- a/weed/storage/volume_vacuum.go +++ b/weed/storage/volume_vacuum.go @@ -13,7 +13,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/storage/needle" "github.com/seaweedfs/seaweedfs/weed/storage/needle_map" "github.com/seaweedfs/seaweedfs/weed/storage/super_block" - "github.com/seaweedfs/seaweedfs/weed/storage/types" . "github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/seaweedfs/seaweedfs/weed/util" ) @@ -341,7 +340,7 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI } } - return v.tmpNm.DoOffsetLoading(v, idx, uint64(idxSize)/types.NeedleMapEntrySize) + return v.tmpNm.DoOffsetLoading(v, idx, uint64(idxSize)/NeedleMapEntrySize) } type VolumeFileScanner4Vacuum struct {