gpt4 book ai didi

java - 如何为范围查询编写 Aerospike 流 UDF

转载 作者:行者123 更新时间:2023-11-30 02:43:44 25 4
gpt4 key购买 nike

我为范围查询编写了一个流 UDF,但它无法正常工作。你知道如何用 lua 设置多个过滤器吗?

查询:

SELECT id1, id2, link_type, visibility, data, time, version FROM linktable
WHERE id1 = <id1> AND
link_type = <link_type> AND
time >= <minTime> AND
time <= <maxTimestamp> AND
visibility = VISIBILITY_DEFAULT
ORDER BY time DESC LIMIT <offset>, <limit>;

调用此 lua 函数的 Java 代码:

stmt = new Statement();
stmt.setNamespace(dbid);
stmt.setSetName("links");
stmt.setIndexName("time");
stmt.setFilters(Filter.range("time", minTimestamp, maxTimestamp));
stmt.setAggregateFunction("linkbench", "check_id1", Value.get(id1));
stmt.setAggregateFunction("linkbench", "check_linktype", Value.get(link_type));
resultSet = client.queryAggregate(null, stmt, "linkbench", "check_visibility", Value.get(VISIBILITY_DEFAULT));

Lua脚本:

local function map_links(record)
-- Add user and password to returned map.
-- Could add other record bins here as well.
return record.id2
end

function check_id1(stream,id1)
local function filter_id1(record)
return record.id1 == id1
end
return stream : filter(filter_id1) : map(map_links)
end

function check_linktype(stream,link_type)
local function filter_linktype(record)
return record.link_type == link_type
end
return stream : filter(filter_linktype) : map(map_links)
end

function check_visibility(stream,visibility)
local function filter_visibility(record)
return record.visibility == visibility
end
return stream : filter(filter_visibility) : map(map_links)
end

知道如何为所有查询限制编写过滤器吗?

谢谢!

最佳答案

release 3.12一个predicate filter完全避免 Lua 以获得更好的性能和可扩展性将是正确的方法。

看看PredExp Java 客户端的类及其 examples用于构建复杂的过滤器。目前还存在 C 的谓词过滤。 , C#Go客户。

关于java - 如何为范围查询编写 Aerospike 流 UDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40852236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com