read_index.go 565 B

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