Skip to content

Commit

Permalink
Add delta compression to change list
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Feb 9, 2024
1 parent be3e588 commit a31c09b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/build-raw-near-lake-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ async function writeChangesFile(outPath, changesByAccount) {
changes = changes.slice(0, maxChangesLength);
}
writeVarint(changes.length);
let prevChange = 0;
for (let change of changes) {
writeVarint(change);
writeVarint(change - prevChange);
prevChange = change;
}
i += changes.length;
}
Expand Down Expand Up @@ -365,6 +367,9 @@ async function *readChangesFile(inPath) {
const changes = new Array(count);
for (let i = 0; i < count; i++) {
changes[i] = readVarint();
if (i > 0) {
changes[i] += changes[i - 1];
}
}

yield { accountId, key, changes };
Expand Down

0 comments on commit a31c09b

Please sign in to comment.