You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
675 B

7 years ago
7 years ago
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "log"
  6. "os"
  7. "github.com/chrislusf/seaweedfs/weed/storage"
  8. "github.com/chrislusf/seaweedfs/weed/storage/types"
  9. )
  10. var (
  11. indexFileName = flag.String("file", "", ".idx file to analyze")
  12. )
  13. func main() {
  14. flag.Parse()
  15. indexFile, err := os.OpenFile(*indexFileName, os.O_RDONLY, 0644)
  16. if err != nil {
  17. log.Fatalf("Create Volume Index [ERROR] %s\n", err)
  18. }
  19. defer indexFile.Close()
  20. storage.WalkIndexFile(indexFile, func(key types.NeedleId, offset types.Offset, size uint32) error {
  21. fmt.Printf("key %d, offset %d, size %d, nextOffset %d\n", key, offset*8, size, int64(offset)*types.NeedlePaddingSize+int64(size))
  22. return nil
  23. })
  24. }