diff --git a/src/bbhash.pyx b/src/bbhash.pyx index c6cfc74..9a055d4 100644 --- a/src/bbhash.pyx +++ b/src/bbhash.pyx @@ -45,6 +45,7 @@ cdef extern from "BooPHF.h" namespace "boomphf": cdef cppclass mphf[T,U]: mphf(unsigned long long, vector[T], int, float, bool, bool) except + uint64_t lookup(uint64_t) + uint64_t totalBitSize() void save(ofstream) void load(ifstream) @@ -82,6 +83,9 @@ cdef class PyMPHF: return mp_hashes + def get_mem(self): + return deref(self.c_mphf).totalBitSize() + def save(self, str filename): cdef ofstream* outputter outputter = new ofstream(filename.encode(), binary) diff --git a/src/bbhash_table.pyx b/src/bbhash_table.pyx index 4e5b323..dcb5d97 100644 --- a/src/bbhash_table.pyx +++ b/src/bbhash_table.pyx @@ -57,6 +57,12 @@ class BBHashTable(object): self.mphf_to_value[mp_hash] = value + def get_mem(self): + "Get memory usage." + return self.mphf.get_mem() + \ + self.mphf_to_hash.nbytes + \ + self.mphf_to_value.nbytes + def get_unique_values(self, hashes, require_exist=False): "Retrieve unique values for item." values = defaultdict(int)