This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pseudo-c++ | |
// | |
// High Level Examples | |
// | |
void insert(BSONObj obj, bool shouldLogOp) { | |
do { | |
WriteUnitOfWork wunit; | |
if (!collection) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/static_assert.hpp> | |
#include <type_traits> | |
#include <vector> | |
int main() { | |
////////////////// PROXY OBJECTS ///////////////// | |
{ | |
auto bools = std::vector<bool>{true, false}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
template <typename T> using some_iterator_type = T*; | |
template <typename T> struct ptr {}; // from mongo ptr.h | |
// Defining concepts using struct syntax. These are like interfaces, but not in | |
// the virtual-dispatch sense. Actual Cursor implementations must have an API | |
// that is usable as-if it had these signatures, even if the types don't match. | |
#define concept struct | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OpDebug : public Decorable<OpDebug> { | |
public: | |
// | |
// Removed existing members for brevity. | |
// | |
class Extension { | |
virtual void appendToString(StringBuilder*) = 0; | |
virtual void appendToBson(BSONObjBuilder*) = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function( key , values ){ | |
var confidence_threshold = 0.0 | |
var total = 0 | |
var sc = 0.0 | |
var cats = [] | |
var links = [] | |
for ( var i=0; i<values.length; i++ ) { | |
total += values[i].count | |
sc += (values[i].score || 0) | |
links.push({hash:values[i].hash,title:values[i].title, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.events.mapReduce( | |
function(){ | |
emit({category:this.category, uid:this.uid}, null); | |
}, | |
function(key, values){ | |
return null; | |
}, | |
{query: {type: "pageview"}} | |
).map_reduce( | |
function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "test.h" | |
#include "mongo.h" | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int main(){ | |
mongo_connection conn[1]; | |
mongo_connection_options opts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ MONGO_INCLUDE_PATH=/usr/include/mongo/ scons . | |
scons: Reading SConscript files ... | |
scons: done reading SConscript files. | |
scons: Building targets ... | |
g++ -o gridfs_c_helpers.o -c -I/usr/include/mongo -INone gridfs_c_helpers.cpp | |
scons: done building targets. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.test.find({loc:{$near:[0,0]}}) | |
{ "_id" : ObjectId("4ba7e616b8c125a527c38708"), "name" : "a", "loc" : [ 0, 0 ] } | |
{ "_id" : ObjectId("4ba7e61ab8c125a527c38709"), "name" : "b", "loc" : [ 0, 0 ] } | |
{ "_id" : ObjectId("4ba7e620b8c125a527c3870a"), "name" : "c", "loc" : [ 1, 1 ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* test.c */ | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#ifndef _WIN32 | |
#include <sys/time.h> | |
#endif | |
static char hexbyte1(char hex){ |
OlderNewer