本文整理汇总了Golang中github.com/pipeviz/pipeviz/types/system.CoreGraph类的典型用法代码示例。如果您正苦于以下问题:Golang CoreGraph类的具体用法?Golang CoreGraph怎么用?Golang CoreGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CoreGraph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:26,代码来源:process.go
示例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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:28,代码来源:environment.go
示例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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:30,代码来源:commit.go
示例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())
}
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:8,代码来源:graph_test.go
示例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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:9,代码来源:commit.go
示例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"])))
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:10,代码来源:dataset.go
示例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"])))
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:10,代码来源:process.go
示例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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:10,代码来源:util.go
示例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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:11,代码来源:environment.go
示例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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:11,代码来源:util.go
示例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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:14,代码来源:pkg_yum.go
示例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,
})
}
开发者ID:eliza411,项目名称:pipeviz-1,代码行数:15,代码来源:server.go
示例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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:19,代码来源:util.go
示例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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:17,代码来源:dataset.go
示例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
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:19,代码来源:dataset.go
示例16: findDataset
func findDataset(g system.CoreGraph, envid uint64, name []string) (id uint64, success bool) {
// first time through use the parent type
vtype := system.VType("parent-dataset")
id = envid
var n string
for len(name) > 0 {
n, name = name[0], name[1:]
rv := g.PredecessorsWith(id, q.Qbv(vtype, "name", n))
vtype = "dataset"
if len(rv) != 1 {
return 0, false
}
id = rv[0].ID
}
return id, true
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:20,代码来源:util.go
示例17: Resolve
func (spec specCommit) Resolve(g system.CoreGraph, mid uint64, src system.VertexTuple) (e system.StdEdge, success bool) {
e = system.StdEdge{
Source: src.ID,
Props: ps.NewMap(),
EType: "version",
}
e.Props = e.Props.Set("sha1", system.Property{MsgSrc: mid, Value: spec.Sha1})
re := g.OutWith(src.ID, q.Qbe(system.EType("version")))
if len(re) > 0 {
sha1, _ := re[0].Props.Lookup("sha1")
e.ID = re[0].ID // FIXME setting the id to non-0 AND failing is currently unhandled
if sha1.(system.Property).Value == spec.Sha1 {
success = true
e.Target = re[0].Target
} else {
rv := g.VerticesWith(q.Qbv(system.VType("commit"), "sha1", spec.Sha1))
if len(rv) == 1 {
success = true
e.Target = rv[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
}
}
return
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:32,代码来源:logic_state.go
示例18: commUnify
func commUnify(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
}
vp := u.Vertex().Properties()
typ, _ := vp["type"]
path, haspath := vp["path"]
if haspath {
return findMatchingEnvId(g, edge, g.VerticesWith(q.Qbv(system.VType("comm"),
"type", typ,
"path", path)))
} else {
port, _ := vp["port"]
return findMatchingEnvId(g, edge, g.VerticesWith(q.Qbv(system.VType("comm"),
"type", typ,
"port", port)))
}
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:22,代码来源:process.go
示例19: init
func init() {
startTime := time.Now().UTC()
expvar.Publish("Uptime", expvar.Func(func() interface{} { return int64(time.Since(startTime)) }))
expvar.Publish("Goroutines", expvar.Func(func() interface{} { return runtime.NumGoroutine() }))
// subscribe to the broker in order to report data about current graph
c := broker.Get().Subscribe()
// Instantiate a real, empty graph to ensure the interface type is never nil when it might be called
var g system.CoreGraph = represent.NewGraph()
go func() {
for latest := range c {
g = latest
}
}()
expvar.Publish("MsgId", expvar.Func(func() interface{} { return g.MsgId() }))
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
}
开发者ID:sdboyer,项目名称:pipeviz,代码行数:22,代码来源:pipeviz_dbg.go
示例20: GenerateDot
// Generates a .dot-format representation of the given CoreGraph, suitable for
// rendering into output by graphviz (or other utilities).
func GenerateDot(g system.CoreGraph) []byte {
buf := new(bytes.Buffer)
// begin the graph
buf.WriteString("digraph{\n")
buf.WriteString("fontsize=16")
// first, write all vertices
for _, v := range g.VerticesWith(q.Qbv()) {
lbltype := "label"
var props string
switch v.Vertex.Typ() {
case "environment":
props = "\tshape=house,style=filled,fillcolor=orange,fontsize=20\n"
case "logic-state":
props = "\tshape=box3d,style=filled,fillcolor=purple,fontcolor=white,fontsize=18,\n"
case "process":
props = "\tshape=oval,style=filled,fillcolor=green,\n"
case "dataset", "parent-dataset":
props = "\tshape=folder,style=filled,fillcolor=brown,fontcolor=white,\n"
case "comm":
props = "\tshape=doubleoctagon,style=filled,fillcolor=cyan,\n"
case "git-commit":
props = "\tshape=box,style=filled,fillcolor=grey\n"
case "git-tag", "git-branch":
props = "\tshape=cds,margin=\"0.22,0.22\",\n"
case "test-result":
props = "\tshape=note\n"
}
buf.WriteString(fmt.Sprintf(
"\t\"v%d\" [%s%s=\"id: %d\nvtype: %s",
v.ID, props, lbltype, v.ID, v.Vertex.Typ()))
v.Vertex.Props().ForEach(func(k string, val ps.Any) {
prop := val.(system.Property)
var format string
switch pv := prop.Value.(type) {
case []byte, [20]byte:
format = "%x"
case int, int64, int32, int16, int8, uint, uint64, uint32, uint16, uint8:
format = "%d"
case string:
prop.Value = strings.Trim(strconv.QuoteToASCII(pv), `"`)
format = "%s"
default:
format = "%s"
}
buf.WriteString(fmt.Sprintf(
"\n%s: "+format+" (%d)",
k, prop.Value, prop.MsgSrc))
})
buf.WriteString("\"\n")
buf.WriteString("];\n")
}
// pass through a second time to write all edges
for _, v := range g.VerticesWith(q.Qbv()) {
v.OutEdges.ForEach(func(k string, val ps.Any) {
edge := val.(system.StdEdge)
buf.WriteString(fmt.Sprintf(
"\t\"v%d\" -> \"v%d\" [\n\tlabel=\"id: %d\netype: %s",
edge.Source, edge.Target, edge.ID, edge.EType))
edge.Props.ForEach(func(k2 string, val2 ps.Any) {
prop := val2.(system.Property)
var format string
switch pv := prop.Value.(type) {
case []byte:
format = "%x"
case int, int64, int32, int16, int8, uint, uint64, uint32, uint16, uint8:
format = "%d"
case string:
prop.Value = strings.Trim(strconv.QuoteToASCII(pv), `"`)
format = "%s"
default:
format = "%s"
}
buf.WriteString(fmt.Sprintf(
"\n%s: "+format+" (%d)",
k2, prop.Value, prop.MsgSrc))
})
buf.WriteString("\"\n")
switch edge.EType {
case "envlink":
buf.WriteString("\tstyle=dashed\n")
}
buf.WriteString("];\n")
})
}
// close out the graph
buf.WriteString("}\n")
//.........这里部分代码省略.........
开发者ID:eliza411,项目名称:pipeviz-1,代码行数:101,代码来源:dotdumper.go
注:本文中的github.com/pipeviz/pipeviz/types/system.CoreGraph类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论