本文整理汇总了Golang中github.com/google/badwolf/triple/node.Node类的典型用法代码示例。如果您正苦于以下问题:Golang Node类的具体用法?Golang Node怎么用?Golang Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: recurse
// recurse generated the triple by recursing while there are still triples
// left to generate.
func (t *treeGenerator) recurse(parent *node.Node, left *int, currentDepth, maxDepth int, trpls []*triple.Triple) ([]*triple.Triple, error) {
if *left < 1 {
return trpls, nil
}
for i, last := 0, *left <= t.branch; i < t.branch; i++ {
offspring, err := t.newNode(i, parent.ID().String())
if err != nil {
return trpls, err
}
trpl, err := t.newTriple(parent, offspring)
if err != nil {
return trpls, err
}
trpls = append(trpls, trpl)
(*left)--
if *left < 1 {
break
}
if currentDepth < maxDepth && !last {
ntrpls, err := t.recurse(offspring, left, currentDepth+1, maxDepth, trpls)
if err != nil {
return ntrpls, err
}
trpls = ntrpls
}
if *left < 1 {
break
}
}
return trpls, nil
}
开发者ID:google,项目名称:badwolf,代码行数:33,代码来源:tree.go
示例2: TriplesForSubject
// TriplesForSubject returns all triples available for a given subect.
func (m *memory) TriplesForSubject(s *node.Node, lo *storage.LookupOptions) (storage.Triples, error) {
sGUID := s.GUID()
m.rwmu.RLock()
triples := make(chan *triple.Triple, len(m.idxS[sGUID]))
go func() {
ckr := newChecker(lo)
for _, t := range m.idxS[sGUID] {
if ckr.CheckAndUpdate(t.P()) {
triples <- t
}
}
m.rwmu.RUnlock()
close(triples)
}()
return triples, nil
}
开发者ID:rtu,项目名称:badwolf,代码行数:17,代码来源:memory.go
示例3: PredicatesForSubject
// PredicatesForSubject returns all the predicats know for the given
// subject.
func (m *memory) PredicatesForSubject(s *node.Node, lo *storage.LookupOptions) (storage.Predicates, error) {
sGUID := s.GUID()
m.rwmu.RLock()
preds := make(chan *predicate.Predicate, len(m.idxS[sGUID]))
go func() {
ckr := newChecker(lo)
for _, t := range m.idxS[sGUID] {
if ckr.CheckAndUpdate(t.P()) {
preds <- t.P()
}
}
m.rwmu.RUnlock()
close(preds)
}()
return preds, nil
}
开发者ID:rtu,项目名称:badwolf,代码行数:18,代码来源:memory.go
示例4: TriplesForSubjectAndPredicate
// TriplesForSubjectAndPredicate returns all triples available for the given
// subject and predicate.
func (m *memory) TriplesForSubjectAndPredicate(s *node.Node, p *predicate.Predicate, lo *storage.LookupOptions) (storage.Triples, error) {
sGUID := s.GUID()
pGUID := p.GUID()
spIdx := strings.Join([]string{sGUID, pGUID}, ":")
m.rwmu.RLock()
triples := make(chan *triple.Triple, len(m.idxSP[spIdx]))
go func() {
ckr := newChecker(lo)
for _, t := range m.idxSP[spIdx] {
if ckr.CheckAndUpdate(t.P()) {
triples <- t
}
}
m.rwmu.RUnlock()
close(triples)
}()
return triples, nil
}
开发者ID:rtu,项目名称:badwolf,代码行数:20,代码来源:memory.go
示例5: PredicatesForSubjectAndObject
// PredicatesForSubjecAndObject returns all predicates available for the
// given subject and object.
func (m *memory) PredicatesForSubjectAndObject(s *node.Node, o *triple.Object, lo *storage.LookupOptions) (storage.Predicates, error) {
sGUID := s.GUID()
oGUID := o.GUID()
soIdx := strings.Join([]string{sGUID, oGUID}, ":")
m.rwmu.RLock()
preds := make(chan *predicate.Predicate, len(m.idxSO[soIdx]))
go func() {
ckr := newChecker(lo)
for _, t := range m.idxSO[soIdx] {
if ckr.CheckAndUpdate(t.P()) {
preds <- t.P()
}
}
m.rwmu.RUnlock()
close(preds)
}()
return preds, nil
}
开发者ID:rtu,项目名称:badwolf,代码行数:20,代码来源:memory.go
示例6: Objects
// Objects returns the objects for the give object and predicate.
func (m *memory) Objects(ctx context.Context, s *node.Node, p *predicate.Predicate, lo *storage.LookupOptions) (storage.Objects, error) {
sGUID := s.GUID()
pGUID := p.GUID()
spIdx := strings.Join([]string{sGUID, pGUID}, ":")
m.rwmu.RLock()
objs := make(chan *triple.Object, len(m.idxSP[spIdx]))
go func() {
ckr := newChecker(lo)
for _, t := range m.idxSP[spIdx] {
if ckr.CheckAndUpdate(t.Predicate()) {
objs <- t.Object()
}
}
m.rwmu.RUnlock()
close(objs)
}()
return objs, nil
}
开发者ID:msingle,项目名称:badwolf,代码行数:19,代码来源:memory.go
注:本文中的github.com/google/badwolf/triple/node.Node类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论