本文整理汇总了Golang中github.com/google/badwolf/triple.Triple.Predicate方法的典型用法代码示例。如果您正苦于以下问题:Golang Triple.Predicate方法的具体用法?Golang Triple.Predicate怎么用?Golang Triple.Predicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/google/badwolf/triple.Triple
的用法示例。
在下文中一共展示了Triple.Predicate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: tripleToRow
// tripleToRow converts a triple into a row using the binndings specidfied
// on the graph clause.
func tripleToRow(t *triple.Triple, cls *semantic.GraphClause) (table.Row, error) {
r, s, p, o := make(table.Row), t.Subject(), t.Predicate(), t.Object()
// Enforce binding validity inside te clause.
bnd := make(map[string]*table.Cell)
validBinding := func(k string, v *table.Cell) bool {
c, ok := bnd[k]
bnd[k] = v
if !ok {
return true
}
if reflect.DeepEqual(c, v) {
return true
}
return false
}
// Subject related bindings.
if cls.SBinding != "" {
c := &table.Cell{N: s}
r[cls.SBinding] = c
if !validBinding(cls.SBinding, c) {
return nil, nil
}
}
if cls.SAlias != "" {
c := &table.Cell{N: s}
r[cls.SAlias] = c
if !validBinding(cls.SAlias, c) {
return nil, nil
}
}
if cls.STypeAlias != "" {
c := &table.Cell{S: s.Type().String()}
r[cls.STypeAlias] = c
if !validBinding(cls.STypeAlias, c) {
return nil, nil
}
}
if cls.SIDAlias != "" {
c := &table.Cell{S: s.ID().String()}
r[cls.SIDAlias] = c
if !validBinding(cls.SIDAlias, c) {
return nil, nil
}
}
// Predicate related bindings.
if cls.PBinding != "" {
c := &table.Cell{P: p}
r[cls.PBinding] = c
if !validBinding(cls.PBinding, c) {
return nil, nil
}
}
if cls.PAlias != "" {
c := &table.Cell{P: p}
r[cls.PAlias] = c
if !validBinding(cls.PAlias, c) {
return nil, nil
}
}
if cls.PIDAlias != "" {
c := &table.Cell{S: string(p.ID())}
r[cls.PIDAlias] = c
if !validBinding(cls.PIDAlias, c) {
return nil, nil
}
}
if cls.PAnchorBinding != "" {
if p.Type() != predicate.Temporal {
return nil, fmt.Errorf("cannot retrieve the time anchor value for non temporal predicate %q in binding %q", p, cls.PAnchorBinding)
}
t, err := p.TimeAnchor()
if err != nil {
return nil, fmt.Errorf("failed to retrieve the time anchor value for predicate %q in binding %q with error %v", p, cls.PAnchorBinding, err)
}
c := &table.Cell{T: t}
r[cls.PAnchorBinding] = c
if !validBinding(cls.PAnchorBinding, c) {
return nil, nil
}
}
if cls.PAnchorAlias != "" {
if p.Type() != predicate.Temporal {
return nil, fmt.Errorf("cannot retrieve the time anchor value for non temporal predicate %q in binding %q", p, cls.PAnchorAlias)
}
t, err := p.TimeAnchor()
if err != nil {
return nil, fmt.Errorf("failed to retrieve the time anchor value for predicate %q in binding %q with error %v", p, cls.PAnchorAlias, err)
}
c := &table.Cell{T: t}
r[cls.PAnchorAlias] = c
if !validBinding(cls.PAnchorAlias, c) {
return nil, nil
}
}
//.........这里部分代码省略.........