1

我的 lua 代码来自官方网站的示例:

local function one(rec)
    info("lalalalal  %s",rec['id'])
    return 1
end
local function add(a, b)
    return a + b
end
function mycount(stream)
    return stream : map(one) : reduce(add);
end

当我使用 aql 命令时:

日志中的错误,例如吹:

2015 年 5 月 20 日 07:12:07 GMT:调试(udf):(udf_rw.c:send_result:515)调用 stream_udf mycount /opt/aerospike/usr/udf/lua/stream_udf.lua:10 时失败:尝试调用方法'map'(零值)2015 年 5 月 20 日 07:12:07 GMT:调试(udf):(udf_rw.c:send_udf_failure:403)非特殊 LDT 或一般 UDF 错误(/opt/aerospike/usr/udf/ lua/stream_udf.lua:10: 尝试调用方法 'map' (一个 nil 值))

如何解决?谢谢

4

1 回答 1

1

这是一个 Lua 问题,它不会自动将 nil 转换为字符串,而 print 和 info() 等函数需要这种类型。将您的线路更改为

info("lalalalal  %s", tostring(rec['id']))
于 2015-05-21T17:07:24.510 回答