largeMap udf with node.js client

I try to register this module to create a largeMap. The code is the following :

local lmap = require(‘ldt/lib_lmap’);

function create_existence_record_simplified(rec, binName, keyMap, newValue)

if aerospike:exists(rec) then

lmap.put(rec, binName, keyMap, newValue);

return rec;

else

lmap.put(rec, binName, keyMap, newValue);

return rec;

end

end

in a file named functions.lua

In node .js I can’t register the module → i had {“code”:100,“message”:“UDF: Execution Error 1”,“func”:“as_command_parse_udf_error”,“file”:“src/main/aerospike/as_command.c”,“line”:731}

I then try to register via aql which worked and then to call the function in my node script:

var usersCreate = aerospike.key(aerospikeDBParams.defaultNamespace,aerospikeDBParams.defaultSet,‘users’);

var udf = { module:‘functions.lua’, funcname: ‘create_existence_record_simplified’, args: [‘lmapUsers’,idInDb, defaultUser]};

client.execute(usersCreate, udf, function(err, result) {

 if ( err.code !== aerospike.status.AEROSPIKE_OK ) {
                                                                                    
        sails.log(JSON.stringify(err));
      }

});

I have the same error that wwhen I try to register the module

I want to get a large map named “lmapUsers” with for each key the id of an userwhen he as registered and for the value some basics infos such as (when I make a console.log on defaultUser) :

{ username: ‘bbb’, email: ‘bb@bb.fr’, privacy: ‘public’, reportConfidence: 1 }

@moubert,

Lmap, lset and lstack have all been deprecated as announced with the release of Aerospike Server CE 3.5.2 earlier this year. Please use llist instead. Llist uses a B+ tree as the internal data structure for ordering the elements and provides all the lmap functions.

Moubert,

Please use LList as indicated.

Looking at the code it looks fine. I just tried it and seems to work. Do you see anything unusual in log ( /var/log/aerospike.log ) ?

– R

Thank you guys-> it was unclear for me since in the documentation lmap,lset are still there.

If I want to do the same can I keep this code but with llist.add? I don’t understand when it’s said for complex data types to explicity pass “key”

Moubert,

When the data you insert is integer or string, it is considered as key by itself and data is sorted based on value. But no such ordering can be defined on complex data type like List or Map. So if you want to store a list or map. What you pass into llist.add is map with reserved ‘key’:keyValue.

Refer to

for example

– R

Thank you raj

I found this link (I use nodejs) : https://github.com/aerospike/aerospike-client-nodejs/blob/master/docs/largelist.md

the documentation on the website is confusing and missing of some elements, when I read Large Data types , there are links for implementations with java,c , go cleint,etc but not for node.js Also when I go in node.js client there is no reference to large list

Aerospike seems great , but the documentation leads to some misunderstandings

Moubert,

Hope you are able to get the information you were looking for.

Thanks for the feedback about node.js documentation. Will make sure it is consistent with others with respect to Large Data Types.

  • R