Closed GoogleCodeExporter closed 9 years ago
Unfortunately Size() would be very expensive to implement.
In more detail, suppose leveldb starts maintaining an internal count of number
of records. Consider a "Put(k, v)" value call. If the database already
contains "k", the counter must be left unchanged. Otherwise the counter must be
increased by one. And currently Put() implementation just logs: it does not
need to read anything. To keep the counter up to date, we would have to do a
read to detect whether or not "k" already exists. So keeping the counter up to
date would double the cost of a synchronous write (changing one seek to two
seeks) and increase the cost of a non-synchronous write by an even larger ratio
(changing 0 seeks to 1 seek).
So we won't be adding a Size() method.
Original comment by san...@google.com
on 10 Jul 2013 at 9:56
Original issue reported on code.google.com by
miroslav...@gmail.com
on 10 Jul 2013 at 3:12