From add99ed57efb52416ee8931fa5a67e706ce089a2 Mon Sep 17 00:00:00 2001 From: chrislusf Date: Fri, 27 Mar 2015 16:29:13 -0700 Subject: [PATCH] Add tool to see idx file contents --- unmaintained/see_idx/see_idx.go | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 unmaintained/see_idx/see_idx.go diff --git a/unmaintained/see_idx/see_idx.go b/unmaintained/see_idx/see_idx.go new file mode 100644 index 000000000..fb79f9d13 --- /dev/null +++ b/unmaintained/see_idx/see_idx.go @@ -0,0 +1,38 @@ +package main + +import ( + "flag" + "os" + "path" + "strconv" + + "github.com/chrislusf/weed-fs/go/glog" + "github.com/chrislusf/weed-fs/go/storage" +) + +var ( + fixVolumePath = flag.String("dir", "/tmp", "data directory to store files") + fixVolumeCollection = flag.String("collection", "", "the volume collection name") + fixVolumeId = flag.Int("volumeId", -1, "a volume id. The volume should already exist in the dir. The volume index file should not exist.") +) + +/* +This is to see content in .idx files. + + see_idx -v=4 -volumeId=9 -dir=/Users/chrislu/Downloads +*/ +func main() { + flag.Parse() + fileName := strconv.Itoa(*fixVolumeId) + if *fixVolumeCollection != "" { + fileName = *fixVolumeCollection + "_" + fileName + } + indexFile, err := os.OpenFile(path.Join(*fixVolumePath, fileName+".idx"), os.O_RDONLY, 0644) + if err != nil { + glog.Fatalf("Create Volume Index [ERROR] %s\n", err) + } + defer indexFile.Close() + + storage.LoadNeedleMap(indexFile) + +}