[SERVER-77290] Clarify/rename CanonicalQuery's internal 'canonicalize()' API Created: 18/May/23  Updated: 25/May/23

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Charlie Swanson Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-76042 Avoid re-parsing match, sort and proj... Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

During code review of SERVER-76042 which refactored this API, we noticed it was a little confusing:

 /**
     * For testing or for internal clients to use.
     */
 
    /**
     * Used for creating sub-queries from an existing CanonicalQuery.
     *
     * 'root' must be an expression in baseQuery.root().
     *
     * Does not take ownership of 'root'.
     */
    static StatusWith<std::unique_ptr<CanonicalQuery>> canonicalize(OperationContext* opCtx,
                                                                    const CanonicalQuery& baseQuery,
                                                                    MatchExpression* root);

The comments and confusion were around:

davis.haupt@mongodb.com: don't we already have a MatchExpression* and a CanonicalQuery in this function? why re-parse here?

It looks like the old code also re-parsed. I do think it would be useful to add a comment here about why it's necessary, though

jacob.evans@mongodb.com: looks like this reroots just the find portion of the query for testing? should we consider changing the name? or filing something to delete it if it's underutilized


Generated at Thu Feb 08 06:35:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.