Floating points

Im having a bit of trouble understanding how floating points are supported in the python client? From my understanding with the release of 1.0.50 floating points are supported, but Im not sure how it is supposed to work. It looks like the floating points are saved as binary which other clients can’t read.

That’s a known bug in the PHP client (and will be fixed next release) but not in the Python client. If you’re looking at the record in AQL, make sure you’re using the aerospike tools release >= 3.6.0.

Old data, records created by older versions of the Python client, will be AS_BYTES_PYTHON containing serialized float data, but any new records should be storing a Python float as as_double.

For example:

from __future__ import print_function
import aerospike
from aerospike.exception import *
import sys

config = { 'hosts': [('192.168.119.3', 3000)]}
try:
    client = aerospike.client(config).connect()
except ClientError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)

client.put(('test', 'demo', 1), {'i':1, 'f': 3.1415, 'm': {'a':1,'b':5.56}})

(k,m,b) = client.get(('test', 'demo', 1))
print(b)
client.close()

Has the output

$ python put.py 
{'i': 1, 'm': {'a': 1, 'b': 5.56}, 'f': 3.1415}

While AQL shows the expected values

aql> select * from test.demo where PK=1
+---+-------------------+--------+
| i | m                 | f      |
+---+-------------------+--------+
| 1 | {"a":1, "b":5.56} | 3.1415 |
+---+-------------------+--------+
1 row in set (0.001 secs)