Aerospike set - dumping into JSON(L)

677 Views Asked by At

How do I dump a set in Aerospike into JSON (newline-separated JSON)?

I tried

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

and

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

but both get stuck after dumping ~25MB (for unknown reasons).

Edit: formatting.

1

There are 1 best solutions below

0
On

Long story short, I took the long route (wrote a script):

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)