Skip to content

Commit dabd6bf

Browse files
committed
some polishing
1 parent cb35492 commit dabd6bf

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

splitio/engine/cache/lru.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SimpleLruCache(object): #pylint: disable=too-many-instance-attributes
2424
class _Node(object): #pylint: disable=too-few-public-methods
2525
"""Links to previous an next items in the circular list."""
2626

27-
def __init__(self, key, value, previous_element, next_element): #pylint: disable=too-many-arguments
27+
def __init__(self, key, value, previous_element, next_element):
2828
"""Class constructor."""
2929
self.key = key # we also keep the key for O(1) access when removing the LRU.
3030
self.value = value

splitio/engine/impmanager.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@ class Hasher(object):
1111

1212
_PATTERN = "%s:%s:%s:%s:%d"
1313

14-
def __init__(self, ):
15-
"""TODO."""
16-
pass
14+
def __init__(self, hash_fn=murmur_128, seed=0):
15+
"""
16+
Class constructor.
17+
18+
:param hash_fn: Hash function to apply (str, int) -> int
19+
:type hash_fn: callable
20+
21+
:param seed: seed to be provided when hashing
22+
:type seed: int
23+
"""
24+
self._hash_fn = hash_fn
25+
self._seed = seed
1726

1827
def _stringify(self, impression):
1928
"""
@@ -41,7 +50,7 @@ def process(self, impression):
4150
:returns: a hash of the supplied impression's relevant fields.
4251
:rtype: int
4352
"""
44-
return murmur_128(self._stringify(impression), 0)
53+
return self._hash_fn(self._stringify(impression), self._seed)
4554

4655

4756
class Observer(object):

0 commit comments

Comments
 (0)