本文整理汇总了Golang中github.com/google/badwolf/triple.Triple类的典型用法代码示例。如果您正苦于以下问题:Golang Triple类的具体用法?Golang Triple怎么用?Golang Triple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Triple类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Exist
// Exists checks if the provided triple exist on the store.
func (m *memory) Exist(t *triple.Triple) (bool, error) {
guid := t.GUID()
m.rwmu.RLock()
_, ok := m.idx[guid]
m.rwmu.RUnlock()
return ok, nil
}
开发者ID:rtu,项目名称:badwolf,代码行数:8,代码来源:memory.go
示例2: 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
}
}
//.........这里部分代码省略.........
开发者ID:defrager,项目名称:badwolf,代码行数:101,代码来源:data_access.go
示例3: 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.S(), t.P(), t.O()
// Subject related bindings.
if cls.SBinding != "" {
r[cls.SBinding] = &table.Cell{N: s}
}
if cls.SAlias != "" {
r[cls.SAlias] = &table.Cell{N: s}
}
if cls.STypeAlias != "" {
r[cls.STypeAlias] = &table.Cell{S: s.Type().String()}
}
if cls.SIDAlias != "" {
r[cls.SIDAlias] = &table.Cell{S: s.ID().String()}
}
// Predicate related bindings.
if cls.PBinding != "" {
r[cls.PBinding] = &table.Cell{P: p}
}
if cls.PAlias != "" {
r[cls.PAlias] = &table.Cell{P: p}
}
if cls.PIDAlias != "" {
r[cls.PIDAlias] = &table.Cell{S: string(p.ID())}
}
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)
}
r[cls.PAnchorBinding] = &table.Cell{T: t}
}
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)
}
r[cls.PAnchorAlias] = &table.Cell{T: t}
}
// Object related bindings.
if cls.OBinding != "" {
// Extract the object type.
c, err := objectToCell(o)
if err != nil {
return nil, err
}
r[cls.OBinding] = c
}
if cls.OAlias != "" {
// Extract the object type.
c, err := objectToCell(o)
if err != nil {
return nil, err
}
r[cls.OAlias] = c
}
if cls.OTypeAlias != "" {
n, err := o.Node()
if err != nil {
return nil, err
}
r[cls.OTypeAlias] = &table.Cell{S: n.Type().String()}
}
if cls.OIDAlias != "" {
n, err := o.Node()
if err == nil {
r[cls.OIDAlias] = &table.Cell{S: n.ID().String()}
} else {
p, err := o.Predicate()
if err != nil {
return nil, err
}
r[cls.OIDAlias] = &table.Cell{S: string(p.ID())}
}
}
if cls.OAnchorBinding != "" {
p, err := o.Predicate()
if err != nil {
return nil, err
}
ts, err := p.TimeAnchor()
if err != nil {
return nil, err
}
r[cls.OAnchorBinding] = &table.Cell{T: ts}
}
if cls.OAnchorAlias != "" {
p, err := o.Predicate()
//.........这里部分代码省略.........
开发者ID:rossdakin,项目名称:badwolf,代码行数:101,代码来源:data_access.go
注:本文中的github.com/google/badwolf/triple.Triple类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论