From b874f47bdedfc234e3a639a0ebae9b9c02a51925 Mon Sep 17 00:00:00 2001 From: sarthakTUM Date: Sun, 16 Feb 2020 21:15:17 +0100 Subject: [PATCH 1/2] removed redis_object from _add_vector --- nearpy/storage/storage_redis.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nearpy/storage/storage_redis.py b/nearpy/storage/storage_redis.py index 5ec82d7..944bda0 100644 --- a/nearpy/storage/storage_redis.py +++ b/nearpy/storage/storage_redis.py @@ -50,7 +50,7 @@ def store_vector(self, hash_name, bucket_key, v, data): """ Stores vector and JSON-serializable data in bucket with specified key. """ - self._add_vector(hash_name, bucket_key, v, data, self.redis_object) + self._add_vector(hash_name, bucket_key, v, data) def store_many_vectors(self, hash_name, bucket_keys, vs, data): """ @@ -61,10 +61,10 @@ def store_many_vectors(self, hash_name, bucket_keys, vs, data): if data is None: data = [None] * len(vs) for bucket_key, data, v in zip(bucket_keys, data, vs): - self._add_vector(hash_name, bucket_key, v, data, pipeline) + self._add_vector(hash_name, bucket_key, v, data) pipeline.execute() - def _add_vector(self, hash_name, bucket_key, v, data, redis_object): + def _add_vector(self, hash_name, bucket_key, v, data): ''' Store vector and JSON-serializable data in bucket with specified key. ''' From ad477db82d3728e0f73f7e27b1e766c2476d9c55 Mon Sep 17 00:00:00 2001 From: sarthakTUM Date: Mon, 17 Feb 2020 21:22:03 +0100 Subject: [PATCH 2/2] removed self from redis_object in _add_vector --- nearpy/storage/storage_redis.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nearpy/storage/storage_redis.py b/nearpy/storage/storage_redis.py index 944bda0..7c7ec0f 100644 --- a/nearpy/storage/storage_redis.py +++ b/nearpy/storage/storage_redis.py @@ -50,7 +50,7 @@ def store_vector(self, hash_name, bucket_key, v, data): """ Stores vector and JSON-serializable data in bucket with specified key. """ - self._add_vector(hash_name, bucket_key, v, data) + self._add_vector(hash_name, bucket_key, v, data, self.redis_object) def store_many_vectors(self, hash_name, bucket_keys, vs, data): """ @@ -61,10 +61,10 @@ def store_many_vectors(self, hash_name, bucket_keys, vs, data): if data is None: data = [None] * len(vs) for bucket_key, data, v in zip(bucket_keys, data, vs): - self._add_vector(hash_name, bucket_key, v, data) + self._add_vector(hash_name, bucket_key, v, data, pipeline) pipeline.execute() - def _add_vector(self, hash_name, bucket_key, v, data): + def _add_vector(self, hash_name, bucket_key, v, data, redis_object): ''' Store vector and JSON-serializable data in bucket with specified key. ''' @@ -102,7 +102,7 @@ def _add_vector(self, hash_name, bucket_key, v, data): val_dict['data'] = data # Push JSON representation of dict to end of bucket list - self.redis_object.rpush(redis_key, pickle.dumps(val_dict, protocol=2)) + redis_object.rpush(redis_key, pickle.dumps(val_dict, protocol=2)) def _format_redis_key(self, hash_name, bucket_key): return '{}{}'.format(self._format_hash_prefix(hash_name), bucket_key)