Aerospike - 使用多个过滤器进行查询
Aerospike - Query with Multiple Filters
我正在尝试使用多个过滤器查询 aerospike,参考下面提到的 link ...
https://www.aerospike.com/community/labs/query_multiple_filters.html
在上述线程中提出的示例中,使用的 aerospike-client 版本是 3.0.22,而我在我的项目中使用的是 3.0.0 版本。
我能够查询数据库并检索所需的数据,更改 aerospike 网站上提到的示例,但是当我 运行 在我的项目中使用相同的代码时,没有返回任何数据。
3.0.0 版是否不支持 lua 用于数据检索的脚本和聚合函数?如果是,有没有其他方法可以查询 3.0.0 版的相同信息?
Lua 脚本
local function map_order(record)
return map {key=record.key, mid=record.mid, orderId=record.orderId, amount=record.amount}
end
function filter_order(stream, mid)
local function filter_mid(record)
return record.mid == mid
end
return stream : filter(filter_mid) : map(map_order)
end
数据检索代码
ResultSet resultSet = client.queryAggregate(null, stmt, "profile", "filter_order", Value.get("mid334"));
编辑:获取此异常
com.aerospike.client.AerospikeException: Failed to read file: /home/lalit/spring-suite/sts-bundle/sts-3.6.3.RELEASE/udf/profile.lua
当文件位于 /home/lalit/udf/profile.udf
注册lua文件的代码
LuaConfig.SourceDirectory = "udf";
udfFile = new File("/home/lalit/udf/profile.lua");
task = client.getAerospikeClient().register(null, udfFile.getPath(), udfFile.getName(), Language.LUA);
task.waitTillComplete();
设法解决了。
QueryAggregateExecutor 的 运行 方法从它使用 LuaConfig.SourceDirectory 变量定位到脚本文件的路径。
我正在通过 udf
LuaConfig.SourceDirectory = "udf"
应该是 /home/lalit/udf
LuaConfig.SourceDirectory = "/home/lalit/udf"
我正在尝试使用多个过滤器查询 aerospike,参考下面提到的 link ...
https://www.aerospike.com/community/labs/query_multiple_filters.html
在上述线程中提出的示例中,使用的 aerospike-client 版本是 3.0.22,而我在我的项目中使用的是 3.0.0 版本。 我能够查询数据库并检索所需的数据,更改 aerospike 网站上提到的示例,但是当我 运行 在我的项目中使用相同的代码时,没有返回任何数据。
3.0.0 版是否不支持 lua 用于数据检索的脚本和聚合函数?如果是,有没有其他方法可以查询 3.0.0 版的相同信息?
Lua 脚本
local function map_order(record)
return map {key=record.key, mid=record.mid, orderId=record.orderId, amount=record.amount}
end
function filter_order(stream, mid)
local function filter_mid(record)
return record.mid == mid
end
return stream : filter(filter_mid) : map(map_order)
end
数据检索代码
ResultSet resultSet = client.queryAggregate(null, stmt, "profile", "filter_order", Value.get("mid334"));
编辑:获取此异常
com.aerospike.client.AerospikeException: Failed to read file: /home/lalit/spring-suite/sts-bundle/sts-3.6.3.RELEASE/udf/profile.lua
当文件位于 /home/lalit/udf/profile.udf
注册lua文件的代码
LuaConfig.SourceDirectory = "udf";
udfFile = new File("/home/lalit/udf/profile.lua");
task = client.getAerospikeClient().register(null, udfFile.getPath(), udfFile.getName(), Language.LUA);
task.waitTillComplete();
设法解决了。
QueryAggregateExecutor 的运行 方法从它使用 LuaConfig.SourceDirectory 变量定位到脚本文件的路径。
我正在通过 udf
LuaConfig.SourceDirectory = "udf"
应该是 /home/lalit/udf
LuaConfig.SourceDirectory = "/home/lalit/udf"