Aerospike 查询语言获取列表大小和计数

Aerospike query language get list size and count

我正在使用 aerospike 列表功能 (http://www.aerospike.com/docs/guide/cdt-list.html) 并且可以执行 select 查询来查看列表:

select bin from ns.set where PK='pk'

但是有什么方法可以获取列表中的元素数吗? 而且我还有一种方法可以看到记录的当前大小(因为最大记录大小有限制)

AQL 是一种工具,主要用于管理索引、UDF、运行 临时 UDF(维护、汇总等),并在较小程度上用于浏览数据。如果要使用全套List或Map操作,应该使用Java, Python, Go等语言客户端

列表API包括列表的size()。例如,在 Python 客户端中,您有 aerospike.Client.list_size. Because the list is stored in a msgpack serialized format at the server-side, it's going to be hard for you to tell if the msgpacked list is larger than your max-write-block,假设您的数据在 SSD 上(如果它在内存中而没有持久性,则您没有相同的记录大小限制)。

你可以估计大小,但要遵循EAFP原则,写记录而不用事先担心大小,并捕获error code 13 'record too big' (for example, aerospike.exception.RecordTooBig的异常会更简单。然后,您可以决定如何溢出到单独的记录中(keykey-2 .. key-N)。