【问题标题】:Aerospike set - dumping into JSON(L)Aerospike 集 - 转储到 JSON(L)
【发布时间】:2018-06-12 05:59:26
【问题描述】:

如何将 Aerospike 中的 set 转储为 JSON(换行符分隔的 JSON)?

我试过了

aql -h 10.0.0.1 --no-config-file --outputmode=json -c "select * fromnamespace.set_name" >> whatever.json

(echo "select * from namespace.set_name" && cat) | aql -h 10.0.0.1 --no-config-file --outputmode=json > whatever.txt

但在转储 ~25MB 后两者都卡住了(原因不明)。

编辑:格式化。

【问题讨论】:

  • 使用 aql 选项,我想知道您是否达到了超时。您是否通过将 aql -T 选项设置为高值来尝试过。
  • aql 一直在运行,但停止转储数据,与 -T 选项相同。

标签: aerospike aerospike-ce


【解决方案1】:

长话短说,我走了很长的路(写了一个剧本):

import aerospike
import json

config = {
    'hosts': [ ('10.0.0.1', 3000) ]
}

try:
    client = aerospike.client(config).connect()
except:
    import sys
    print("rekt lol dump yourself", config['hosts'])
    sys.exit(1)

query = client.query('dmp', 'whatever')
query.select('id', 'not_id', 'not_id_at_all')

with open('whatever.json', 'w') as out:
    def processRecord(arg):
        key, metadata, record = arg
        out.write(json.dumps(record))
        out.write('\n')

    query.foreach(processRecord)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多