예제 #1
0
파일: command.go 프로젝트: jaeyeom/sstable
// convert converts a RecordIO to SSTable.
func convert(from, to string) {
	f, err := os.Open(from)
	if err != nil {
		log.Println("Error on opening path", from, ":", err)
		return
	}
	defer f.Close()
	info, err := f.Stat()
	if err != nil {
		log.Println("Error on stating path", from, ":", err)
		return
	}
	size := info.Size()
	if size < 0 {
		log.Println("Size is negative on path", from)
		return
	}
	t, err := os.Create(to)
	if err != nil {
		log.Println("Error on creating path", to, ":", err)
		return
	}
	w := sstable.NewWriter(t)
	defer w.Close()
	for c := sstable.NewRecordIOReader(f, uint64(size)); !c.Done(); c.Next() {
		w.Write(*c.Entry())
	}
}
예제 #2
0
파일: command.go 프로젝트: jaeyeom/sstable
// cat prints the list of keys and values of each path in the RecordIO.
func cat(tablePaths []string) {
	for _, tablePath := range tablePaths {
		f, err := os.Open(tablePath)
		if err != nil {
			log.Println("Error on opening path", tablePath, ":", err)
			return
		}
		defer f.Close()
		info, err := f.Stat()
		if err != nil {
			log.Println("Error on stating path", tablePath, ":", err)
			return
		}
		size := info.Size()
		if size < 0 {
			log.Println("Size is negative on path", tablePath)
			return
		}
		for c := sstable.NewRecordIOReader(f, uint64(size)); !c.Done(); c.Next() {
			fmt.Println(string(c.Entry().Key))
			fmt.Println(string(c.Entry().Value))
		}
	}
}