本文整理汇总了Golang中github.com/janelia-flyem/dvid/storage.GraphDB.RemoveEdgeProperty方法的典型用法代码示例。如果您正苦于以下问题:Golang GraphDB.RemoveEdgeProperty方法的具体用法?Golang GraphDB.RemoveEdgeProperty怎么用?Golang GraphDB.RemoveEdgeProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/janelia-flyem/dvid/storage.GraphDB
的用法示例。
在下文中一共展示了GraphDB.RemoveEdgeProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleProperty
// handleProperty retrieves or deletes properties that can be added to a vertex or edge -- data posted
// or retrieved uses default compression
func (d *Data) handleProperty(ctx *datastore.VersionedCtx, db storage.GraphDB, w http.ResponseWriter, r *http.Request, path []string, method string) error {
edgemode := false
var propertyname string
if len(path) == 3 {
edgemode = true
propertyname = path[2]
} else if len(path) != 2 {
return fmt.Errorf("Incorrect number of parameters specified for handling properties")
} else {
propertyname = path[1]
}
temp, err := strconv.Atoi(path[0])
if err != nil {
return fmt.Errorf("Vertex number not provided")
}
id1 := dvid.VertexID(temp)
id2 := dvid.VertexID(0)
if edgemode {
temp, err := strconv.Atoi(path[1])
if err != nil {
return fmt.Errorf("Vertex number not provided")
}
id2 = dvid.VertexID(temp)
}
// remove a property from a vertex or edge
if method == "delete" {
if edgemode {
db.RemoveEdgeProperty(ctx, id1, id2, propertyname)
if err != nil {
return fmt.Errorf("Failed to remove edge property %d-%d %s: %v\n", id1, id2, propertyname, err)
}
} else {
db.RemoveVertexProperty(ctx, id1, propertyname)
if err != nil {
return fmt.Errorf("Failed to remove vertex property %d %s: %v\n", id1, propertyname, err)
}
}
} else if method == "get" {
var data []byte
if edgemode {
data, err = db.GetEdgeProperty(ctx, id1, id2, propertyname)
} else {
data, err = db.GetVertexProperty(ctx, id1, propertyname)
}
if err != nil {
return fmt.Errorf("Failed to get property %s: %v\n", propertyname, err)
}
uncompress := true
value, _, e := dvid.DeserializeData(data, uncompress)
if e != nil {
err = fmt.Errorf("Unable to deserialize data for property '%s': %v\n", propertyname, e.Error())
return err
}
w.Header().Set("Content-Type", "application/octet-stream")
_, err = w.Write(value)
if err != nil {
return err
}
} else if method == "post" {
// read as binary and load into propertyname
data, err := ioutil.ReadAll(r.Body)
if err != nil {
return err
}
serialization, err := dvid.SerializeData(data, d.Compression(), d.Checksum())
if err != nil {
return fmt.Errorf("Unable to serialize data: %v\n", err)
}
if edgemode {
err = db.SetEdgeProperty(ctx, id1, id2, propertyname, serialization)
} else {
err = db.SetVertexProperty(ctx, id1, propertyname, serialization)
}
if err != nil {
return fmt.Errorf("Failed to add property %s: %v\n", propertyname, err)
}
}
return err
}