func minimalIndexes(sargables map[datastore.Index]*indexEntry, pred expression.Expression) ( map[datastore.Index]*indexEntry, error) { for s, se := range sargables { for t, te := range sargables { if t == s { continue } if narrowerOrEquivalent(se, te) { delete(sargables, t) } } } minimals := make(map[datastore.Index]*indexEntry, len(sargables)) for s, se := range sargables { spans, err := SargFor(pred, se.sargKeys, len(se.keys)) if err != nil || len(spans) == 0 { logging.Errorp("Sargable index not sarged", logging.Pair{"pred", pred}, logging.Pair{"sarg_keys", se.sargKeys}, logging.Pair{"error", err}) return nil, errors.NewPlanError(nil, fmt.Sprintf("Sargable index not sarged; pred=%v, sarg_keys=%v, error=%v", pred.String(), se.sargKeys.String(), err)) return nil, err } se.spans = spans minimals[s] = se } return minimals, nil }
/* Create a key value pair using the operands of the input expression Array construct and return. */ func NewPair(expr expression.Expression) (*Pair, error) { array, ok := expr.(*expression.ArrayConstruct) if !ok { return nil, fmt.Errorf("Invalid VALUES expression %s", expr.String()) } operands := array.Operands() if len(operands) != 2 { return nil, fmt.Errorf("Invalid VALUES expression %s", expr.String()) } pair := &Pair{ Key: operands[0], Value: operands[1], } return pair, nil }