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

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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • Query Optimization

    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

      Attachments

        Activity

          People

            backlog-query-optimization Backlog - Query Optimization
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: