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.

43 lines
1.1 KiB

  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "path"
  6. "strconv"
  7. "github.com/chrislusf/seaweedfs/weed/glog"
  8. "github.com/chrislusf/seaweedfs/weed/storage"
  9. "fmt"
  10. "github.com/chrislusf/seaweedfs/weed/storage/types"
  11. )
  12. var (
  13. fixVolumePath = flag.String("dir", "/tmp", "data directory to store files")
  14. fixVolumeCollection = flag.String("collection", "", "the volume collection name")
  15. fixVolumeId = flag.Int("volumeId", -1, "a volume id. The volume should already exist in the dir. The volume index file should not exist.")
  16. )
  17. /*
  18. This is to see content in .idx files.
  19. see_idx -v=4 -volumeId=9 -dir=/Users/chrislu/Downloads
  20. */
  21. func main() {
  22. flag.Parse()
  23. fileName := strconv.Itoa(*fixVolumeId)
  24. if *fixVolumeCollection != "" {
  25. fileName = *fixVolumeCollection + "_" + fileName
  26. }
  27. indexFile, err := os.OpenFile(path.Join(*fixVolumePath, fileName+".idx"), os.O_RDONLY, 0644)
  28. if err != nil {
  29. glog.Fatalf("Create Volume Index [ERROR] %s\n", err)
  30. }
  31. defer indexFile.Close()
  32. storage.WalkIndexFile(indexFile, func(key types.NeedleId, offset types.Offset, size uint32) error {
  33. fmt.Printf("key:%v offset:%v size:%v\n", key, offset, size)
  34. return nil
  35. })
  36. }