|
@ -82,6 +82,9 @@ func (db *GoLevelDB) Close() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (db *GoLevelDB) Print() { |
|
|
func (db *GoLevelDB) Print() { |
|
|
|
|
|
str, _ := db.db.GetProperty("leveldb.stats") |
|
|
|
|
|
fmt.Printf("%v\n", str) |
|
|
|
|
|
|
|
|
iter := db.db.NewIterator(nil, nil) |
|
|
iter := db.db.NewIterator(nil, nil) |
|
|
for iter.Next() { |
|
|
for iter.Next() { |
|
|
key := iter.Key() |
|
|
key := iter.Key() |
|
@ -90,15 +93,30 @@ func (db *GoLevelDB) Print() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (db *GoLevelDB) Iterator() Iterator { |
|
|
|
|
|
return db.db.NewIterator(nil, nil) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func (db *GoLevelDB) Stats() map[string]string { |
|
|
|
|
|
keys := []string{ |
|
|
|
|
|
"leveldb.num-files-at-level{n}", |
|
|
|
|
|
"leveldb.stats", |
|
|
|
|
|
"leveldb.sstables", |
|
|
|
|
|
"leveldb.blockpool", |
|
|
|
|
|
"leveldb.cachedblock", |
|
|
|
|
|
"leveldb.openedtables", |
|
|
|
|
|
"leveldb.alivesnaps", |
|
|
|
|
|
"leveldb.alibeiters", |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func (db *GoLevelDB) Next(iter Iterator) ([]byte, []byte) { |
|
|
|
|
|
if iter.Next() { |
|
|
|
|
|
return iter.Key(), iter.Value() |
|
|
|
|
|
|
|
|
stats := make(map[string]string) |
|
|
|
|
|
for _, key := range keys { |
|
|
|
|
|
str, err := db.db.GetProperty(key) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
stats[key] = str |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return nil, nil |
|
|
|
|
|
|
|
|
return stats |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (db *GoLevelDB) Iterator() Iterator { |
|
|
|
|
|
return db.db.NewIterator(nil, nil) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (db *GoLevelDB) NewBatch() Batch { |
|
|
func (db *GoLevelDB) NewBatch() Batch { |
|
|