add estimate_num_keys to prefix interface

This commit is contained in:
Jack Robison 2022-02-11 15:49:09 -05:00
parent 6a5ff0636c
commit 937adbf439
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 6 additions and 0 deletions

View file

@ -139,3 +139,6 @@ class BasePrefixDB:
def stage_raw_delete(self, key: bytes, value: bytes):
self._op_stack.append_op(RevertableDelete(key, value))
def estimate_num_keys(self, column_family: 'rocksdb.ColumnFamilyHandle' = None):
return int(self._db.get_property(b'rocksdb.estimate-num-keys', column_family).decode())

View file

@ -144,6 +144,9 @@ class PrefixRow(metaclass=PrefixRowType):
def unpack_item(cls, key: bytes, value: bytes):
return cls.unpack_key(key), cls.unpack_value(value)
def estimate_num_keys(self) -> int:
return int(self._db.get_property(b'rocksdb.estimate-num-keys', self._column_family).decode())
class UTXOKey(NamedTuple):
hashX: bytes