I have a large JSON Dataset A (180,000 records) containing user's complete records and another JSON Dataset B (which is a subset of A) containing only some user's unique ID and name (about 1,500 records). I need to get the complete records for the users in Dataset B from Dataset A.
Here is I've tried so far
let detailedSponsoreApplicants = [];
let j;
for(j=0; j < allApplicants.length; j++){
let a = allApplicants[j];
let i;
for(i=0; i < sponsoredApplicants.length;; i++){
let s = sponsoredApplicants[i];
if (s && s.number === a.applicationNumber) {
detailedSponsoreApplicants.push(a);
}else{
if(s){
logger.warn(`${s.number} not found in master list`);
}
}
}
}
The problem with the above code is that at some point I get the error
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
So, how do I efficiently achieve the task without the errors.
EDIT - SAMPLE JSON
Dataset A
{
"applicationNumber": "3434343"
"firstName": "dcds",
"otherNames": "sdcs",
"surname": "sdcs"
"phone": "dscd",
.
.
.
"stateOfOrigin": "dcsd"
}
Dataset B
{
"number": "3434343",
"fullName": "dcds sdcs sdcs"
}