예제 #1
0
파일: db.go 프로젝트: daaku/gorocksdb
// RepairDB repairs a database.
func RepairDB(name string, opts *Options) error {
	var (
		cErr  *C.char
		cName = C.CString(name)
	)
	defer C.free(unsafe.Pointer(cName))
	C.rocksdb_repair_db(opts.c, cName, &cErr)
	return convertErr(cErr)
}
예제 #2
0
파일: db.go 프로젝트: rdallman/gorocksdb
// RepairDb repairs a database.
func RepairDb(name string, opts *Options) error {
	var cErr *C.char
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	C.rocksdb_repair_db(opts.c, cname, &cErr)
	if cErr != nil {
		defer C.free(unsafe.Pointer(cErr))

		return errors.New(C.GoString(cErr))
	}

	return nil
}
예제 #3
0
파일: db.go 프로젝트: cayleydb/dgraph
// RepairDatabase attempts to repair a database.
//
// If the database is unrepairable, an error is returned.
func RepairDatabase(dbname string, o *Options) error {
	var errStr *C.char
	ldbname := C.CString(dbname)
	defer C.free(unsafe.Pointer(ldbname))

	C.rocksdb_repair_db(o.Opt, ldbname, &errStr)
	if errStr != nil {
		gs := C.GoString(errStr)
		C.free(unsafe.Pointer(errStr))
		return DatabaseError(gs)
	}
	return nil
}
예제 #4
0
파일: db.go 프로젝트: nzinfo/ledisdb
func Repair(cfg *Config) error {
	db := new(DB)
	db.cfg = cfg

	err := db.open()
	defer db.Close()

	//open ok, do not need repair
	if err == nil {
		return nil
	}

	var errStr *C.char
	ldbname := C.CString(db.cfg.Path)
	defer C.free(unsafe.Pointer(ldbname))

	C.rocksdb_repair_db(db.opts.Opt, ldbname, &errStr)
	if errStr != nil {
		return saveError(errStr)
	}
	return nil
}
예제 #5
0
파일: db.go 프로젝트: malloc-fi/vantaa
func (s Store) Repair(path string, cfg *config.Config) error {
	db := new(DB)
	db.path = path
	db.cfg = &cfg.RocksDB

	err := db.open()
	defer db.Close()

	//open ok, do not need repair
	if err == nil {
		return nil
	}

	var errStr *C.char
	ldbname := C.CString(path)
	defer C.free(unsafe.Pointer(ldbname))

	C.rocksdb_repair_db(db.opts.Opt, ldbname, &errStr)
	if errStr != nil {
		return saveError(errStr)
	}
	return nil
}