本文整理汇总了Golang中github.com/google/badwolf/triple/predicate.Predicate类的典型用法代码示例。如果您正苦于以下问题:Golang Predicate类的具体用法?Golang Predicate怎么用?Golang Predicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Predicate类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: processPredicate
// processPredicate updates the working graph clause if there is an available
// predicate.
func processPredicate(c *GraphClause, ce ConsumedElement, lastNopToken *lexer.Token) (*predicate.Predicate, string, string, bool, error) {
var (
nP *predicate.Predicate
pID string
pAnchorBinding string
temporal bool
)
raw := ce.Token().Text
p, err := predicate.Parse(raw)
if err == nil {
// A fully specified predicate was provided.
nP = p
return nP, pID, pAnchorBinding, nP.Type() == predicate.Temporal, nil
}
// The predicate may have a binding on the anchor.
cmps := predicateRegexp.FindAllStringSubmatch(raw, 2)
if len(cmps) != 1 || (len(cmps) == 1 && len(cmps[0]) != 3) {
return nil, "", "", false, fmt.Errorf("failed to extract partialy defined predicate %q, got %v instead", raw, cmps)
}
id, ta := cmps[0][1], cmps[0][2]
pID = id
if ta != "" {
pAnchorBinding = ta
temporal = true
}
return nil, pID, pAnchorBinding, temporal, nil
}
开发者ID:google,项目名称:badwolf,代码行数:29,代码来源:hooks.go
示例2: TriplesForPredicate
// TriplesForPredicate returns all triples available for the given predicate.
func (m *memory) TriplesForPredicate(p *predicate.Predicate, lo *storage.LookupOptions) (storage.Triples, error) {
pGUID := p.GUID()
m.rwmu.RLock()
triples := make(chan *triple.Triple, len(m.idxP[pGUID]))
go func() {
ckr := newChecker(lo)
for _, t := range m.idxP[pGUID] {
if ckr.CheckAndUpdate(t.Predicate()) {
triples <- t
}
}
m.rwmu.RUnlock()
close(triples)
}()
return triples, nil
}
开发者ID:defrager,项目名称:badwolf,代码行数:17,代码来源:memory.go
示例3: TriplesForPredicateAndObject
// TriplesForPredicateAndObject returns all triples available for the given
// predicate and object.
func (m *memory) TriplesForPredicateAndObject(p *predicate.Predicate, o *triple.Object, lo *storage.LookupOptions) (storage.Triples, error) {
pGUID := p.GUID()
oGUID := o.GUID()
poIdx := strings.Join([]string{pGUID, oGUID}, ":")
m.rwmu.RLock()
triples := make(chan *triple.Triple, len(m.idxPO[poIdx]))
go func() {
ckr := newChecker(lo)
for _, t := range m.idxPO[poIdx] {
if ckr.CheckAndUpdate(t.P()) {
triples <- t
}
}
m.rwmu.RUnlock()
close(triples)
}()
return triples, nil
}
开发者ID:rtu,项目名称:badwolf,代码行数:20,代码来源: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: Subjects
// Subject returns the subjects for the give predicate and object.
func (m *memory) Subjects(p *predicate.Predicate, o *triple.Object, lo *storage.LookupOptions) (storage.Nodes, error) {
pGUID := p.GUID()
oGUID := o.GUID()
poIdx := strings.Join([]string{pGUID, oGUID}, ":")
m.rwmu.RLock()
subs := make(chan *node.Node, len(m.idxPO[poIdx]))
go func() {
ckr := newChecker(lo)
for _, t := range m.idxPO[poIdx] {
if ckr.CheckAndUpdate(t.P()) {
subs <- t.S()
}
}
m.rwmu.RUnlock()
close(subs)
}()
return subs, nil
}
开发者ID:rtu,项目名称:badwolf,代码行数:19,代码来源: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
示例7: CheckAndUpdate
// CheckAndUpdate checks if a predicate should be considered and it also updates
// the internal state in case counts are needed.
func (c *checker) CheckAndUpdate(p *predicate.Predicate) bool {
if c.max {
if c.c <= 0 {
return false
}
c.c--
}
if p.Type() == predicate.Immutable {
return true
}
t, _ := p.TimeAnchor()
if c.o.LowerAnchor != nil && t.Before(*c.o.LowerAnchor) {
return false
}
if c.o.UpperAnchor != nil && t.After(*c.o.UpperAnchor) {
return false
}
return true
}
开发者ID:rtu,项目名称:badwolf,代码行数:21,代码来源:memory.go
注:本文中的github.com/google/badwolf/triple/predicate.Predicate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论