volume: sdx generation uses memdb instead of compactMap

fix https://github.com/chrislusf/seaweedfs/issues/1194
This commit is contained in:
Chris Lu 2020-02-04 21:12:09 -08:00
parent 08e4702542
commit c1288e9eb4

View file

@ -5,12 +5,13 @@ import (
"io" "io"
"os" "os"
"github.com/klauspost/reedsolomon"
"github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/storage/idx" "github.com/chrislusf/seaweedfs/weed/storage/idx"
"github.com/chrislusf/seaweedfs/weed/storage/needle_map" "github.com/chrislusf/seaweedfs/weed/storage/needle_map"
"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"
"github.com/klauspost/reedsolomon"
) )
const ( const (
@ -280,14 +281,14 @@ func rebuildEcFiles(shardHasData []bool, inputFiles []*os.File, outputFiles []*o
} }
func readCompactMap(baseFileName string) (*needle_map.CompactMap, error) { func readCompactMap(baseFileName string) (*needle_map.MemDb, error) {
indexFile, err := os.OpenFile(baseFileName+".idx", os.O_RDONLY, 0644) indexFile, err := os.OpenFile(baseFileName+".idx", os.O_RDONLY, 0644)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot read Volume Index %s.idx: %v", baseFileName, err) return nil, fmt.Errorf("cannot read Volume Index %s.idx: %v", baseFileName, err)
} }
defer indexFile.Close() defer indexFile.Close()
cm := needle_map.NewCompactMap() cm := needle_map.NewMemDb()
err = idx.WalkIndexFile(indexFile, func(key types.NeedleId, offset types.Offset, size uint32) error { err = idx.WalkIndexFile(indexFile, func(key types.NeedleId, offset types.Offset, size uint32) error {
if !offset.IsZero() && size != types.TombstoneFileSize { if !offset.IsZero() && size != types.TombstoneFileSize {
cm.Set(key, offset, size) cm.Set(key, offset, size)