Вопрос

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?

Это было полезно?

Решение

"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.

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top