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

Search worker unification - removing duplicated ones #141

Merged
merged 19 commits into from
May 19, 2024

Conversation

pdelewski
Copy link
Contributor

@pdelewski pdelewski commented May 17, 2024

This PR combines searchAggregationWorker with searchWorker and searchAggregationWorkerCommon with searchWorkerCommon

@pdelewski pdelewski changed the title Return explicitly Search worker unification continuation May 17, 2024
@pdelewski pdelewski force-pushed the unify-searchworker-2 branch 9 times, most recently from a5992af to f7ff7ad Compare May 17, 2024 14:26
@pdelewski pdelewski force-pushed the unify-searchworker-2 branch from 006a631 to 1dae47e Compare May 17, 2024 14:47
@pdelewski pdelewski changed the title Search worker unification continuation Search worker unification - removing one of them May 17, 2024
@@ -232,28 +232,40 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin
}
oldHandlingUsed = true
fullQuery, columns := q.makeBasicQuery(ctx, queryTranslator, table, simpleQuery, queryInfo, highlighter)
var columnsSlice [][]string
if optAsync != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch and the one that starts in line 258 will be combined next time

@pdelewski pdelewski changed the title Search worker unification - removing one of them Search worker unification - removing duplicated ones May 17, 2024
@pdelewski pdelewski marked this pull request as ready for review May 17, 2024 15:25
@pdelewski pdelewski requested a review from a team as a code owner May 17, 2024 15:25
@pdelewski pdelewski requested review from nablaone, jakozaur, mieciu, pivovarit and trzysiek and removed request for a team May 17, 2024 15:25
Copy link
Contributor

@jakozaur jakozaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, got minor comments.

optAsync.doneCh <- AsyncSearchWithError{translatedQueryBody: translatedQueryBody, err: err}
return
}
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody, err: nil}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would omit empty nil struct fields as we do above.

Suggested change
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody, err: nil}
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody}

q.searchAggregationWorker(ctx, aggregations, columns, queryTranslator, table, optAsync)
translatedQueryBody, aggregationResults = q.searchWorker(ctx, aggregations, columns, table, true, optAsync)
searchResponse := queryTranslator.MakeResponseAggregation(aggregations, aggregationResults)
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody, err: nil}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above:

Suggested change
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody, err: nil}
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody}

}
rows, err := q.logManager.ProcessQuery(dbQueryCtx, table, &agg, nil)
rows, err := q.logManager.ProcessQuery(dbQueryCtx, table, &query, columns[columnsIndex])
if err != nil {
logger.ErrorWithCtx(ctx).Msg(err.Error())
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why here we are not incrementing columnsIndex. Looks like a bug.

if agg.NoDBQuery {
logger.InfoWithCtx(ctx).Msgf("pipeline query: %+v", agg)
columnsIndex := 0
for _, query := range queries {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this fixes a bug and also you can simplify code:

Suggested change
for _, query := range queries {
for columnsIndex, query := range queries {

hits = append(hits, postprocessedRows)
} else {
hits = append(hits, rows)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woulnd't it be simpler if we:

if doPostProcessing {
  rows = query.Type.PostprocessResults(rows)
}
hits = append(hits, rows)

@jakozaur jakozaur enabled auto-merge (squash) May 19, 2024 17:32
@jakozaur jakozaur merged commit 218f0c1 into main May 19, 2024
4 checks passed
@jakozaur jakozaur deleted the unify-searchworker-2 branch May 19, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants