Files
wehub-resource-sync a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

28 lines
948 B
Go

package graph
// outEdgesBatcher is implemented by backends that can fetch many nodes'
// out-edges in a single query (the disk-backed stores), collapsing the
// per-node N+1 the single-file resolve path would otherwise issue.
type outEdgesBatcher interface {
GetOutEdgesForNodes(ids []string) map[string][]*Edge
}
// OutEdgesForNodes returns each node's outgoing edges, using the backend's
// batched query when it offers one and falling back to per-node lookups
// otherwise (the in-memory graph, where each lookup is already an O(1) map
// hit). Nodes with no out-edges may be absent from the returned map.
func OutEdgesForNodes(r interface {
GetOutEdges(nodeID string) []*Edge
}, ids []string) map[string][]*Edge {
if b, ok := r.(outEdgesBatcher); ok {
return b.GetOutEdgesForNodes(ids)
}
out := make(map[string][]*Edge, len(ids))
for _, id := range ids {
if e := r.GetOutEdges(id); len(e) > 0 {
out[id] = e
}
}
return out
}