Aerospike 按 TTL 对所有过滤器进行计数

she*_*nzy 3 python aerospike

我正在尝试执行以下查询:

SELECT COUNT(*) FROM ns123.foo WHERE ttl < 60 * 60 * 24
Run Code Online (Sandbox Code Playgroud)

我从Aerospike AQL count(*) SQL 模拟脚本中找到了 lua 脚本来执行COUNT(*)

使用带有上述 LUA 脚本的 Python,我尝试将 UDF 与读取策略一起应用:

        client.udf_put('aggr_functions.lua')
        query = client.query('ns123', 'foo')
        policy = {
            'expressions':
                exp.LT(exp.TTL(), 60 * 60 * 24).compile()
        }
        query.apply('aggr_functions', 'count_star', [])
        records = query.results(policy)
        print(records)
Run Code Online (Sandbox Code Playgroud)

我被抛出:

Traceback (most recent call last):
  ...
    records = query.results(policy)
exception.UnsupportedFeature: (16, 'AEROSPIKE_ERR_UNSUPPORTED_FEATURE', 'src/main/aerospike/aerospike_query.c', 348, False)
Run Code Online (Sandbox Code Playgroud)

对 Python3.8 库和服务器使用 Aerospike 6.1.x。

pgu*_*pta 5

聚合不支持过滤表达式。但是你可以在lua中编写过滤器代码,在lua聚合模块本身中添加过滤器函数。(我在这里发布了一个在lua中使用带有聚合的过滤器的代码示例: https: //discuss.aerospike.com/t/record-manipulation-with-more-than-one-filter-lua/3637