mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 17:10:48 +01:00
add mapreduce() to the c++ client api.
not yet tested.
This commit is contained in:
parent
befa6fb41f
commit
04104f13a1
@ -282,6 +282,20 @@ namespace mongo {
|
||||
return false;
|
||||
}
|
||||
|
||||
BSONObj DBClientWithCommands::mapreduce(const string &ns, const string &jsmapf, const string &jsreducef, BSONObj query, const string& outputcolname) {
|
||||
BSONObjBuilder b;
|
||||
b.append("mapreduce", nsGetCollection(ns));
|
||||
b.appendCode("map", jsmapf.c_str());
|
||||
b.appendCode("reduce", jsreducef.c_str());
|
||||
if( !query.isEmpty() )
|
||||
b.append("query", query);
|
||||
if( !outputcolname.empty() )
|
||||
b.append("out", outputcolname);
|
||||
BSONObj info;
|
||||
runCommand(nsGetDB(ns), b.done(), info);
|
||||
return info;
|
||||
}
|
||||
|
||||
bool DBClientWithCommands::eval(const string &dbname, const string &jscode, BSONObj& info, BSONElement& retValue, BSONObj *args) {
|
||||
BSONObjBuilder b;
|
||||
b.appendCode("$eval", jscode.c_str());
|
||||
|
@ -458,6 +458,27 @@ namespace mongo {
|
||||
bool setDbProfilingLevel(const string &dbname, ProfilingLevel level, BSONObj *info = 0);
|
||||
bool getDbProfilingLevel(const string &dbname, ProfilingLevel& level, BSONObj *info = 0);
|
||||
|
||||
/** Run a map/reduce job on the server.
|
||||
|
||||
See http://www.mongodb.org/display/DOCS/MapReduce
|
||||
|
||||
ns namespace (db+collection name) of input data
|
||||
jsmapf javascript map function code
|
||||
jsreducef javascript reduce function code.
|
||||
query optional query filter for the input
|
||||
output optional permanent output collection name. if not specified server will
|
||||
generate a temporary collection and return its name.
|
||||
|
||||
returns a result object which contains:
|
||||
{ result : <collection_name>,
|
||||
numObjects : <number_of_objects_scanned>,
|
||||
timeMillis : <job_time>,
|
||||
ok : <1_if_ok>,
|
||||
[, err : <errmsg_if_error>]
|
||||
}
|
||||
*/
|
||||
BSONObj mapreduce(const string &ns, const string &jsmapf, const string &jsreducef, BSONObj query = BSONObj(), const string& output = "");
|
||||
|
||||
/** Run javascript code on the database server.
|
||||
dbname database context in which the code runs. The javascript variable 'db' will be assigned
|
||||
to this database when the function is invoked.
|
||||
|
@ -77,20 +77,6 @@ namespace mongo {
|
||||
|
||||
BSONObj::BSONObj(const Record *r) {
|
||||
init(r->data, false);
|
||||
/*
|
||||
_objdata = r->data;
|
||||
_objsize = *((int*) _objdata);
|
||||
if( _objsize > r->netLength() ) {
|
||||
out() << "About to assert fail _objsize <= r->netLength()" << endl;
|
||||
out() << " _objsize: " << _objsize << endl;
|
||||
out() << " netLength(): " << r->netLength() << endl;
|
||||
out() << " extentOfs: " << r->extentOfs << endl;
|
||||
out() << " nextOfs: " << r->nextOfs << endl;
|
||||
out() << " prevOfs: " << r->prevOfs << endl;
|
||||
assert( _objsize <= r->netLength() );
|
||||
}
|
||||
iFree = false;
|
||||
*/
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
|
Loading…
Reference in New Issue
Block a user