0

I'm trying to decode bins' data returned by an aerospike get query using nodejs but i keep getting data containing weird \u0003 unicode characters.

I have stored the data in aerospike using a simple script much like the default example

'use strict';

const Aerospike = require('aerospike');

const key = new Aerospike.Key('test', 'test_set', '1234');
const client = Aerospike.client({hosts: '127.0.0.1'});
const bins = {
    test: {
        '123': '1', 
        '456': '1'
    }
};

client.connect((err) => {
    if(err) return console.error('Could not connect to aerospike', err);
    return client.put(key, bins, (err) => {
        if(err) return console.error('Error when inserting data', err);
        console.log('Record has been written');
    });
});

I then retrieve the key bins and their associated values.

82a403313233a20331a403343536a20331 is the hex content of the bin test that we previously inserted.

When decoded using various nodejs msgpack libraries:

I always get the same result which is not what i inserted in the first place:

{
    test: {
        '\u0003123': '\u00031',
        '\u0003456': '\u00031'
    }
}

All the msgpack libraries i tried seem to match the msgpack spec described here which means that Aerospike uses an alternate format based on msgpack.

If that's the case where can i find this alternate protocol ?

1 Answers1

1

The wire protocol isn't based on msgpack.

CDT bins are encoded with msgpack with custom extensions.

Edit

The extension is used to express how the map is ordered, this could be unordered, key ordered, or key-value ordered. See here for how the Java client unpacks this information.

kporter
  • 2,684
  • 17
  • 26
  • Thanks for the link, i already checked it out previously but there is no documentation available, the API & wiki link doesn't seem to work anymore (http://redmine.msgpack.org/projects/msgpack/wiki) and there is no mention of a custom implementation. Is there somewhere i can find the specification of these custom extensions ? – Maxime Lequain Feb 10 '18 at 19:56
  • Are you trying to decode all bins with msgpack or just cdt bins. The types in your sample aren't cdts so they aren't packed with msgmack. – kporter Feb 10 '18 at 20:13
  • Ah, missed that inner definition. Curious, what is this needed for? Will see if I can find information about the extension. – kporter Feb 11 '18 at 20:59
  • The `test` bin contains a map and if i'm not mistaken it is converted to a CDT of type `map` by the node aerospike client. – Maxime Lequain Feb 11 '18 at 21:02
  • Okay great, i'll wait for your reponse then. Thank you very much ! – Maxime Lequain Feb 11 '18 at 21:02
  • Sure, soonest will be tomorrow. – kporter Feb 11 '18 at 21:04
  • Updated the answer with the information I could find. – kporter Feb 14 '18 at 21:49
  • Okay ! Thank you very much, i'll take a look at it as soon as i can. – Maxime Lequain Feb 15 '18 at 09:34