Exception.ClientError: (-1L, 'Unable to deserialize bytes', 'src/main/serializer.c', 475)


Follow scenario:

import aerospike
AEROSPIKE_CONNECTION_STRING = {'hosts': [("localhost", 3000)], 'policies': {'timeout': 10000, 'retry': 10000}}
remote = aerospike.client(AEROSPIKE_CONNECTION_STRING).connect()

(key, metadata, bins) = remote.get(("ns", "some_set", "key-here"))

print bins # cannot reach because exception

It raises a exception:

exception.ClientError: (-1L, 'Unable to deserialize bytes', 'src/main/serializer.c', 475)

How to reproduce this problem: Write using java this bin: {“key”: {“id”: {“key”: “value”} }}

HashMap<String,HashMap<String, String>> map = new HashMap<String,HashMap<String, String>>();
HashMap<String, String> am = new HashMap<String, String>();
am.put("key", "value");
map.put("id", am);

Bin bin = new Bin("key", map);
client.put(params.writePolicy, key, bin); // for short, have some code behind

Then using python try to read that data.

Is there a way to write a Java HashMap and read using python as dictionary?


Linked to Issue 62 at aerospike/aerospike-client-python.


Are you sure that you are persisting only data that casts to one of the native types (integer, string, list, map, bytes)? For example if a map has a type nested which isn’t, or if another bin is there with unsupported types. What will happen with Java, or Python is that those unsupported types will get serialized and saves as bytes, with the Java client encoding those as AS_BYTES_JAVA and the Python one as AS_BYTES_PYTHON, which are not interchangeable. You can check by seeing what is stored in that record using AQL . If you could paste the output here, it would help.


I’ve tested Issue 62 with the PHP and Python clients and it works fine for me. There is a longer explanation of how serialization works for cross-client compatibility above aerospike.set_serializer method in the Python client doc.