Skip to content

Add export and import to file (efficiently) #40

@jonsnowseven

Description

@jonsnowseven

This is more a feature request than an issue (sorry if it is not the correct place to report this).

Description

I think it could be very useful to have a functionality that exports and imports efficiently a bounter object to and from a file.

Something like:

from bounter import CountMinSketch

cms = CountMinSketch(size_mb=xxx)
cms.update(['a', 'b', 'c', 'a'])
cms.export('file')
cms = CountMinSketch(file='file')
print(cms.counts['a'])

I believe this can be accomplished with this:

import pickle
from bounter import CountMinSketch

cms = CountMinSketch(size_mb=xxx)
cms.update(['a', 'b', 'c', 'a'])
with open('counter.pkl', 'wb') as f:
    pickle.dump(cms, f)

with open('counter.pkl', 'rb') as f:
    cms = pickle.load(f)

print(b.size())
print(b['a'])

But maybe there is a more efficient way to export the object.

Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions