Skip to content

Commit

Permalink
Reduce memory usage of symmetric hash join
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
jeswr authored May 22, 2024
1 parent d3ace4c commit 131c8ad
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions join/SymmetricHashJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,18 @@ class SymmetricHashJoin extends AsyncIterator
}

let hash = this.funHash(item);
let map = this.usedLeft ? this.leftMap : this.rightMap;
if (!map.has(hash))
map.set(hash, []);
let arr = map.get(hash);
arr.push(item);

if (this.usedLeft && this.right.done) {
this.leftMap = null;
} else if (this.left.done) {
this.rightMap = null;
} else {
let map = this.usedLeft ? this.leftMap : this.rightMap;
if (!map.has(hash))
map.set(hash, []);
let arr = map.get(hash);
arr.push(item);
}

this.match = item;
this.matches = (this.usedLeft ? this.rightMap : this.leftMap).get(hash) || [];
Expand Down

0 comments on commit 131c8ad

Please sign in to comment.