Many commands, such as find, distinct, count, etc. support processing over views.
Usually processing command over views results in the following flow:
- check if the collection or view acquisition is a view, if so go through a different execution flow
- relinquish the lock, as aggregation command will reacquire them
- map the command request into aggregation request
- run the aggregation request
- if the command is run not as explain, then also optionally format the result from the aggregate command
While working on PQS, we tried to extract this logic at least into a separate method for both find and distinct as done in SERVER-86874 and SERVER-86885.
While working on count modernization under SERVER-71453 we also moved the processing into a separate method.
The purpose for this ticket would be to try to avoid copy/pasta like code for each individual command, but rather provide a single generic method that would be shared by all the commands