C++ driver now supports 1.8 M/R options SERVER-2893

This commit is contained in:
Mathias Stearn
2011-04-04 19:19:48 -04:00
parent fa7fbbb1f6
commit ec093cc5ac
3 changed files with 42 additions and 6 deletions

View File

@@ -224,5 +224,27 @@ int main( int argc, const char **argv ) {
}
}
{
//Map Reduce (this mostly just tests that it compiles with all output types)
const string ns = "test.mr";
conn.insert(ns, BSON("a" << 1));
conn.insert(ns, BSON("a" << 1));
const char* map = "function() { emit(this.a, 1); }";
const char* reduce = "function(key, values) { return Array.sum(values); }";
const string outcoll = ns + ".out";
BSONObj out;
out = conn.mapreduce(ns, map, reduce, BSONObj()); // default to inline
//MONGO_PRINT(out);
out = conn.mapreduce(ns, map, reduce, BSONObj(), outcoll);
//MONGO_PRINT(out);
out = conn.mapreduce(ns, map, reduce, BSONObj(), outcoll.c_str());
//MONGO_PRINT(out);
out = conn.mapreduce(ns, map, reduce, BSONObj(), BSON("reduce" << outcoll));
//MONGO_PRINT(out);
}
cout << "client test finished!" << endl;
}