Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shards: log typeRepo sub-expression evaluation #865

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions shards/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *typeRepoSearcher) Search(ctx context.Context, q query.Q, opts *zoekt.Se
tr.Finish()
}()

q, err = s.eval(ctx, q)
q, err = s.eval(ctx, tr, q)
if err != nil {
return nil, err
}
Expand All @@ -60,7 +60,7 @@ func (s *typeRepoSearcher) StreamSearch(ctx context.Context, q query.Q, opts *zo
tr.Finish()
}()

q, err = s.eval(ctx, q)
q, err = s.eval(ctx, tr, q)
if err != nil {
return err
}
Expand Down Expand Up @@ -92,15 +92,15 @@ func (s *typeRepoSearcher) List(ctx context.Context, q query.Q, opts *zoekt.List
tr.Finish()
}()

q, err = s.eval(ctx, q)
q, err = s.eval(ctx, tr, q)
if err != nil {
return nil, err
}

return s.Streamer.List(ctx, q, opts)
}

func (s *typeRepoSearcher) eval(ctx context.Context, q query.Q) (query.Q, error) {
func (s *typeRepoSearcher) eval(ctx context.Context, tr *trace.Trace, q query.Q) (query.Q, error) {
var err error
q = query.Map(q, func(q query.Q) query.Q {
if err != nil {
Expand All @@ -112,6 +112,8 @@ func (s *typeRepoSearcher) eval(ctx context.Context, q query.Q) (query.Q, error)
return q
}

tr.LazyPrintf("evaluating sub-expression %s", rq)

var rl *zoekt.RepoList
rl, err = s.Streamer.List(ctx, rq.Child, nil)
if err != nil {
Expand All @@ -122,6 +124,9 @@ func (s *typeRepoSearcher) eval(ctx context.Context, q query.Q) (query.Q, error)
for _, r := range rl.Repos {
rs.Set[r.Repository.Name] = true
}

tr.LazyPrintf("replaced sub-expression with %s", rs)

return rs
})
return q, err
Expand Down
Loading