Skip to content

GODRIVER-3902 Move UpdateSearchIndex to the mongo package. - #2500

Open
qingyang-hu wants to merge 3 commits into
mongodb:masterfrom
qingyang-hu:godriver3902
Open

GODRIVER-3902 Move UpdateSearchIndex to the mongo package.#2500
qingyang-hu wants to merge 3 commits into
mongodb:masterfrom
qingyang-hu:godriver3902

Conversation

@qingyang-hu

Copy link
Copy Markdown
Contributor

GODRIVER-3902

Summary

  • Move UpdateSearchIndex from "x/mongo/driver/operation" into the mongo package as an unexported updateSearchIndexOp.
  • All exported setters and the NewUpdateSearchIndex constructor are removed.
  • All unused fluent setters, NewUpdateSearchIndex, and Result() are dropped.

Background & Motivation

@mongodb-drivers-pr-bot

mongodb-drivers-pr-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

🧪 Performance Results

Commit SHA: bfa3ded

The following benchmark tests for version 6a6770cc0d9c2c0007b0ddac had statistically significant changes (i.e., |z-score| > 1.96):

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score
BenchmarkSmallDocInsertOne ops_per_second_min -46.1088 731.6584 Avg: 1357.6589
Med: 1361.0729
Stdev: 284.3332
0.7681 -2.2016
BenchmarkMultiFindMany total_mem_allocs -18.6308 369390.0000 Avg: 453967.6018
Med: 461228.0000
Stdev: 40008.9103
0.7311 -2.1140
BenchmarkMultiFindMany total_bytes_allocated -18.5355 600360608.0000 Avg: 736960153.5928
Med: 749791000.0000
Stdev: 64977806.3778
0.7297 -2.1022
BenchmarkSingleRunCommand ns_per_op 8.1829 144607.0000 Avg: 133669.0238
Med: 132696.0000
Stdev: 4622.5329
0.8037 2.3662
BenchmarkSingleRunCommand ops_per_second_med -7.8180 7244.3295 Avg: 7858.7248
Med: 7909.0461
Stdev: 239.7758
0.8068 -2.5624
BenchmarkLargeDocInsertOne ops_per_second_med -5.8078 5528.7717 Avg: 5869.6680
Med: 5867.8387
Stdev: 139.6163
0.7703 -2.4417
BenchmarkLargeDocInsertOne ns_per_op 5.1043 187090.0000 Avg: 178004.1531
Med: 177319.0000
Stdev: 4459.5289
0.7357 2.0374
BenchmarkBSONFlatDocumentDecoding total_time_seconds -2.0487 1.1746 Avg: 1.1992
Med: 1.1992
Stdev: 0.0067
0.8557 -3.6765

For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch.

@qingyang-hu qingyang-hu added review-priority-normal Medium Priority PR for Review: within 1 business day ignore-for-release labels Jul 22, 2026
@mongodb-drivers-pr-bot

Copy link
Copy Markdown
Contributor

API Change Report

./v2/x/mongo/driver/operation

incompatible changes

NewUpdateSearchIndex: removed
UpdateSearchIndex: removed
UpdateSearchIndexResult: removed

@qingyang-hu
qingyang-hu marked this pull request as ready for review July 23, 2026 15:21
@qingyang-hu
qingyang-hu requested a review from a team as a code owner July 23, 2026 15:21
@qingyang-hu
qingyang-hu requested review from Copilot and matthewdale and removed request for Copilot July 23, 2026 15:21
Copilot AI review requested due to automatic review settings July 27, 2026 14:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the updateSearchIndex operation implementation by moving it out of x/mongo/driver/operation and into the public mongo package as an unexported operation type, simplifying the call site in SearchIndexView.UpdateOne.

Changes:

  • Delete the exported operation.UpdateSearchIndex implementation (and its fluent setters/constructor) from x/mongo/driver/operation.
  • Add an unexported mongo.updateSearchIndexOp with an execute method to run the command via driver.Operation.
  • Update SearchIndexView.UpdateOne to construct and execute the new unexported op directly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
x/mongo/driver/operation/update_search_index.go Removes the exported UpdateSearchIndex operation implementation from the operation package.
mongo/search_index_view.go Switches UpdateOne to use the new in-package unexported operation struct instead of operation.NewUpdateSearchIndex(...).
mongo/op_update_search_index.go Adds the unexported updateSearchIndexOp implementation inside the mongo package.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mongo/op_update_search_index.go Outdated
var ok bool
usir.Ok, ok = element.Value().AsInt32OK()
if !ok {
return usir, fmt.Errorf("response field 'ok' is type int32, but received BSON type %s", element.Value().Type)
Comment on lines +35 to +66
res updateSearchIndexResult
serverAPI *driver.ServerAPIOptions
timeout *time.Duration
}

// updateSearchIndexResult represents a single index in the updateSearchIndexResult result.
type updateSearchIndexResult struct {
Ok int32
}

func buildUpdateSearchIndexResult(response bsoncore.Document) (updateSearchIndexResult, error) {
elements, err := response.Elements()
if err != nil {
return updateSearchIndexResult{}, err
}
usir := updateSearchIndexResult{}
for _, element := range elements {
if element.Key() == "ok" {
var ok bool
usir.Ok, ok = element.Value().AsInt32OK()
if !ok {
return usir, fmt.Errorf("response field 'ok' is type int32, but received BSON type %s", element.Value().Type)
}
}
}
return usir, nil
}

func (usi *updateSearchIndexOp) processResponse(_ context.Context, resp bsoncore.Document, _ driver.ResponseInfo) error {
var err error
usi.res, err = buildUpdateSearchIndexResult(resp)
return err
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release review-priority-normal Medium Priority PR for Review: within 1 business day

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants