4

I have a python dictionary in which every key corresponds to a vector-id and the value contains an n dimensional vector as a list. I want to store and retrieve the data to perform mathematical operations. e.g.

{
1121:[5.333,1.637,3.323],
3442:[1.32,0.233,4.04],
.
.
.

}

1 Answer 1

7

There is no one way to do that. First, note that Redis' data structures are not nest-able. Then, decide what patterns you need to serve with the data.

  1. If you're mostly reading/writing the entire dictionary, the simplest is to serialize it (using Pickle, JSON or whatever) and store it as a plain String key in Redis.
  2. If you're accessing only individual vectors, you can mimic the dictionary structure using a Redis Hash, in which each field is a vector id and the value is the serialized list.
Sign up to request clarification or add additional context in comments.

2 Comments

Or you can use the excellent ReJSON module that will let you store JSON objects in redis and manipulate them directly. github.com/RedisLabsModules/rejson
Avoid pickle at any rate it introduces security breach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.