Hi all,
I’m trying to pass some information (BLOB in aerospike aka byte in a java client aka bytes in LUA) from a LUA filtering routine to a C function.
Unfortunately from C side I’m not able to access any kind of information (lua_isnumber, lua_isstring and lua_istable return false).
If I simply pass a byte (and NOT an array of byte) the information is retrieved correctly in the C routine.
Does somebody have any idea why this scenario is not working or does somebody have any pointer to the aerospike/lua documentation?
Thanks you soooo much!
My code is: From the Java Client I create a byte array of size = 6 and invoke a LUA routine called testingC in a prova2.lua file. I pass to LUA the byte
byte[] java_query_pool={13, 15, 11, 0, 99, 77};
rs =client.queryAggregate(null, stmt, "prova2", "testingC", Value.get(java_query_pool) );
in the LUA routine i can correctly retrieve the array of byte and I’m able to retrieve the size of the array and the contents of the array (i.e. I’m able to retrieve the 6-th data = 77)
local function myfilter1(pool_query)
local fromlua=require("fromlua")
local sizee=bytes.size(pool_query)
info (sizee)
local unbyte=bytes.get_byte(pool_query,6)
info (unbyte)
If i pass the pool_query (bytes) to the C routine the data is not available on C side (is even not recognized like strin/number/table). If i pass the unbyte (simple one byte) to C, the data is correctly retrieved
WORKING SCENARIO:
From LUA
local return_value = fromlua.match(unbyte);
to the C routine
static int match(lua_State * L)
{
int rtrn = lua_tonumber(L, -1);
NOT WORKING SCENARIO
from LUA
local return_value = fromlua.match(pool_query);
to C
static int match(lua_State * L) {
syslog(LOG_INFO, "whattisit");
if (lua_isnumber(L, -1)) {
syslog(LOG_INFO, "iz a number");
}
else if (lua_isstring(L, -1)) {
syslog(LOG_INFO, "iz a string");
}
else if (lua_istable(L, -1)) {
syslog(LOG_INFO, "iz a table");
}
else syslog(LOG_INFO, "iz NONE"); <-- this is printed out
const void *rtrn=lua_topointer(L, -1); <-- return pointer to ZERO
//int rtrn = lua_tonumber(L, -1); <-- return ZERO
//const char *value = lua_tostring(L, -1); <-- return NULL
Any helps is more than appreciate! Thankssss