Skip to content

Commit

Permalink
Speed up Polish JSON data for loop (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leslie-Wong-H authored Apr 25, 2023
2 parents d69ef93 + ddef9ab commit 1a2e70c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,16 @@ const messageHandle = async (data) => {
try {
console.log(`Polish JSON data`);

const jsonData = dedupedHashList.map((doc) => {
return {
let jsonData = new Array(dedupedHashList.length).fill(null);
for (let i = 0; i < dedupedHashList.length; i++) {
const doc = dedupedHashList[i];
jsonData[i] = {
id: `${file}/${doc.time.toFixed(2)}`,
// cl_hi: doc.cl_hi, // reduce index size
cl_ha: getNormalizedCharCodesVector(doc.cl_ha, 100, 1),
primary_key: getPrimaryKey(doc.cl_hi),
};
});
}

// Pause for 5 seconds to make node arrange the compute resource.
console.log("Pause for 5 seconds");
Expand Down

0 comments on commit 1a2e70c

Please sign in to comment.