Difficulty registering UDF Files

php
lua
udf

#1

Hi.

I’m trying to run through some of the example UDF work but am unable to register the UDF with the Aerospike server. I keep getting:

Error[100]: error=invalid_filename

I have the UDF file on the client in a folder within the project which I’m referencing (/lua/my_lu_file.lua). Do I also need to copy this file to the server in the /opt/aerospike/udf/lua folder before registering?

If I copy it to this location I get a different error regarding being unable to do something with nothing scriptdo

Not overly familiar with UDF in terms of Aerospike so is there more of a step by step?

Thanks guys


#3

Okay, so for clarification I have a test project set up with the following:

root testfile.php udf my_udf.lua

Using the PHP client, if I issue the following command $status = $this->getDb()->register('{project root}/udf/my_udf.lua', 'my_udf'); I get the error=invalid_filename come up.

This does however seem to copy the file to my /usr/local/aerospike/usr-lua/ folder (which I didn’t do manually) so something must be working sort of.

If I then change the file location to be /usr/local/aerospike/usr-lua/ and run it again I get the Error[1301]: Cannot open script filedo nothing and it still fails to register - could this be an issue with the script I wonder? I’m using a direct copy / paste of the aggregate example so shouldn’t be.

Thanks


#4

Well, what comes to mind is that inside your register method you’re trying to string interpolate inside a single-quoted string. That open bracket will stay literal, it won’t be evaluated, and that’s an invalid filename in most OSes. Try changing it to ```php $status = $this->getDb()->register("{project root}/udf/my_udf.lua", ‘my_udf’);


Does that work?

#5

Thanks for the reply Ronen… my apologies but that code in there was literally to say I’m using the project root not that that was the actual code, my bad really sorry.

I have managed to get the lua script to register. I must have been doing something wrong as the demo worked fine from the example folder and now i have created my own and used the same functionality it seems to be working. No idea why as the register functions are identical but hey, that’s code for you.

Thanks for the response though… now i just need to learn lua and aggregate functions lol


#6

Ha. No problem. Keep the Lua simple, look at the examples, and if you get stuck ask about it here.

The rule of thumb for stream UDFs is minimize the records passing through it, tossing out as much records and bins that you don’t need up front. That gives you the best performance.


#7

Hi Crags, I am facing the same issue. If you found the solution for this then please let me know.


#8

Hi @nitish_janterparia - the only way I solved it was making a new file, adding the code again and registering the file again - then it all seemed to work _ I still have no idea why it didn’t - sorry


#9

@Crags…I resolved it :sunglasses:…anyways thanks for reply


#10

No problem @nitish_janterparia - do you want to post how you resolved it just in case it’s something some else comes across :slight_smile: