mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 18:05:45 +00:00
perf(javascript): index change-graph nodes once per comparison
Resolve each compared graph node through a per-side index while preserving right-hand evidence selection and complete comparison results. Refs #1065. Co-authored-by: keemsisi <7439375+keemsisi@users.noreply.github.com>
This commit is contained in:
1 parent
eeb83f6581
commit
33b9b31a6f
2 files changed
+124
-8
No files matched your search
@@ -53,8 +53,14 @@ export const buildJavaScriptApplicationChangeGraph = (
|
||||
({ source_node_id: source, target_node_id: target }) =>
|
||||
retained.has(source) && retained.has(target),
|
||||
);
|
||||
const leftById = new Map(
|
||||
input.left.nodes.map((node) => [node.node_id, node]),
|
||||
);
|
||||
const rightById = new Map(
|
||||
input.right.nodes.map((node) => [node.node_id, node]),
|
||||
);
|
||||
const comparisonEdges = input.items.flatMap((item) =>
|
||||
changedFromEdge(item, input, retained),
|
||||
changedFromEdge(item, input, retained, leftById, rightById),
|
||||
);
|
||||
const candidateEdges = uniqueEdges([...sourceEdges, ...comparisonEdges]);
|
||||
const rootNodeIds = preferredRoots.filter((nodeId) => retained.has(nodeId));
|
||||
@@ -104,6 +110,8 @@ const changedFromEdge = (
|
||||
item: ApplicationVersionComparisonItem,
|
||||
input: ChangeGraphInput,
|
||||
retained: ReadonlySet<string>,
|
||||
leftById: ReadonlyMap<string, ApplicationNode>,
|
||||
rightById: ReadonlyMap<string, ApplicationNode>,
|
||||
): ApplicationEdge[] => {
|
||||
const left = item.left_node_id;
|
||||
const right = item.right_node_id;
|
||||
@@ -117,7 +125,12 @@ const changedFromEdge = (
|
||||
!retained.has(right)
|
||||
)
|
||||
return [];
|
||||
const evidence = comparisonEvidence(item, input);
|
||||
const evidence = comparisonEvidence(
|
||||
item,
|
||||
input,
|
||||
leftById.get(left),
|
||||
rightById.get(right),
|
||||
);
|
||||
return [
|
||||
createJavaScriptApplicationEdge({
|
||||
source_node_id: right,
|
||||
@@ -138,13 +151,9 @@ const changedFromEdge = (
|
||||
const comparisonEvidence = (
|
||||
item: ApplicationVersionComparisonItem,
|
||||
input: ChangeGraphInput,
|
||||
left: ApplicationNode | undefined,
|
||||
right: ApplicationNode | undefined,
|
||||
): ApplicationGraphEvidence => {
|
||||
const right = input.right.nodes.find(
|
||||
({ node_id: id }) => id === item.right_node_id,
|
||||
);
|
||||
const left = input.left.nodes.find(
|
||||
({ node_id: id }) => id === item.left_node_id,
|
||||
);
|
||||
const source =
|
||||
right?.observations[0]?.evidence ?? left?.observations[0]?.evidence;
|
||||
const complete =
|
||||
|
||||
Reference in new issue
Block a user