From 123cd0eb6734f397ebf4236e0779d056243446d4 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Tue, 10 Nov 2009 15:43:51 -0500 Subject: optional params for map function SERVER-401 --- db/mr.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'db/mr.cpp') diff --git a/db/mr.cpp b/db/mr.cpp index 79042b23d41..521ef79fcd2 100644 --- a/db/mr.cpp +++ b/db/mr.cpp @@ -124,6 +124,13 @@ namespace mongo { finalizeCode = cmdObj["finalize"].ascode(); } + + if ( cmdObj["mapparams"].type() == Array ){ + mapparams = cmdObj["mapparams"].embeddedObjectUserCheck(); + } + else { + mapparams = BSONObj(); + } } { // query options @@ -174,6 +181,8 @@ namespace mongo { string mapCode; string reduceCode; string finalizeCode; + + BSONObj mapparams; // output tables string incLong; @@ -375,7 +384,7 @@ namespace mongo { if ( mr.verbose ) mt.reset(); state.scope->setThis( &o ); - if ( state.scope->invoke( state.map , BSONObj() , 0 , true ) ) + if ( state.scope->invoke( state.map , state.setup.mapparams , 0 , true ) ) throw UserException( (string)"map invoke failed: " + state.scope->getError() ); if ( mr.verbose ) mapTime += mt.micros(); -- cgit v1.2.1