I am trying to run a fairly simple UDF stream witch runs through the entire set and calculates some statistics (simple counter).
I se two errors in two different scenarios:
When doing register through client and running through AQL I get a “unexpected symbol” error. When opening the LUA file on the server, I can see it prepends “.” symbol in the file and when I remove it, save and running again through AQL it works. (are there some issues in the file reading part of the client? Encoding maybe?)
When above are fixed and the AQL method works I try to run the same UDF from the client, but keeps getting the below error message:
Query Failed: Method not found: ‘Neo.IronLua.LuaGlobal Neo.IronLua.Lua.CreateEnvironment()’.
I can’t find anything about that error?
Code for register:
var clientDirectory = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "Aerospike\\LUA");
LuaConfig.PackagePath = clientDirectory + @"\?.lua";
var filename = "Statistics.lua";
var clientPath = Path.Combine(clientDirectory, filename);
RegisterTask task = Handler.Client.Register(null, clientPath, filename, Language.LUA);
task.Wait();
Code for execution:
var stmt = new Statement();
stmt.SetNamespace("nstest");
stmt.SetSetName("settest");
var resultSet = Aerospike.Client.QueryAggregate(null, stmt, "Statistics", "sum");
if (resultSet.Next())
...
Can you provide the exact AQL registration string command?
NeoLua is required to run the lua aggregation function on the client for the final reduce. Therefore, you need to copy Neo.Lua.dll and Neo.Lua.pdb to the same directory as AerospikeClient.dll and AerospikeClient.pdb.
We have identified the problem. Statistics.lua contains a “Byte Order Mark” (BOM) prefix that both Windows and Linux understand and skip over. Unfortunately, the lua interpreter does not parse and skip over these initial characters.
$ lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require 'Statistics'
error loading module 'Statistics' from file './Statistics.lua':
./Statistics.lua:1: unexpected symbol near '�'
stack traceback:
[C]: ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: ?
$ file Statistics.lua
Statistics.lua: UTF-8 Unicode (with BOM) text, with CRLF line terminators
$ xxd -p Statistics.lua | head -1
efbbbf6c6f63616c2066756e6374696f6e206167677265676174655f7374
"efbbbf" is the BOM.
6c = 'l'
6f = 'o'
63 = 'c'
61 = 'a'
6c = 'l'
Windows is apparently creating BOM by default. Linux does not create BOM by default. If you remove the BOM from both the client and server file, everything should work.
I did it … the neolua files (Neo.Lua.dll, Neo.Lua.pdb, Neo.Lua.xml) are on same folder as aerospike client files (AerospikeClient.dll, AerospikeClient.pdb, AerospikeClient.xml)
Do the example aggregation queries (Query Sum, Query Average) in AerospikeDemo work for you?
I would helpful if you could provide a sample solution (including lua functions) that just runs one aggregation query which results in the error.
It may not be applicable to your query, but records can’t be passed to the client in aggregation queries. The record bins must be copied to a map (which can be passed to the client).
Since this topic comes us when searching for Method not found: 'Neo.IronLua.LuaGlobal Neo.IronLua.Lua.CreateEnvironment()', I would like to add this information:
Aerospike 3.4.4 (and previous versions) does not support Neo.Lua 1.0 and above. The last supported version from Nuget is 0.9.17. All newer versions will break LUA support in AerospikeClient.
Btw, it can be very easily fixed in the Aerospike client library, though just setting the upper limit for Neo.Lua dependency would be enough.
I’ve always used Neo.Lua 0.9.14, so that is why it worked for me. I will try to resolve the problem with Neo.Lua 1.0 and above. If I can’t resolve, I will set the Neo.Lua package dependency to exactly [0.9.14].
Np Brian. FYI, the majority of the code changes necessary to migrate are rather simple, but the new Neo.Lua is a .NET Portable library that targets .NET Framework 4.5, and the Aerospike client library target 4.0, which is a bigger change.
The lastest Neo.Lua version 1.2.23 broke our tests that accessed our type class library (LuaList, LuaMap, etc…).
map = clr.Aerospike.Client.LuaMap
local m = map()
For some reason, Neo.Lua versions >= 1.0.0 can’t resolve them. I will create a new nuget dll that fixes the Neo.Lua version dependency at exactly 0.9.14 on Monday.