From d4dc13894aa4326d2c27994b427683f9a695256d Mon Sep 17 00:00:00 2001 From: blu10ph Date: Thu, 10 Feb 2022 14:55:47 +0800 Subject: [PATCH] Avoid obtaining mapped sort multiple times for mapReduce. Apply already mapped sort for map reduce instead of running the source document through the mapping layer again. Closes: #3960 --- .../org/springframework/data/mongodb/core/MongoTemplate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java index a07e3fee7..2986df20c 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java @@ -1852,7 +1852,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, Document mappedSort = getMappedSortObject(query, domainType); if (mappedSort != null && !mappedSort.isEmpty()) { - mapReduce = mapReduce.sort(getMappedSortObject(query, domainType)); + mapReduce = mapReduce.sort(mappedSort); } mapReduce = mapReduce