From 6cad96709dea9ac76c759b360ac9e76ab7c9783d 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 d8ac2d0a0..9c343abfe 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 @@ -1848,7 +1848,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