Question

It seems there's not such interface..

Do I have to iterate all keys to get the count?

What is the design purpose of that? Or what is the limitation of implement this feature?

Was it helpful?

Solution

"There is no way to implement Count more efficiently inside leveldb than outside." states offical issue 113

Looks like there is no better way to do it, except for either iterating through the whole dataset or implementing your own in-application on-write counter.

OTHER TIPS

Probably when LevelDB was built, this API was not required for the original authors. Sadly LevelDB does not have an increment API which you can use to record counting. What you can do right now is read and write a key in Leveldb, but this is not thread safe.

May be you could have a look at Redis, if it is better suited for your use case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top