Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM]Improve performance of join_by_key #178177

Merged
merged 15 commits into from
Mar 7, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function joinByKey(
const keys = castArray(key);
// Create a map to quickly query the key of group.
const map = new Map();
return items.reduce<Array<Record<string, any>>>((prev, current) => {
items.forEach((current) => {
// The key of the map is a stable JSON string of the values from given keys.
// We need stable JSON string to support plain object values.
const stableKey = stableStringify(keys.map((k) => current[k]));
Expand All @@ -72,7 +72,6 @@ export function joinByKey(
} else {
map.set(stableKey, { ...current });
}

return [...map.values()];
}, []);
});
return [...map.values()];
}