Conceptually, all my bin names are integer ids, and yet it seems like the Aerospike
Java
client only supports Strings as bin names. What’s the reason for this?
The server requires the bin names to be strings. All clients must obey this constraint.
But Aerospike is written in C, and C’s strings are UTF-8
not UTF-16
like Java
. Can byte arrays be used as the bin keys in the Java
client?
Byte arrays could theoretically be used as bin names, but the implementation would be bloated. The only reason for byte array bin names would be to avoid the String to UTF-8 conversion on socket send, but I doubt the performance gain would be significant.
I was trying to get around conversions, but it seems like even if byte's could be used as bin names, they too would have to be converted to integers in the end.
At ~45k whole-record reads per second, and potentially 200 bins per record, if I had to convert all Record
Map<String,Objects>
's into Map<Integer,Object>
's it could be a problem. But even then, it’s something that could be offloaded to the devices that request the records.
However, I’ve found a workaround for my use case. The Map<String,Object>
is going to be serialized into Json anyways, so on the device-end all quotation marks can be removed from the Json and the Json can be deserialized as a Map<Integer,Integer>
. Which actually is even more efficient than if bin names had been byte's in the first place, and wouldn’t work if bin names weren’t String
objects.