Load distribution in refresh provision
This commit is contained in:
1 parent
7620628e52
commit
4b5dc25010
2 files changed
+11
-1
No files matched your search
@@ -301,6 +301,14 @@ escapeRegExp = (str) ->
|
||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")
|
||||
|
||||
|
||||
# djb2 hashing algorithm adapted from http://www.cse.yorku.ca/~oz/hash.html
|
||||
djb2 = (str) ->
|
||||
hash = 5381
|
||||
for i in [0...str.length]
|
||||
hash = ((hash << 5) + hash) ^ str.charCodeAt(i)
|
||||
return hash
|
||||
|
||||
|
||||
exports.UNDEFINED_TYPE = UNDEFINED_TYPE
|
||||
exports.NULL_TYPE = NULL_TYPE
|
||||
exports.NUMBER_TYPE = NUMBER_TYPE
|
||||
@@ -315,3 +323,4 @@ exports.parsePath = parsePath
|
||||
exports.addPathMeta = addPathMeta
|
||||
exports.hammingWeight = hammingWeight
|
||||
exports.escapeRegExp = escapeRegExp
|
||||
exports.djb2 = djb2
|
||||
@@ -29,7 +29,8 @@ function refresh(sessionData, provision, declarations, startRevision, endRevisio
|
||||
path.length = MAX_DEPTH;
|
||||
path.fill("*", l);
|
||||
let every = 1000 * (provision[2] || 1);
|
||||
let t = Math.trunc(sessionData.timestamp / every) * every;
|
||||
let offset = Math.abs(common.djb2(sessionData.deviceId)) % 86400000;
|
||||
let t = Math.trunc((sessionData.timestamp + offset) / every) * every - offset;
|
||||
|
||||
for (let i = l; i < path.length; ++ i)
|
||||
declarations.push([path.slice(0, i), t, {object: 1, writable: 1, value: t}]);
|
||||
|
||||
Reference in new issue
Block a user