[SERVER-8624] Remove read-only constraint on Reduce function values Created: 19/Feb/13  Updated: 11/Jul/16  Resolved: 25/Feb/13

Status: Closed
Project: Core Server
Component/s: MapReduce
Affects Version/s: 2.3.0, 2.3.1, 2.3.2, 2.4.0-rc0
Fix Version/s: 2.4.0-rc2

Type: Improvement Priority: Major - P3
Reporter: Ian Beaver Assignee: Ben Becker
Resolution: Done Votes: 0
Labels: v8
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

V8


Issue Links:
Duplicate
duplicates SERVER-5379 js increment operators (ob.prop += ob... Closed
Related
related to SERVER-9066 Field names can be repeated in JavaSc... Closed
Participants:

 Description   

In the V8 engine switch, values passed to the reduce function have been changed to be read-only. There are several situations were read only values impose problems in the reduce step. For example trying to merge lists of objects with some common properties where you increment a count in an existing object when you see a duplicate in another list. Since that object is read only, you cant increment the count inside it to persist in future reduce steps. Or you want to actually merge two objects where the result is a composite of the two objects, you can't because the initial object is read only. So then you have to try and make a copy of the initial object to then write your changes into and return, which adds overhead and lots of duplicate code in each reduce function. Also as this is JavaScript, implementing a deep copy on a generic object is a hard thing to get right (See http://stackoverflow.com/questions/728360/copying-an-object-in-javascript for a detailed discussion).

I understand this was done as a performance optimization, but maybe there should be a reconsideration of the impact on the M/R engine flexibility and on all the existing code written against the <2.4 engine behaviour?



 Comments   
Comment by auto [ 25/Feb/13 ]

Author:

{u'date': u'2013-02-25T19:27:15Z', u'name': u'Ben Becker', u'email': u'ben.becker@10gen.com'}

Message: SERVER-8624: make reduce arguments mutable
Branch: master
https://github.com/mongodb/mongo/commit/b06ea7b670826856cbc28ba99ae766c7ca397084

Generated at Thu Feb 08 03:17:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.