lib ldb key_value: Add get_size method
authorGary Lockyer <gary@catalyst.net.nz>
Mon, 1 Apr 2019 02:27:32 +0000 (15:27 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 4 Apr 2019 06:40:17 +0000 (06:40 +0000)
commit6129a05ca0cc39a8043d58f793c4ec92e4c40182
tree7c3ba22599d159436e6afbac7afc3cd4187afe90
parent8f7bf13b96841b38cdc60765a5465be940e1477b
lib ldb key_value: Add get_size method

Add the get_size method to the ldb_key_value layer, this will allow the
reindexing code to get an estimate of the number of records in the
database.

The lmdb backend returns an accurate count of the number of records in
the database withe the mdb_env_stat call.

The tdb backend does not provide a low cost method to determine the
number of records on the database.  It does provide a tdb_summary call
however this this walks the entire database.

So for tdb we use the map size divided by 500, this over estimates the counts
for small domains, but the extra memory allocated for the cache should
not be significant.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/ldb_key_value/ldb_kv.h
lib/ldb/ldb_mdb/ldb_mdb.c
lib/ldb/ldb_tdb/ldb_tdb.c
lib/ldb/tests/ldb_kv_ops_test.c
lib/ldb/wscript