diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-11-10 15:43:51 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-11-10 15:43:51 -0500 |
commit | 123cd0eb6734f397ebf4236e0779d056243446d4 (patch) | |
tree | f216d0563330f23445dcd522c6620ada1c7a91b8 /db/mr.cpp | |
parent | c47308b1b4c677d782b6f4ed516894bc5210774e (diff) | |
download | mongo-123cd0eb6734f397ebf4236e0779d056243446d4.tar.gz |
optional params for map function SERVER-401
Diffstat (limited to 'db/mr.cpp')
-rw-r--r-- | db/mr.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
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(); |