# largeMap udf with node.js client

**URL:** https://discuss.aerospike.com/t/largemap-udf-with-node-js-client/1595
**Category:** User Defined Functions (UDF)
**Created:** [August 10, 2015, 5:43pm UTC](https://discuss.aerospike.com/t/largemap-udf-with-node-js-client/1595 "2015-08-10T17:43:09Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![moubert](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@moubert](https://discuss.aerospike.com/u/moubert)
#### Post date: [August 10, 2015, 5:43pm UTC](https://discuss.aerospike.com/t/largemap-udf-with-node-js-client/1595/1 "2015-08-10T17:43:09Z")

</div>

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 }

---

<div class="post-metadata">

### Author: ![Mnemaudsyne](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/mnemaudsyne/32/200_2.png) [@Mnemaudsyne](https://discuss.aerospike.com/u/Mnemaudsyne)
#### Post date: [August 12, 2015, 1:39am UTC](https://discuss.aerospike.com/t/largemap-udf-with-node-js-client/1595/2 "2015-08-12T01:39:43Z")

</div>

@moubert,

Lmap, lset and lstack have all been deprecated as announced with the release of [Aerospike Server CE 3.5.2](http://www.aerospike.com/download/server/notes.html#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.

---

<div class="post-metadata">

### Author: ![raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@raj](https://discuss.aerospike.com/u/raj)
#### Post date: [August 12, 2015, 4:50am UTC](https://discuss.aerospike.com/t/largemap-udf-with-node-js-client/1595/3 "2015-08-12T04:50:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![moubert](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@moubert](https://discuss.aerospike.com/u/moubert)
#### Post date: [August 12, 2015, 10:05am UTC](https://discuss.aerospike.com/t/largemap-udf-with-node-js-client/1595/4 "2015-08-12T10:05:36Z")

</div>

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”

---

<div class="post-metadata">

### Author: ![raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@raj](https://discuss.aerospike.com/u/raj)
#### Post date: [August 12, 2015, 10:46am UTC](https://discuss.aerospike.com/t/largemap-udf-with-node-js-client/1595/5 "2015-08-12T10:46:53Z")

</div>

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

> [@How to add as\_map to Large ordered list (llist)](https://discuss.aerospike.com/t/how-to-add-as-map-to-large-ordered-list-llist/1518/5):
>
> Hi Raj, Thanks for the details. This fix worked fine. But Ideally the original code should work. I am using C client API through C++ code. I tried to find the root cause of this issue. Below are the details: for(int k = 0; k \< n; ++k) { as\_hashmap map1; as\_map \*m1 = (as\_map \*)as\_hashmap\_init(&map1, (2)); as\_stringmap\_set\_str(m1, "key", map\_array[k].key); as\_stringmap\_set\_int64(m1, map\_array[k].key, map\_array[k].value); as\_arraylist\_append\_map(&vals, m1); } In this for loo…

for example

– R

---

<div class="post-metadata">

### Author: ![moubert](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@moubert](https://discuss.aerospike.com/u/moubert)
#### Post date: [August 12, 2015, 12:54pm UTC](https://discuss.aerospike.com/t/largemap-udf-with-node-js-client/1595/6 "2015-08-12T12:54:00Z")

</div>

Thank you raj

I found this link (I use nodejs) : [https://github.com/aerospike/aerospike-client-nodejs/blob/master/docs/largelist.md](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

---

<div class="post-metadata">

### Author: ![raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@raj](https://discuss.aerospike.com/u/raj)
#### Post date: [August 12, 2015, 1:11pm UTC](https://discuss.aerospike.com/t/largemap-udf-with-node-js-client/1595/7 "2015-08-12T13:11:51Z")

</div>

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
