Example #1
0
 void BSONObjBuilder::appendMinForType( const StringData& fieldName , int t ) {
     switch ( t ) {
             
     // Shared canonical types
     case NumberInt:
     case NumberDouble:
     case NumberLong:
         append( fieldName , - std::numeric_limits<double>::max() ); return;
     case Symbol:
     case String:
         append( fieldName , "" ); return;
     case Date: 
         // min varies with V0 and V1 indexes, so we go one type lower.
         appendBool(fieldName, true);
         //appendDate( fieldName , numeric_limits<long long>::min() ); 
         return;
     case Timestamp: // TODO integrate with Date SERVER-3304
         appendTimestamp( fieldName , 0 ); return;
     case Undefined: // shared with EOO
         appendUndefined( fieldName ); return;
             
     // Separate canonical types
     case MinKey:
         appendMinKey( fieldName ); return;
     case MaxKey:
         appendMaxKey( fieldName ); return;
     case jstOID: {
         OID o;
         appendOID( fieldName , &o);
         return;
     }
     case Bool:
         appendBool( fieldName , false); return;
     case jstNULL:
         appendNull( fieldName ); return;
     case Object:
         append( fieldName , BSONObj() ); return;
     case Array:
         appendArray( fieldName , BSONObj() ); return;
     case BinData:
         appendBinData( fieldName , 0 , BinDataGeneral , (const char *) 0 ); return;
     case RegEx:
         appendRegex( fieldName , "" ); return;
     case DBRef: {
         OID o;
         appendDBRef( fieldName , "" , o );
         return;
     }
     case Code:
         appendCode( fieldName , "" ); return;
     case CodeWScope:
         appendCodeWScope( fieldName , "" , BSONObj() ); return;
     };
     log() << "type not supported for appendMinElementForType: " << t;
     uassert( 10061 ,  "type not supported for appendMinElementForType" , false );
 }
Example #2
0
File: jsobj.cpp Project: fes/mongo
    void BSONObjBuilder::appendMinForType( const string& field , int t ){
        switch ( t ){
        case MinKey: appendMinKey( field.c_str() ); return;
        case MaxKey: appendMinKey( field.c_str() ); return;
        case NumberInt:
        case NumberDouble:
        case NumberLong:
            append( field.c_str() , - numeric_limits<double>::max() ); return;
        case jstOID: 
            { 
                OID o;
                memset(&o, 0, sizeof(o));
                appendOID( field.c_str() , &o);
                return;
            }
        case Bool: appendBool( field.c_str() , false); return;
        case Date: appendDate( field.c_str() , 0); return;
        case jstNULL: appendNull( field.c_str() ); return;
        case String: append( field.c_str() , "" ); return;
        case Object: append( field.c_str() , BSONObj() ); return;
        case Array: 
            appendArray( field.c_str() , BSONObj() ); return;
        case BinData:  
            appendBinData( field.c_str() , 0 , Function , 0 ); return;
        case Undefined:
            appendUndefined( field.c_str() ); return;
        case RegEx: appendRegex( field.c_str() , "" ); return;
        case DBRef:
            {
                OID o;
                memset(&o, 0, sizeof(o));
                appendDBRef( field.c_str() , "" , o );
                return;
            }
        case Code: appendCode( field.c_str() , "" ); return;
        case Symbol: appendSymbol( field.c_str() , "" ); return;
        case CodeWScope: appendCodeWScope( field.c_str() , "" , BSONObj() ); return;
        case Timestamp: appendTimestamp( field.c_str() , 0); return;

        };
        log() << "type not support for appendMinElementForType: " << t << endl;
        uassert( "type not supported for appendMinElementForType" , false );
    }