diff options
author | Josh Levenberg <josh11b@tensorflow.org> | 2016-05-26 09:50:54 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-05-26 11:03:06 -0700 |
commit | 1c28846ac82fe3d1cc8438d90cff23c27ac2701f (patch) | |
tree | 0bf43999d252907b0813223f9bbbe4178b961c8f /tensorflow/python/framework/docs.py | |
parent | ef90ea5ccac81072fd3a14e7630964173e1a8a5c (diff) |
Follow up to documentation sharding change to make the sharding
use a fixed hashing function.
Change: 123334435
Diffstat (limited to 'tensorflow/python/framework/docs.py')
-rw-r--r-- | tensorflow/python/framework/docs.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tensorflow/python/framework/docs.py b/tensorflow/python/framework/docs.py index 92c6cfb3d9..7f1cfd110d 100644 --- a/tensorflow/python/framework/docs.py +++ b/tensorflow/python/framework/docs.py @@ -165,6 +165,14 @@ def _get_anchor(module_to_name, fullname): return anchor +def _stable_hash(s): + """A simple string hash that won't change from run to run.""" + ret = 0 + for c in s: + ret = ret * 97 + ord(c) + return ret + + class Library(Document): """An automatically generated document for a set of functions and classes.""" @@ -258,7 +266,7 @@ class Library(Document): When generating individual files for each function and class, we shard the files across several directories to avoid hitting the limit for files per directory. This function determines the subdirectory for - a member based on a hash of its name. + a member based on a stable hash of its name. Args: name: string. The name of a function or class. @@ -266,7 +274,7 @@ class Library(Document): Returns: The path to a subdirectory of the api docs directory. """ - index = hash(name) % _num_subdirs + index = _stable_hash(name) % _num_subdirs return os.path.join(self.functions_and_classes_dir, _subdir_prefix + str(index)) |