当前位置: 首页>>代码示例>>Golang>>正文


Golang GraphClause.Specificity方法代码示例

本文整理汇总了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)
}
开发者ID:google,项目名称:badwolf,代码行数:51,代码来源:planner.go


注:本文中的github.com/google/badwolf/bql/semantic.GraphClause.Specificity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。