aerospike-client-python icon indicating copy to clipboard operation
aerospike-client-python copied to clipboard

Support UUID type

Open alvinr opened this issue 10 years ago • 3 comments

h1. Problem

If you use the UUID type in Python for the key you get the following (-2L, 'key is invalid', 'src/main/conversions.c', 747)

h1. Solution Extend conversion.c to include UUID support - this is a fairly standard way to get a UUID in python code.

h1. Workaround

Wrap the UUID in str, for example

foo = str(uuid.uuid1());

h1. Reproduce

Example code

import uuid
import aerospike
config = { 'hosts': [ "localhost", 3000) ] }
client = aerospike.client(config).connect()

foo = uuid.uuid1();
key = ("test", "hits", foo)
client.put(key, {"server": "foo"} )

alvinr avatar Aug 14 '15 21:08 alvinr

UUID seems useful enough, but that module does have an str implemented so it would be trivial to wrap it in str() as follows:

foo = uuid.uuid1();
key = ("test", "hits", str(foo))
client.put(key, {"server": "foo"} )

rbotzer avatar Sep 07 '15 04:09 rbotzer

Agree, that was the workaround that I included above.

alvinr avatar Sep 07 '15 05:09 alvinr

This is simple, as long as we don't have to cast back to UUID. Whenever a read operation happens, and assuming the key policy is POLICY_KEY_SEND the value will be of type string.

rbotzer avatar Oct 06 '15 21:10 rbotzer