Created
August 11, 2021 22:52
-
-
Save jszwedko/ed4ba52cd52b967d76a7a947b3697225 to your computer and use it in GitHub Desktop.
Leveldb Counter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/syndtr/goleveldb/leveldb" | |
"github.com/syndtr/goleveldb/leveldb/opt" | |
) | |
func main() { | |
opts := opt.Options{Compression: opt.NoCompression} | |
db, err := leveldb.OpenFile(os.Args[1], &opts) | |
defer db.Close() | |
count := 0 | |
iter := db.NewIterator(nil, nil) | |
for iter.Next() { | |
count++ | |
} | |
iter.Release() | |
err = iter.Error() | |
fmt.Printf("iterator error: %+v\n", err) | |
fmt.Printf("count: %d\n", count) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment