func optionsBulk(c *cli.Context) error { dbOptions := rdb.NewDefaultOptions() defaultFlags.setOptions(dbOptions, c) out, err := json.MarshalIndent(DefaultOptions, "", "\t") if err != nil { log.Fatal(err) } fmt.Println(string(out)) return nil }
func createDb(c *cli.Context) error { dbName := c.GlobalString("db") if dbName == "" { cli.ShowAppHelp(c) return nil } dbOptions := rdb.NewDefaultOptions() dbOptions.SetCreateIfMissing(true) defaultFlags.setOptions(dbOptions, c) db, err := rdb.OpenDb(dbOptions, dbName) if err != nil { log.Fatal(err) } defer db.Close() return nil }
func statsDb(c *cli.Context) error { dbName := c.GlobalString("db") if dbName == "" { cli.ShowAppHelp(c) return nil } dbOptions := rdb.NewDefaultOptions() defaultFlags.setOptions(dbOptions, c) db, err := rdb.OpenDbForReadOnly(dbOptions, dbName, false) if err != nil { log.Fatal(err) } fmt.Println(db.GetProperty("rocksdb.stats")) db.Close() return nil }
func compactDb(c *cli.Context) error { dbName := c.GlobalString("db") if dbName == "" { cli.ShowAppHelp(c) return nil } dbOptions := rdb.NewDefaultOptions() dbOptions.SetCreateIfMissing(true) defaultFlags.setOptions(dbOptions, c) db, err := rdb.OpenDb(dbOptions, dbName) if err != nil { log.Fatal(err) } db.CompactRange(rdb.Range{}) db.Flush(rdb.NewDefaultFlushOptions()) fmt.Println(db.GetProperty("rocksdb.stats")) fmt.Println("done") return nil }