Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load a nested csv file in aerospike using aerospike loader?

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
like image 549
hmims Avatar asked Oct 19 '22 01:10

hmims


1 Answers

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");
like image 100
mmkd Avatar answered Nov 01 '22 12:11

mmkd