tvalentyn commented on a change in pull request #12756:
URL: https://github.com/apache/beam/pull/12756#discussion_r485218862
##########
File path: sdks/python/apache_beam/transforms/stats.py
##########
@@ -46,6 +57,35 @@
V = typing.TypeVar('V')
+def _default_hash_fn(value):
+ """Hash value using either murmurhash or md5 based on installation."""
+ if not _default_hash_fn.fn:
+ try:
+ import mmh3 # pylint: disable=import-error
+
+ def _mmh3_hash(value):
+ # mmh3.hash64 returns 2 64-bit unsigned integers
+ return mmh3.hash64(value, seed=0, signed=False)[0]
+
+ _default_hash_fn.fn = _mmh3_hash
+ except ImportError:
+ logging.warning(
+ 'Couldn\'t find murmurhash so the implementation of '
+ 'ApproximateUnique is not as fast as it could be.')
Review comment:
`Couldn't find murmurhash. Install mmh3 for a faster implementation of
ApproximateUnique.`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]