diff options
author | Dwight <dmerriman@gmail.com> | 2009-10-15 16:47:48 -0400 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2009-10-15 16:47:48 -0400 |
commit | 5696d65d835ad279ea5ae8bef6c51230fba15b0f (patch) | |
tree | 3a900ec29cf44063921e40eb51b16d32be001586 | |
parent | f152047f195cc9a2e9a6d9d327f1097593e0ba11 (diff) | |
parent | 98d994eb51b174c4f464194ccb2b406ed9e37230 (diff) | |
download | mongo-5696d65d835ad279ea5ae8bef6c51230fba15b0f.tar.gz |
Merge branch 'master' of git@github.com:mongodb/mongo
-rw-r--r-- | buildscripts/hacks_ubuntu.py | 2 | ||||
-rw-r--r-- | db/instance.cpp | 10 | ||||
-rw-r--r-- | db/mr.cpp | 2 | ||||
-rw-r--r-- | jstests/mr1.js | 33 | ||||
-rw-r--r-- | scripting/engine_spidermonkey.cpp | 4 | ||||
-rw-r--r-- | util/base64.cpp | 22 | ||||
-rw-r--r-- | util/processinfo_linux2.cpp | 8 |
7 files changed, 58 insertions, 23 deletions
diff --git a/buildscripts/hacks_ubuntu.py b/buildscripts/hacks_ubuntu.py index 9ae72a85db5..26714bdd2db 100644 --- a/buildscripts/hacks_ubuntu.py +++ b/buildscripts/hacks_ubuntu.py @@ -41,4 +41,6 @@ def foundxulrunner( env , options ): incroot + "unstable/" ] ) env.Append( CPPDEFINES=[ "XULRUNNER" , "OLDJS" ] ) + if best.find( "1.9.0" ) >= 0: + env.Append( CPPDEFINES=[ "XULRUNNER190" ] ) return True diff --git a/db/instance.cpp b/db/instance.cpp index 4fff3b7820f..d173940fe2c 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -509,9 +509,10 @@ namespace mongo { note we should already be in the mutex lock from connThread() at this point. */ + /* void jniCallbackDeprecated(Message& m, Message& out) { - /* we should be in the same thread as the original request, so authInfo should be available. */ + // AuthenticationInfo *ai = currentClient.get()->ai; Database *clientOld = cc().database(); @@ -589,7 +590,7 @@ namespace mongo { if ( database && database->profile >= 1 ) { if ( database->profile >= 2 || ms >= 100 ) { // profile it - profile(ss.str().c_str()+20/*skip ts*/, ms); + profile(ss.str().c_str()+20, ms); } } } @@ -603,11 +604,10 @@ namespace mongo { callDepth--; if ( cc().database() != clientOld ) { - assert(false);/* - database = clientOld; - wassert(false);*/ + assert(false); } } + */ void getDatabaseNames( vector< string > &names ) { boost::filesystem::path path( dbpath ); diff --git a/db/mr.cpp b/db/mr.cpp index 4083ba889a4..d812c5e3f3e 100644 --- a/db/mr.cpp +++ b/db/mr.cpp @@ -314,7 +314,7 @@ namespace mongo { ProgressMeter pm( db.count( ns , filter ) ); auto_ptr<DBClientCursor> cursor = db.query( ns , q ); - long long mapTime; + long long mapTime = 0; Timer mt; while ( cursor->more() ){ BSONObj o = cursor->next(); diff --git a/jstests/mr1.js b/jstests/mr1.js index d06137e519b..c78f615d768 100644 --- a/jstests/mr1.js +++ b/jstests/mr1.js @@ -10,7 +10,7 @@ t.save( { x : 4 , tags : [ "b" , "c" ] } ); emit = printjson; function d( x ){ - //printjson( x ); + printjson( x ); } ks = "_id"; @@ -26,6 +26,13 @@ m = function(){ ); }; +m2 = function(){ + for ( var i=0; i<this.tags.length; i++ ){ + emit( this.tags[i] , 1 ); + } +}; + + r = function( key , values ){ var total = 0; for ( var i=0; i<values.length; i++ ){ @@ -34,6 +41,14 @@ r = function( key , values ){ return { count : total }; }; +r2 = function( key , values ){ + var total = 0; + for ( var i=0; i<values.length; i++ ){ + total += values[i]; + } + return total; +}; + res = db.runCommand( { mapreduce : "mr1" , map : m , reduce : r } ); d( res ); if ( ks == "_id" ) assert( res.ok , "not ok" ); @@ -62,6 +77,18 @@ assert.eq( 1 , z.b , "C2" ); assert.eq( 2 , z.c , "C3" ); x.drop(); +res = db.runCommand( { mapreduce : "mr1" , map : m2 , reduce : r2 , query : { x : { "$gt" : 2 } } } ); +d( res ); +assert.eq( 2 , res.counts.input , "B" ); +x = db[res.result]; +z = {}; +x.find().forEach( function(a){ z[a[ks]] = a.value; } ); +assert.eq( 1 , z.a , "C1z" ); +assert.eq( 1 , z.b , "C2z" ); +assert.eq( 2 , z.c , "C3z" ); +x.drop(); + + res = db.runCommand( { mapreduce : "mr1" , out : "foo" , map : m , reduce : r , query : { x : { "$gt" : 2 } } } ); d( res ); assert.eq( 2 , res.counts.input , "B2" ); @@ -141,6 +168,10 @@ if ( true ){ } } x.drop(); + + res = db.runCommand( { mapreduce : "mr1" , out : "foo" , map : m2 , reduce : r2 } ); + d(res); + print( "t3: " + res.timeMillis + " (~3500 on 2.8ghz)" ); } diff --git a/scripting/engine_spidermonkey.cpp b/scripting/engine_spidermonkey.cpp index 44f5067c9a2..ea6c4c1916a 100644 --- a/scripting/engine_spidermonkey.cpp +++ b/scripting/engine_spidermonkey.cpp @@ -1174,7 +1174,7 @@ namespace mongo { spec->start = boost::posix_time::microsec_clock::local_time(); spec->count = 0; JS_SetContextPrivate( _context, (void*)spec ); -#ifdef SM181 +#if defined(SM181) && !defined(XULRUNNER190) JS_SetOperationCallback( _context, _checkTimeout ); #else JS_SetBranchCallback( _context, checkTimeout ); @@ -1184,7 +1184,7 @@ namespace mongo { void uninstallCheckTimeout( int timeoutMs ) { if ( timeoutMs > 0 ) { -#ifdef SM181 +#if defined(SM181) && !defined(XULRUNNER190) JS_SetOperationCallback( _context , 0 ); #else JS_SetBranchCallback( _context, 0 ); diff --git a/util/base64.cpp b/util/base64.cpp index 18281c5c4e9..44d335611bf 100644 --- a/util/base64.cpp +++ b/util/base64.cpp @@ -25,13 +25,13 @@ namespace mongo { class Alphabet { public: Alphabet(){ - encode = + encode = (unsigned char*) "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789" "+/"; - decode = (char*)malloc(257); + decode = (unsigned char*)malloc(257); memset( decode , 0 , 256 ); for ( int i=0; i<64; i++ ){ decode[ encode[i] ] = i; @@ -44,7 +44,7 @@ namespace mongo { } void test(){ - assert( strlen( encode ) == 64 ); + assert( strlen( (char*)encode ) == 64 ); for ( int i=0; i<26; i++ ) assert( encode[i] == toupper( encode[i+26] ) ); } @@ -54,22 +54,22 @@ namespace mongo { } private: - const char * encode; + const unsigned char * encode; public: - char * decode; + unsigned char * decode; } alphabet; void encode( stringstream& ss , const char * data , int size ){ for ( int i=0; i<size; i+=3 ){ int left = size - i; - const char * start = data + i; + const unsigned char * start = (const unsigned char*)data + i; // byte 0 ss << alphabet.e(start[0]>>2); // byte 1 - char temp = ( start[0] << 4 ); + unsigned char temp = ( start[0] << 4 ); if ( left == 1 ){ ss << alphabet.e(temp); break; @@ -113,12 +113,12 @@ namespace mongo { void decode( stringstream& ss , const string& s ){ uassert( "invalid base64" , s.size() % 4 == 0 ); - const char * data = s.c_str(); + const unsigned char * data = (const unsigned char*)s.c_str(); int size = s.size(); - char buf[3]; + unsigned char buf[3]; for ( int i=0; i<size; i+=4){ - const char * start = data + i; + const unsigned char * start = data + i; buf[0] = ( ( alphabet.decode[start[0]] << 2 ) & 0xFC ) | ( ( alphabet.decode[start[1]] >> 4 ) & 0x3 ); buf[1] = ( ( alphabet.decode[start[1]] << 4 ) & 0xF0 ) | ( ( alphabet.decode[start[2]] >> 2 ) & 0xF ); buf[2] = ( ( alphabet.decode[start[2]] << 6 ) & 0xC0 ) | ( ( alphabet.decode[start[3]] & 0x3F ) ); @@ -130,7 +130,7 @@ namespace mongo { len = 1; } } - ss.write( buf , len ); + ss.write( (const char*)buf , len ); } } diff --git a/util/processinfo_linux2.cpp b/util/processinfo_linux2.cpp index 3a6bd900daf..035acc6a2f7 100644 --- a/util/processinfo_linux2.cpp +++ b/util/processinfo_linux2.cpp @@ -19,8 +19,8 @@ namespace mongo { sprintf( name , "/proc/%d/stat" , pid ); FILE * f = fopen( name , "r"); - - fscanf(f, + + int found = fscanf(f, "%d %s %c " "%d %d %d %d %d " "%lu %lu %lu %lu %lu " @@ -61,7 +61,9 @@ namespace mongo { &_rtprio, &_sched */ ); - + if ( found == 0 ){ + cerr << "system error: reading proc info" << endl; + } fclose( f ); } |