// 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) }