-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
refactor(graph): optimize graph api, improve docs #6792
base: v5
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request refactors the graph API by optimizing the performance of Changes
|
*/ | ||
public getNodeData(ids: ID[]): NodeData[]; | ||
public getNodeData(id?: ID | ID[]): NodeData | NodeData[] { | ||
if (id === undefined) return this.context.model.getNodeData(); | ||
if (Array.isArray(id)) return this.context.model.getNodeData(id); | ||
return this.context.model.getNodeData([id])?.[0]; | ||
return this.context.model.getNodeLikeDatum(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change from getNodeData([id])?.[0]
to getNodeLikeDatum(id)
improves performance by directly accessing the node datum without wrapping it in an array. Ensure that getNodeLikeDatum
handles non-existent IDs appropriately to avoid runtime errors.
*/ | ||
public getEdgeData(ids: ID[]): EdgeData[]; | ||
public getEdgeData(id?: ID | ID[]): EdgeData | EdgeData[] { | ||
if (id === undefined) return this.context.model.getEdgeData(); | ||
if (Array.isArray(id)) return this.context.model.getEdgeData(id); | ||
return this.context.model.getEdgeData([id])?.[0]; | ||
return this.context.model.getEdgeDatum(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change from getEdgeData([id])?.[0]
to getEdgeDatum(id)
enhances performance by directly accessing the edge datum. Verify that getEdgeDatum
properly manages cases where the ID does not exist to prevent potential exceptions.
*/ | ||
public getComboData(ids: ID[]): ComboData[]; | ||
public getComboData(id?: ID | ID[]): ComboData | ComboData[] { | ||
if (id === undefined) return this.context.model.getComboData(); | ||
if (Array.isArray(id)) return this.context.model.getComboData(id); | ||
return this.context.model.getComboData([id])?.[0]; | ||
return this.context.model.getNodeLikeDatum(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The update from getComboData([id])?.[0]
to getNodeLikeDatum(id)
optimizes the retrieval process by directly accessing the combo datum. Confirm that getNodeLikeDatum
correctly handles scenarios where the combo ID is missing to avoid errors.
getNodeData
、getEdgeData
、getComboData
API performanceRelative Issue: #6784