Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-77290

Clarify/rename CanonicalQuery's internal 'canonicalize()' API

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization

      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

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: