diff --git a/redbiom/admin.py b/redbiom/admin.py index 5c592b5..d7b59ed 100644 --- a/redbiom/admin.py +++ b/redbiom/admin.py @@ -15,10 +15,9 @@ class ScriptManager: local result = {} local formedkey = context .. ':' .. 'feature' .. ':' .. key - local items = redis.call('ZRANGEBYSCORE', + local items = redis.call('LRANGE', formedkey, - '-inf', 'inf', - 'withscores') + '0', '-1') -- adapted from https://gist.github.com/klovadis/5170446 local resultkey @@ -39,10 +38,9 @@ class ScriptManager: local result = {} local formedkey = context .. ':' .. 'sample' .. ':' .. key - local items = redis.call('ZRANGEBYSCORE', + local items = redis.call('LRANGE', formedkey, - '-inf', 'inf', - 'withscores') + '0', '-1') -- adapted from https://gist.github.com/klovadis/5170446 local resultkey @@ -203,8 +201,8 @@ def load_sample_data(table, context, tag=None, redis_protocol=False): --------------------- EVALSHA 1 :feature-index EVALSHA 1 :sample-index - ZADD :samples: ... - ZADD :features: ... + LPUSH :samples: ... + LPUSH :features: ... SADD :samples-represented ... SADD :features-represented ... @@ -243,7 +241,7 @@ def load_sample_data(table, context, tag=None, redis_protocol=False): packed = '/'.join(["%d/%s" % (v, i) for i, v in zip(remapped, int_values.data)]) - post(context, 'ZADD', 'sample:%s/%s' % (id_, packed)) + post(context, 'LPUSH', 'sample:%s/%s' % (id_, packed)) payload = "samples-represented/%s" % '/'.join(samples) post(context, 'SADD', payload) @@ -256,7 +254,7 @@ def load_sample_data(table, context, tag=None, redis_protocol=False): packed = '/'.join(["%d/%s" % (v, i) for i, v in zip(remapped, int_values.data)]) - post(context, 'ZADD', 'feature:%s/%s' % (id_, packed)) + post(context, 'LPUSH', 'feature:%s/%s' % (id_, packed)) payload = "features-represented/%s" % '/'.join(obs) post(context, 'SADD', payload) diff --git a/redbiom/tests/test_rest.py b/redbiom/tests/test_rest.py index 3192461..a5b791c 100644 --- a/redbiom/tests/test_rest.py +++ b/redbiom/tests/test_rest.py @@ -42,9 +42,9 @@ def test_feature_sample_associations(self): inv_index = get('HGETALL', 'test:sample-index-inverted') for values, id_, _ in table.iter(axis='observation'): exp = set(sample_ids[values > 0]) - obs = get('ZRANGEBYSCORE', 'test:feature:%s/%s/%s' % - (id_, '-inf', 'inf')) - obs = {inv_index[i] for i in obs} + obs = get('LRANGE', 'test:feature:%s/%s/%s' % + (id_, '0', '-1')) + obs = {inv_index[i] for i in obs[::2]} self.assertEqual(obs, exp) def test_sample_data(self): @@ -64,9 +64,9 @@ def test_sample_data(self): exp_ids = feature_ids[values > 0] exp_dict = {i: v for i, v in zip(exp_ids, exp_data)} - obs = get('ZRANGEBYSCORE', - 'test:sample:UNTAGGED_%s/%s/%s/%s' % - (id_, "-inf", "inf", "withscores")) + obs = get('LRANGE', + 'test:sample:UNTAGGED_%s/%s/%s' % + (id_, "0", "-1")) obs_dict = {inv_index[i]: float(v) for i, v in zip(obs[::2], obs[1::2])}