SERVER-15528 Refactor DistinctScan to do less in each work() call

(cherry picked from commit e0f47214d06738f14d0d0d731235a9f665a6b81f)