Skip to content

Commit

Permalink
use relation deps api
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel committed Sep 19, 2024
1 parent 446b79e commit abb2a72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Start a RisingWave cluster, create some tables and materialized views for testin
For example:

```bash
./risedev d full
./risedev d
./risedev slt e2e_test/nexmark/create_sources.slt.part
./risedev psql -c 'CREATE TABLE dimension (v1 int);'
./risedev psql -c 'CREATE MATERIALIZED VIEW mv AS SELECT auction.* FROM dimension join auction on auction.id-auction.id = dimension.v1;'
Expand Down
37 changes: 21 additions & 16 deletions dashboard/pages/ddl_graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,33 @@ import {
StreamingJob,
getFragmentVertexToRelationMap,
getSchemas,
getStreamingJobs,
getStreamingJobs, getRelationDependencies,
} from "../lib/api/streaming"
import { DdlBox } from "../lib/layout"
import { BackPressureInfo } from "../proto/gen/monitor_service"

// Refresh interval (ms) for back pressure stats
const INTERVAL_MS = 5000

function buildDdlDependencyAsEdges(relations: StreamingJob[]): DdlBox[] {
function buildDdlDependencyAsEdges(relations: StreamingJob[], relationDeps: Map<number, number[]>): DdlBox[] {
// Filter out non-streaming relations, e.g. source, views.
let relationIds = new Set<number>()
for (const relation of relations) {
relationIds.add(relation.id)
}
const nodes: DdlBox[] = []
for (const relation of relations) {
let parentIds = relation.dependentRelations
let parentIds = relationDeps.get(relation.id)
nodes.push({
id: relation.id.toString(),
order: relation.id,
width: 0,
height: 0,
parentIds: parentIds
.filter((x) => relationIds.has(x))
.map((x) => x.toString()),
? parentIds
.filter((x) => relationIds.has(x))
.map((x) => x.toString())
: [],
ddlName: relation.name,
schemaName: relation.schemaName ? relation.schemaName : "",
})
Expand All @@ -89,6 +91,7 @@ interface EmbeddedBackPressureInfo {

export default function Streaming() {
const { response: relationList } = useFetch(getStreamingJobs)
const { response: relationDeps } = useFetch(getRelationDependencies)
const { response: fragmentVertexToRelationMap } = useFetch(
getFragmentVertexToRelationMap
)
Expand All @@ -106,20 +109,22 @@ export default function Streaming() {

const ddlDependencyCallback = useCallback(() => {
if (relationList) {
if (schemas) {
let relationListWithSchemaName = relationList.map((relation) => {
let schemaName = schemas.find(
(schema) => schema.id === relation.schemaId
)?.name
return { ...relation, schemaName }
})
const ddlDep = buildDdlDependencyAsEdges(relationListWithSchemaName)
return {
ddlDep,
if (relationDeps) {
if (schemas) {
let relationListWithSchemaName = relationList.map((relation) => {
let schemaName = schemas.find(
(schema) => schema.id === relation.schemaId
)?.name
return { ...relation, schemaName }
})
const ddlDep = buildDdlDependencyAsEdges(relationListWithSchemaName, relationDeps)
return {
ddlDep,
}
}
}
}
}, [relationList, schemas])
}, [relationList, relationDeps, schemas])

const ddlDependency = ddlDependencyCallback()?.ddlDep

Expand Down

0 comments on commit abb2a72

Please sign in to comment.