| OLD | NEW |
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Sharding Entity group utility function to improve performance. | 5 """Sharding Entity group utility function to improve performance. |
| 6 | 6 |
| 7 This enforces artificial root entity grouping, which can be actually useful in | 7 This enforces artificial root entity grouping, which can be actually useful in |
| 8 some specific circumstances. | 8 some specific circumstances. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import hashlib | 11 import hashlib |
| 12 import string | 12 import string |
| 13 | 13 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 | 56 |
| 57 def hashed_shard_key(key, number_of_letters, root_entity_type): | 57 def hashed_shard_key(key, number_of_letters, root_entity_type): |
| 58 """Returns a ndb.Key to a virtual entity of type |root_entity_type|. | 58 """Returns a ndb.Key to a virtual entity of type |root_entity_type|. |
| 59 | 59 |
| 60 The main difference with shard_key() is that it doesn't assume the key is well | 60 The main difference with shard_key() is that it doesn't assume the key is well |
| 61 distributed so it first hashes the value via MD5 to make it more distributed. | 61 distributed so it first hashes the value via MD5 to make it more distributed. |
| 62 """ | 62 """ |
| 63 return shard_key( | 63 return shard_key( |
| 64 hashlib.md5(key).hexdigest(), number_of_letters, root_entity_type) | 64 hashlib.md5(key).hexdigest(), number_of_letters, root_entity_type) |
| OLD | NEW |