Skip to content

Commit

Permalink
add generateDdlEdges
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel committed Sep 16, 2024
1 parent 6b5806d commit 5580388
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
3 changes: 1 addition & 2 deletions dashboard/components/DdlGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export default function DdlGraph({

const fragmentLayout = layoutItem(
fragmentDependencyDag.map(({ width: _1, height: _2, id, ...data }) => {
const { width, height } = layoutFragmentResult.get(id)!
return { width, height, id, ...data }
return { width: 100, height: 100, id, ...data }
}),
fragmentDistanceX,
fragmentDistanceY
Expand Down
56 changes: 55 additions & 1 deletion dashboard/lib/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ export interface Position {

export type FragmentBoxPosition = FragmentBox & Position
export type RelationPointPosition = RelationPoint & Position
export type DdlBoxPosition = DdlBox & Position

export interface Edge {
points: Array<Position>
Expand Down Expand Up @@ -495,7 +496,7 @@ export function generateFragmentEdges(
// Simply draw a horizontal line here.
// Typically, external parent is only applicable to `StreamScan` fragment,
// and there'll be only one external parent due to `UpstreamShard` distribution
// and plan node sharing. So there's no overlapping issue.
// and plan node sharing. So we won't see multiple horizontal lines overlap each other.
for (const externalParentId of fragment.externalParentIds) {
links.push({
points: [
Expand All @@ -515,3 +516,56 @@ export function generateFragmentEdges(
}
return links
}

export function generateDdlEdges(
layoutMap: DdlBoxPosition[]
): Edge[] {
const links = []
const ddlMap = new Map<string, DdlBoxPosition>()
for (const x of layoutMap) {
ddlMap.set(x.id, x)
}
for (const ddl of layoutMap) {
for (const parentId of ddl.parentIds) {
const parentDdl = ddlMap.get(parentId)!
links.push({
points: [
{
x: ddl.x + ddl.width / 2,
y: ddl.y + ddl.height / 2,
},
{
x: parentDdl.x + parentDdl.width / 2,
y: parentDdl.y + parentDdl.height / 2,
},
],
source: ddl.id,
target: parentId,
})
}

// TODO(kwannoel)
// Simply draw a horizontal line here.
// Typically, external parent is only applicable to `StreamScan` fragment,
// and there'll be only one external parent due to `UpstreamShard` distribution
// and plan node sharing. So we won't see multiple horizontal lines overlap each other.
// for (const externalParentId of ddl.externalParentIds) {
// links.push({
// points: [
// {
// x: fragment.x,
// y: fragment.y + fragment.height / 2,
// },
// {
// x: fragment.x + 100,
// y: fragment.y + fragment.height / 2,
// },
// ],
// source: fragment.id,
// target: externalParentId,
// })
// }
}
return links
}

0 comments on commit 5580388

Please sign in to comment.