From e2849a36e5922767220b97e9e620edc58c9484ac Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 9 Jul 2018 22:48:30 -0700 Subject: [PATCH] fix compilation errors --- unmaintained/fix_dat/fix_dat.go | 9 +++++---- unmaintained/see_idx/see_idx.go | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/unmaintained/fix_dat/fix_dat.go b/unmaintained/fix_dat/fix_dat.go index 8cc6a93d8..10dd94810 100644 --- a/unmaintained/fix_dat/fix_dat.go +++ b/unmaintained/fix_dat/fix_dat.go @@ -11,6 +11,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/storage" "github.com/chrislusf/seaweedfs/weed/util" + "github.com/chrislusf/seaweedfs/weed/storage/types" ) var ( @@ -105,8 +106,8 @@ func iterateEntries(datFile, idxFile *os.File, visitNeedle func(n *storage.Needl fmt.Printf("key: %d offsetFromIndex %d n.Size %d sizeFromIndex:%d\n", key, offsetFromIndex, n.Size, sizeFromIndex) - padding := storage.NeedlePaddingSize - ((sizeFromIndex + storage.NeedleHeaderSize + storage.NeedleChecksumSize) % storage.NeedlePaddingSize) - rest = sizeFromIndex + storage.NeedleChecksumSize + padding + padding := types.NeedlePaddingSize - ((sizeFromIndex + types.NeedleEntrySize + storage.NeedleChecksumSize) % types.NeedlePaddingSize) + rest = int64(sizeFromIndex + storage.NeedleChecksumSize + padding) func() { defer func() { @@ -114,7 +115,7 @@ func iterateEntries(datFile, idxFile *os.File, visitNeedle func(n *storage.Needl fmt.Println("Recovered in f", r) } }() - if err = n.ReadNeedleBody(datFile, version, offset+int64(storage.NeedleHeaderSize), rest); err != nil { + if err = n.ReadNeedleBody(datFile, version, offset+int64(types.NeedleEntrySize), rest); err != nil { fmt.Printf("cannot read needle body: offset %d body %d %v\n", offset, rest, err) } }() @@ -124,7 +125,7 @@ func iterateEntries(datFile, idxFile *os.File, visitNeedle func(n *storage.Needl } visitNeedle(n, offset) - offset += int64(storage.NeedleHeaderSize) + int64(rest) + offset += types.NeedleEntrySize + rest //fmt.Printf("==> new entry offset %d\n", offset) if n, rest, err = storage.ReadNeedleHeader(datFile, version, offset); err != nil { if err == io.EOF { diff --git a/unmaintained/see_idx/see_idx.go b/unmaintained/see_idx/see_idx.go index e7735b9a1..9e8133dde 100644 --- a/unmaintained/see_idx/see_idx.go +++ b/unmaintained/see_idx/see_idx.go @@ -8,6 +8,8 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/storage" + "fmt" + "github.com/chrislusf/seaweedfs/weed/storage/types" ) var ( @@ -33,6 +35,9 @@ func main() { } defer indexFile.Close() - storage.LoadNeedleMap(indexFile) + storage.WalkIndexFile(indexFile, func(key types.NeedleId, offset types.Offset, size uint32) error { + fmt.Printf("key:%v offset:%v size:%v\n", key, offset, size) + return nil + }) }