Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: appengine/components/components/datastore_utils/sharding.py

Issue 2013943002: Changing license header, again! (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: Fixed third parties Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698