有关获取 aerospike 集中记录总数的说明?是否需要 Lua 脚本?
Clarifications related to getting the total number of records in an aerospike set? Is Lua scripting needed?
我想通过 python 获取 aerospike 集中的记录总数。
我猜,这是针对 n_objects 与 show sets
-
输出中的集合显示的值
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'
调查 https://www.aerospike.com/apidocs/python/client.html?highlight=info#aerospike.Client.info_all - info_all() in the python client and pass the correct info command from the info command reference here: https://www.aerospike.com/docs/reference/info
sets
信息命令为您提供即时统计信息,例如指定集合中的对象数量。
$ 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')}
我想通过 python 获取 aerospike 集中的记录总数。
我猜,这是针对 n_objects 与 show sets
-
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'
调查 https://www.aerospike.com/apidocs/python/client.html?highlight=info#aerospike.Client.info_all - info_all() in the python client and pass the correct info command from the info command reference here: https://www.aerospike.com/docs/reference/info
sets
信息命令为您提供即时统计信息,例如指定集合中的对象数量。
$ 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')}