关于获取 aerospike 集合中记录总数的澄清?是否需要使用 Lua 脚本?
2018-7-29 18:34:1
收藏:0
阅读:91
评论:1
我想通过 Python 获取 aerospike 集合中的记录总数。
我猜,它是在 show sets 输出中针对集合显示的 n_objects 值-
aql> show sets
+-----------+------------------+----------------+-------------------+----------------+---------------------+--------------------------------------------+------------+
| n_objects | disable-eviction | set-enable-xdr | stop-writes-count | n-bytes-memory | ns_name | set_name | set-delete |
+
| 179 | "true" | "use-default" | 0 | 0 | "namespace" | "setName" | "false" |
从我从中读到的内容,似乎只能通过 lua 脚本实现 - https://discuss.aerospike.com/t/fastest-way-to-count-records-returned-by-a-query/2379/4
有人可以证实吗?
但是,我通过迭代 select() 的结果并使用计数器变量找到了计数,并将其匹配到上面的计数 -
client = aerospike.client(config).connect()
scan = client.scan('namespace', 'set')
scan.select('PK','expiresIn','clientId','scopes','roles')
scan.foreach(process_result)
print "Total aeroCount"
print aeroCount
def process_result((key, metadata, record)):
global aeroCount
aeroCount=aeroCount+1
更新
我尝试首先在命令行上运行 asinfo -v sets 命令。它给了我对象计数,就像这样 -
ns=namespace:set=setName:objects=29949:。
不确定如何从中获取一个集合的对象计数。这个命令是否符合 Python 函数的命令?我尝试了这个 -
client = aerospike.client(config).connect()
response = client.info_all("asinfo -v sets")
这是我得到的错误 -
File "Sandeepan-oauth_token_cache_complete_sanity_cp.py", line 89, in <module>
response = client.info_all("asinfo -v sets")
AttributeError: 'aerospike.Client' object has no attribute 'info_all'
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

查看 https://www.aerospike.com/apidocs/python/client.html?highlight=info#aerospike.Client.info_all - python客户端中的info_all(),并从此处的info命令参考中传递正确的info命令:https://www.aerospike.com/docs/reference/info
setsinfo命令提供给您即时统计信息,例如在指定集合中的对象数量。$ python >>> import aerospike >>> aerospike.__version__ '2.1.2' >>> config = {'hosts':[("127.0.0.1", 3000)]} >>> client = aerospike.client(config).connect() >>> client.info("sets") {'BB9BE1CFE290C00': (None, 'ns=test:set=testMap:objects=1:tombstones=0:memory_data_bytes=0:truncate_lut=0:stop-writes-count=0:set-enable-xdr=use-default:disable-eviction=false;\n')}