本文整理汇总了Golang中github.com/pipeviz/pipeviz/types/system.CoreGraph类的典型用法代码示例。如果您正苦于以下问题:Golang CoreGraph类的具体用法?Golang CoreGraph怎么用?Golang CoreGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CoreGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Resolve
func (spec specLocalLogic) Resolve(g system.CoreGraph, mid uint64, src system.VertexTuple) (e system.StdEdge, success bool) {
e = system.StdEdge{
Source: src.ID,
Props: ps.NewMap(),
EType: "logic-link",
}
// search for existing link
re := g.OutWith(src.ID, q.Qbe(system.EType("logic-link"), "path", spec.Path))
if len(re) == 1 {
// TODO don't set the path prop again, it's the unique id...meh, same question here w/uniqueness as above
success = true
e = re[0]
return
}
// no existing link found, search for proc directly
envid, _, _ := findEnv(g, src)
rv := g.PredecessorsWith(envid, q.Qbv(system.VType("logic-state"), "path", spec.Path))
if len(rv) == 1 {
success = true
e.Target = rv[0].ID
}
return
}
示例2: Resolve
func (spec EnvLink) Resolve(g system.CoreGraph, mid uint64, src system.VertexTuple) (e system.StdEdge, success bool) {
_, e, success = findEnv(g, src)
// Whether we find a match or not, have to merge in the EnvLink
e.Props = maputil.FillPropMap(mid, false,
pp("hostname", spec.Address.Hostname),
pp("ipv4", spec.Address.Ipv4),
pp("ipv6", spec.Address.Ipv6),
pp("nick", spec.Nick),
)
// If we already found the matching edge, bail out now
if success {
return
}
rv := g.VerticesWith(q.Qbv(system.VType("environment")))
for _, vt := range rv {
// TODO this'll be cross-package eventually - reorg needed
if maputil.AnyMatch(e.Props, vt.Vertex.Properties, "nick", "hostname", "ipv4", "ipv6") {
success = true
e.Target = vt.ID
break
}
}
return
}
示例3: Resolve
func (spec specGitCommitParent) Resolve(g system.CoreGraph, mid uint64, src system.VertexTuple) (e system.StdEdge, success bool) {
e = system.StdEdge{
Source: src.ID,
Props: ps.NewMap(),
EType: "parent-commit",
}
re := g.OutWith(src.ID, q.Qbe(system.EType("parent-commit"), "pnum", spec.ParentNum))
if len(re) > 0 {
success = true
e.Target = re[0].Target
e.Props = re[0].Props
// FIXME evidence of a problem here - since we're using pnum as the deduping identifier, there's no
// way it could also sensibly change its MsgSrc value. This is very much a product of the intensional/extensional
// identity problem: what does it mean to have the identifying data change? is it now a new thing? was it the old thing,
// and it underwent a transition into the new thing? or is there no distinction between the old and new thing?
e.Props = e.Props.Set("sha1", system.Property{MsgSrc: mid, Value: spec.Sha1})
e.ID = re[0].ID
} else {
rv := g.VerticesWith(q.Qbv(system.VType("commit"), "sha1", spec.Sha1))
if len(rv) == 1 {
success = true
e.Target = rv[0].ID
e.Props = e.Props.Set("pnum", system.Property{MsgSrc: mid, Value: spec.ParentNum})
e.Props = e.Props.Set("sha1", system.Property{MsgSrc: mid, Value: spec.Sha1})
}
}
return
}
示例4: BenchmarkMergeMessageOneAndTwo
func BenchmarkMergeMessageOneAndTwo(b *testing.B) {
var g system.CoreGraph = &coreGraph{vtuples: ps.NewMap()}
for i := 0; i < b.N; i++ {
g.Merge(0, msgs[0].UnificationForm())
g.Merge(0, msgs[1].UnificationForm())
}
}
示例5: commitUnify
func commitUnify(g system.CoreGraph, u system.UnifyInstructionForm) uint64 {
candidates := g.VerticesWith(q.Qbv(system.VType("commit"), "sha1", u.Vertex().Properties()["sha1"]))
if len(candidates) > 0 { // there can be only one
return candidates[0].ID
}
return 0
}
示例6: parentDatasetUnify
func parentDatasetUnify(g system.CoreGraph, u system.UnifyInstructionForm) uint64 {
edge, success := u.ScopingSpecs()[0].(EnvLink).Resolve(g, 0, emptyVT(u.Vertex()))
if !success {
// FIXME scoping edge resolution failure does not mean no match - there could be an orphan
return 0
}
props := u.Vertex().Properties()
return findMatchingEnvId(g, edge, g.VerticesWith(q.Qbv(system.VType("parent-dataset"), "path", props["path"], "name", props["name"])))
}
示例7: processUnify
func processUnify(g system.CoreGraph, u system.UnifyInstructionForm) uint64 {
// only one scoping edge - the envlink
edge, success := u.ScopingSpecs()[0].(EnvLink).Resolve(g, 0, emptyVT(u.Vertex()))
if !success {
// FIXME scoping edge resolution failure does not mean no match - there could be an orphan
return 0
}
return findMatchingEnvId(g, edge, g.VerticesWith(q.Qbv(system.VType("process"), "pid", u.Vertex().Properties()["pid"])))
}
示例8: findEnvironment
func findEnvironment(g system.CoreGraph, props ps.Map) (envid uint64, success bool) {
rv := g.VerticesWith(q.Qbv(system.VType("environment")))
for _, vt := range rv {
if maputil.AnyMatch(props, vt.Vertex.Props(), "hostname", "ipv4", "ipv6", "nick") {
return vt.ID, true
}
}
return
}
示例9: envUnify
func envUnify(g system.CoreGraph, u system.UnifyInstructionForm) uint64 {
matches := g.VerticesWith(q.Qbv(system.VType("environment")))
for _, e := range matches {
if maputil.AnyMatch(e.Vertex.Properties, u.Vertex().Properties(), "hostname", "ipv4", "ipv6") {
return e.ID
}
}
return 0
}
示例10: findMatchingEnvId
func findMatchingEnvId(g system.CoreGraph, edge system.StdEdge, vtv system.VertexTupleVector) uint64 {
for _, candidate := range vtv {
for _, edge2 := range g.OutWith(candidate.ID, q.Qbe(system.EType("envlink"))) {
if edge2.Target == edge.Target {
return candidate.ID
}
}
}
return 0
}
示例11: pkgYumUnify
func pkgYumUnify(g system.CoreGraph, u system.UnifyInstructionForm) uint64 {
props := u.Vertex().Properties()
vtv := g.VerticesWith(q.Qbv(system.VType("pkg-yum"),
"name", props["name"],
"version", props["version"],
"arch", props["arch"],
"epoch", props["epoch"],
))
if len(vtv) > 0 {
return vtv[0].ID
}
return 0
}
示例12: graphToJSON
func graphToJSON(g system.CoreGraph) ([]byte, error) {
var vertices []interface{}
for _, v := range g.VerticesWith(q.Qbv(system.VTypeNone)) {
vertices = append(vertices, v.Flat())
}
// TODO use something that lets us write to a reusable byte buffer instead
return json.Marshal(struct {
Id uint64 `json:"id"`
Vertices []interface{} `json:"vertices"`
}{
Id: g.MsgID(),
Vertices: vertices,
})
}
示例13: findEnv
// Searches the given vertex's out-edges to find its environment's vertex id.
//
// Also conveniently initializes a StandardEdge to the standard zero-state for an envlink.
func findEnv(g system.CoreGraph, vt system.VertexTuple) (vid uint64, edge system.StdEdge, success bool) {
edge = system.StdEdge{
Source: vt.ID,
Props: ps.NewMap(),
EType: "envlink",
}
if vt.ID != 0 {
re := g.OutWith(vt.ID, q.Qbe(system.EType("envlink")))
if len(re) == 1 {
vid, edge, success = re[0].Target, re[0], true
}
}
return
}
示例14: Resolve
func (spec DataAlpha) Resolve(g system.CoreGraph, mid uint64, src system.VertexTuple) (e system.StdEdge, success bool) {
// TODO this makes a loop...are we cool with that?
success = true // impossible to fail here
e = system.StdEdge{
Source: src.ID,
Target: src.ID,
Props: ps.NewMap(),
EType: "data-provenance",
}
re := g.OutWith(src.ID, q.Qbe(system.EType("data-provenance")))
if len(re) == 1 {
e = re[0]
}
return
}
示例15: datasetUnify
func datasetUnify(g system.CoreGraph, u system.UnifyInstructionForm) uint64 {
vtv := g.VerticesWith(q.Qbv(system.VType("dataset"), "name", u.Vertex().Properties()["name"]))
if len(vtv) == 0 {
return 0
}
spec := u.ScopingSpecs()[0].(specDatasetHierarchy)
el, success := spec.Environment.Resolve(g, 0, emptyVT(u.Vertex()))
// FIXME scoping edge resolution failure does not mean no match - there could be an orphan
if success {
for _, vt := range vtv {
if id := findMatchingEnvId(g, el, g.SuccessorsWith(vt.ID, q.Qbe(system.EType("dataset-hierarchy")))); id != 0 {
return vt.ID
}
}
}
return 0
}