本文整理匯總了Golang中github.com/redhat-cip/skydive/topology/graph/gremlin.GremlinPropertiesEncoder類的典型用法代碼示例。如果您正苦於以下問題:Golang GremlinPropertiesEncoder類的具體用法?Golang GremlinPropertiesEncoder怎麽用?Golang GremlinPropertiesEncoder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了GremlinPropertiesEncoder類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetMetadata
func (g GremlinBackend) SetMetadata(i interface{}, k string, v interface{}) bool {
var e graphElement
var elType string
switch i.(type) {
case *Node:
e = i.(*Node).graphElement
elType = "V"
case *Edge:
e = i.(*Edge).graphElement
elType = "V"
}
properties, err := idToPropertiesString(e.ID)
if err != nil {
logging.GetLogger().Error("Error while retrieving a Node: %s", err.Error())
return false
}
encoder := gremlin.GremlinPropertiesEncoder{}
encoder.EncodeKVPair(k, v)
query := "g." + elType + "().has(" + properties + ").property(" + encoder.String() + ")"
_, err = g.client.Query(query)
if err != nil {
logging.GetLogger().Error("Gremlin query error: %s, %s", query, err.Error())
return false
}
return true
}
示例2: idToPropertiesString
func idToPropertiesString(i Identifier) (string, error) {
properties := map[string]interface{}{
"_ID": string(i),
}
encoder := gremlin.GremlinPropertiesEncoder{}
err := encoder.Encode(properties)
if err != nil {
logging.GetLogger().Error("Error while retrieving a Node: %s", err.Error())
return "", err
}
return encoder.String(), nil
}
示例3: toPropertiesString
func toPropertiesString(e graphElement) ([]byte, error) {
properties := map[string]interface{}{
"_ID": string(e.ID),
}
for k, v := range e.metadatas {
if k == "_ID" {
return nil, errors.New("_ID is a reserved value, can not be overridden by metadata")
}
properties[k] = v
}
encoder := gremlin.GremlinPropertiesEncoder{}
err := encoder.Encode(properties)
return encoder.Bytes(), err
}
示例4: toPropertiesString
func toPropertiesString(e graphElement) ([]byte, error) {
properties := map[string]interface{}{
"_ID": string(e.ID),
"_host": e.host,
}
for k, v := range e.metadata {
if k[0] == '_' {
return nil, errors.New("Properties starting with _ are reserved")
}
properties[k] = v
}
encoder := gremlin.GremlinPropertiesEncoder{}
err := encoder.Encode(properties)
return encoder.Bytes(), err
}