如何使用aerospike加载器在aerospike中加载嵌套的csv文件? [英] How to load a nested csv file in aerospike using aerospike loader?

查看:215
本文介绍了如何使用aerospike加载器在aerospike中加载嵌套的csv文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将JSON文件转换为CSV格式,现在使用aerospike加载程序在Aerospike中加载CSV。我可以这样做简单的结构,但如何修改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
}
}
}
}
}
}


b $ b

CSV FILE

  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有效载荷上面应该存储在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)+\\\
);
console.printf(password:+ user_records.getValue(password)+\\\
);


I have converted JSON file to CSV format and now loading the CSV in Aerospike using aerospike loader. I can do this for simple structure but how to modify the contents of allDatatype.json to load the nested CSV file in Aerospike?

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

JSON FILE

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

CSV FILE

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

解决方案

My understanding which I must admit is limited as I have only just started looking into Aerospike is to forget that you want to store the whole object in one (which as suggested above in the comments, as this is more like a document store). Instead you need to think of it in the world of Key-Value terms. My understanding is that your json payload above should be stored in Aerospike like so

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

then you can do something like this:

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");

这篇关于如何使用aerospike加载器在aerospike中加载嵌套的csv文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆