Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bbhash.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/bbhash_table.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down