本文整理汇总了Golang中github.com/google/badwolf/bql/semantic.GraphClause.Specificity方法的典型用法代码示例。如果您正苦于以下问题:Golang GraphClause.Specificity方法的具体用法?Golang GraphClause.Specificity怎么用?Golang GraphClause.Specificity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/google/badwolf/bql/semantic.GraphClause
的用法示例。
在下文中一共展示了GraphClause.Specificity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: processClause
// processClause retrieves the triples for the provided triple given the
// information available.
func (p *queryPlan) processClause(ctx context.Context, cls *semantic.GraphClause, lo *storage.LookupOptions) (bool, error) {
// This method decides how to process the clause based on the current
// list of bindings solved and data available.
if cls.Specificity() == 3 {
t, err := triple.New(cls.S, cls.P, cls.O)
if err != nil {
return false, err
}
b, tbl, err := simpleExist(ctx, p.grfs, cls, t)
if err != nil {
return false, err
}
if err := p.tbl.AppendTable(tbl); err != nil {
return b, err
}
return b, nil
}
exist, total := 0, 0
for _, b := range cls.Bindings() {
total++
if p.tbl.HasBinding(b) {
exist++
}
}
if exist == 0 {
// Data is new.
tbl, err := simpleFetch(ctx, p.grfs, cls, lo, p.chanSize)
if err != nil {
return false, err
}
if len(p.tbl.Bindings()) > 0 {
return false, p.tbl.DotProduct(tbl)
}
return false, p.tbl.AppendTable(tbl)
}
if exist > 0 && exist < total {
// Data is partially bound, retrieve data either extends the row with the
// new bindings or filters it out if now new bindings are available.
return false, p.specifyClauseWithTable(ctx, cls, lo)
}
if exist > 0 && exist == total {
// Since all bindings in the clause are already solved, the clause becomes a
// fully specified triple. If the triple does not exist the row will be
// deleted.
return false, p.filterOnExistence(ctx, cls, lo)
}
// Something is wrong with the code.
return false, fmt.Errorf("queryPlan.processClause(%v) should have never failed to resolve the clause", cls)
}