database - 如何使用 aerospike 加载程序在 aerospike 中加载嵌套的 csv 文件?

标签 database csv import nested aerospike

我已将 JSON 文件转换为 CSV 格式,现在使用 aerospike 加载器将 CSV 加载到 Aerospike 中。我可以为简单的结构执行此操作,但如何修改 allDatatype.json 的内容以在 Aerospike 中加载嵌套的 CSV 文件?

https://github.com/aerospike/aerospike-loader/tree/master/example

JSON 文件

{
"centers" : {
"ER" : {
"admin":{
"users" : {
  "emp1" : {
    "password" : "abcdefgh",
    "username" : "pankaj-roy"
  },
  "emp2" : {
    "password" : "12345678",
    "username" : "niketan-shah"
  }
}
}
}
}
}

CSV 文件

centers.ER.admin.users.emp2.username,centers.ER.admin.users.emp2.password, centers.ER.admin.users.emp1.username,centers.ER.admin.users.emp1.password
niketan-shah,12345678,pankaj-roy,abcdefgh

最佳答案

我必须承认我的理解是有限的,因为我才刚刚开始研究 Aerospike 是忘记了你想将整个对象存储在一个中(正如上面评论中所建议的,因为这更像是一个文档存储).相反,您需要在 Key-Value 术语的世界中考虑它。我的理解是你上面的 json payload 应该像这样存储在 Aerospike 中

Bin=users
Set=creds
Key=(username, "pankaj-roy")
bin=(password, "abcdefgh")
bin=(role, "admin")`

然后你可以这样做:

user_key = new Key("users", "creds", username);
user_records = client.get(null, user_key);
console.printf("username:   " + user_records.getValue("username") + "\n");
console.printf("password:   " + user_records.getValue("password") + "\n");

关于database - 如何使用 aerospike 加载程序在 aerospike 中加载嵌套的 csv 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32794867/

相关文章:

python - 仅当 main 在 python 包中运行时导入包

mysql - 对复杂用户交互的数据库建模的最佳方法是什么?

mysql - 使用导出与动态数据库node.js连接

csv - 如何在 CSV 格式的文件中编码超链接?

mysql - 在 MySQL 字段中加载数字

import - 在Dart中导入库

database - 我可以使用数据转换器来组合 symfony2 中表单中的字段吗

MySQL:追加记录:查找然后追加或仅追加

python : editing several files : loop on a list of file

mysql - 从批处理文件将 .sql 文件导入 mysql