fix: ListColumnFamilies 先创建.rocksdb 和 default columnfamilies

This commit is contained in:
eson 2020-03-03 20:51:18 +08:00
parent 5a6d78bfb9
commit d08133a3a3
2 changed files with 9 additions and 4 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.rocksdb
log
main
rocksdb-api

View File

@ -63,9 +63,10 @@ func OpenDataBase() (*gorocksdb.DB, []*gorocksdb.ColumnFamilyHandle) {
log.SetOutput(f)
log.Println(timeCFStr)
names, err := gorocksdb.ListColumnFamilies(opts, "./.rocksdb")
names, err := gorocksdb.ListColumnFamilies(opts, ".rocksdb")
if err != nil {
panic(err)
log.Println(".rocksdb 文件不存在")
names = append(names, "default")
}
isadd := true
@ -85,7 +86,7 @@ func OpenDataBase() (*gorocksdb.DB, []*gorocksdb.ColumnFamilyHandle) {
log.Println(names)
db, cfs, err := gorocksdb.OpenDbColumnFamilies(opts, "./.rocksdb", names, opslist)
db, cfs, err := gorocksdb.OpenDbColumnFamilies(opts, ".rocksdb", names, opslist)
if err != nil {
panic(err)
}
@ -96,7 +97,7 @@ func CreateData() {
db, cfs := OpenDataBase()
GCOUNT := 100
GCOUNT := 10
wg := &sync.WaitGroup{}
wg.Add(GCOUNT)