Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Pipelining get #78

Open
elan-izidane opened this issue Oct 28, 2020 · 2 comments
Open

Pipelining get #78

elan-izidane opened this issue Oct 28, 2020 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@elan-izidane
Copy link

Hi,
I am trying to run something like:

pipeline = time_series_client.pipeline(transaction=False)
for key in my_list_of_keys:
    pipeline.get(key)
my_data = pipeline.execute()

This does not work, I could not find tests for get with pipelines. Adding works great though.
My guess is that it is doing a "GET" and not a "TS.GET" (have not tested this).

@gkorland
Copy link
Contributor

from redistimeseries.client import Client
rts = Client()
rts.create('test', labels={'Time':'Series'})
rts.add('test', 1, 1.12)
rts.add('test', 2, 1.12)

pipeline = rts.pipeline(transaction=False)
pipeline.get('test')
print(pipeline.execute() )

result [(2, 1.12)]

@gkorland gkorland added the help wanted Extra attention is needed label Oct 29, 2020
@ilieszidane
Copy link

ilieszidane commented Nov 27, 2020

Hi,
Thanks vm for your response.

Here is my code:

from redistimeseries.client import Client as RedisTS
client_kwargs = {"host": hostname, "port": port, "decode_responses": True}
rts = RedisTS(**client_kwargs)
rts.create('test', labels={'Time': 'Series'})
rts.add('test', 1, 1.12)
rts.add('test', 2, 1.12)

print(rts.get('test'))

pipeline = rts.pipeline(transaction=False)
pipeline.get('test')
print(pipeline.execute())

The first print does print (2, 1.12), the second raises:

Exception has occurred: ResponseError
Command # 1 (GET test) of pipeline caused error: WRONGTYPE Operation against a key holding the wrong kind of value
  File "/usr/local/pip-global/redis/connection.py", line 756, in read_response
    raise response
  File "/usr/local/pip-global/redis/client.py", line 915, in parse_response
    response = connection.read_response()
  File "/usr/local/pip-global/redis/client.py", line 3977, in parse_response
    result = Redis.parse_response(
  File "/usr/local/pip-global/redis/client.py", line 3961, in _execute_pipeline
    self.raise_first_error(commands, response)
  File "/usr/local/pip-global/redis/client.py", line 3968, in raise_first_error
    raise r
  File "/usr/local/pip-global/redis/client.py", line 3961, in _execute_pipeline
    self.raise_first_error(commands, response)
  File "/usr/local/pip-global/redis/client.py", line 4019, in execute
    return execute(conn, stack, raise_on_error)
  File "/workspaces/app/command/play_with_redis.py", line 31, in <module>
    print(pipeline.execute())

I am running redislabs/redismod:latest and this client.

$ pip3 freeze | grep redis
hiredis==1.1.0
redis==3.5.3
redistimeseries==1.4.3

output of module list on the cli:

>> module list

1) 1) "name"
   2) "bf"
   3) "ver"
   4) (integer) 20204
2) 1) "name"
   2) "search"
   3) "ver"
   4) (integer) 20003
3) 1) "name"
   2) "ai"
   3) "ver"
   4) (integer) 10002
4) 1) "name"
   2) "timeseries"
   3) "ver"
   4) (integer) 10406
5) 1) "name"
   2) "rg"
   3) "ver"
   4) (integer) 10003
6) 1) "name"
   2) "graph"
   3) "ver"
   4) (integer) 20208
7) 1) "name"
   2) "ReJSON"
   3) "ver"
   4) (integer) 10006

Thanks vm for your help!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants