【问题标题】:aerospike udf error attempt to call method 'map' (a nil value)aerospike udf 错误尝试调用方法“map”(零值)
【发布时间】:2015-05-20 07:16:40
【问题描述】:

我的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 命令时:

blow 等日志中的错误:

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'(一个零值))

如何解决? 谢谢

【问题讨论】:

    标签: lua aerospike


    【解决方案1】:

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

    info("lalalalal  %s", tostring(rec['id']))
    

    【讨论】:

      猜你喜欢
      • 2019-01-06
      • 2015-06-15
      • 1970-01-01
      • 1970-01-01
      • 2021-06-07
      • 2015-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多