Skip to content

Instantly share code, notes, and snippets.

@qix
Created September 8, 2015 20:13
Show Gist options
  • Save qix/74c07f05c019533c6c7b to your computer and use it in GitHub Desktop.
Save qix/74c07f05c019533c6c7b to your computer and use it in GitHub Desktop.
from __future__ import absolute_import
import cPickle
import zlib
from hyperloglog import SlidingHyperLogLog
def shlld_from_string(string, error_rate, window_count):
lpfm = cPickle.loads(zlib.decompress(string)) if string else None
return SlidingHyperLogLog(
error_rate=error_rate,
window=window_count,
lpfm=lpfm,
)
def shlld_to_string(hyperlog):
return zlib.compress(cPickle.dumps(hyperlog.LPFM))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment