Skip to content

Commit

Permalink
Filter non-canonical eclasses before rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
mcheshkov committed Nov 13, 2024
1 parent ef25363 commit 5212ee8
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions rust/cubesql/cubesql/egraph-debug-template/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,16 @@ function prepareStates(states: InputData): Array<PreparedStateData> {
} as InputNodeData;
})
.concat(
egraph.eclasses.map((eclass) => {
return {
id: eclass.id.toString(),
label: eclass.id.toString(),
comboId: `c${eclass.id}`,
} as InputNodeData;
}),
egraph.eclasses
// render only canonical eclasses to avoid rendering empty nodes and combos for merged ones
.filter((eclass) => eclass.id === eclass.canon)
.map((eclass) => {
return {
id: eclass.id.toString(),
label: eclass.id.toString(),
comboId: `c${eclass.id}`,
} as InputNodeData;
}),
);

const allEdges = egraph.enodes
Expand Down Expand Up @@ -144,12 +147,15 @@ function prepareStates(states: InputData): Array<PreparedStateData> {
}
let edges = [...uniqueEdges.values()];

let combos = egraph.eclasses.map((eclass) => {
return {
id: `c${eclass.id}`,
label: `#${eclass.id}`,
} as InputComboData;
});
let combos = egraph.eclasses
// render only canonical eclasses to avoid rendering empty nodes and combos for merged ones
.filter((eclass) => eclass.id === eclass.canon)
.map((eclass) => {
return {
id: `c${eclass.id}`,
label: `#${eclass.id}`,
} as InputComboData;
});

const nodesClone = nodes.slice();
const edgesClone = edges.slice();
Expand Down

0 comments on commit 5212ee8

Please sign in to comment.