Exemple #1
0
 void BSONObjBuilder::appendMaxForType( const string& field , int t ){
     switch ( t ){
     case MinKey: appendMaxKey( field.c_str() );  break;
     case MaxKey: appendMaxKey( field.c_str() ); break;
     case NumberInt:
     case NumberDouble:
     case NumberLong:
         append( field.c_str() , numeric_limits<double>::max() );
         break;
     case BinData:
         appendMinForType( field , jstOID );
         break;
     case jstOID:
         {
             OID o;
             memset(&o, 0xFF, sizeof(o));
             appendOID( field.c_str() , &o);
             break;
         }
     case Undefined:
     case jstNULL:
         appendMinForType( field , NumberInt );
     case Bool: appendBool( field.c_str() , true); break;
     case Date: appendDate( field.c_str() , 0xFFFFFFFFFFFFFFFFLL ); break;
     case Symbol:
     case String: append( field.c_str() , BSONObj() ); break;
     case Code:
     case CodeWScope:
         appendCodeWScope( field.c_str() , "ZZZ" , BSONObj() ); break;
     case Timestamp:
         appendTimestamp( field.c_str() , numeric_limits<unsigned long long>::max() ); break;
     default:
         appendMinForType( field , t + 1 );
     }
 }
Exemple #2
0
 void BSONObjBuilder::appendMaxForType( const string& field , int t ){
     switch ( t ){
     case MinKey: appendMaxKey( field.c_str() );  break;
     case MaxKey: appendMaxKey( field.c_str() ); break;
     case NumberInt: 
     case NumberDouble:
     case NumberLong:
         append( field.c_str() , numeric_limits<double>::max() ); 
         break;
     case jstOID: 
         { 
             OID o;
             memset(&o, 0xFF, sizeof(o));
             appendOID( field.c_str() , &o);
             break;
         }
     case Bool: appendBool( field.c_str() , true); break;
     case Date: appendDate( field.c_str() , 0xFFFFFFFFFFFFFFFFLL ); break;
     case String: append( field.c_str() , BSONObj() ); break;
     case Timestamp:
         append( field.c_str() , (long long)0 ); break;
     default: 
         appendMinForType( field , t + 1 );
     }
 }
Exemple #3
0
    void BSONObjBuilder::appendMaxForType( 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:
            appendMinForType( fieldName, Object ); return;
        case Date:
            appendDate( fieldName , std::numeric_limits<long long>::max() ); return;
        case Timestamp: // TODO integrate with Date SERVER-3304
            append( fieldName , OpTime::max() ); 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 = OID::max();
            appendOID( fieldName , &o);
            return;
        }
        case Bool:
            appendBool( fieldName , true ); return;
        case jstNULL:
            appendNull( fieldName ); return;
        case Object:
            appendMinForType( fieldName, Array ); return;
        case Array:
            appendMinForType( fieldName, BinData ); return;
        case BinData:
            appendMinForType( fieldName, jstOID ); return;
        case RegEx:
            appendMinForType( fieldName, DBRef ); return;
        case DBRef:
            appendMinForType( fieldName, Code ); return;                
        case Code:
            appendMinForType( fieldName, CodeWScope ); return;
        case CodeWScope:
            // This upper bound may change if a new bson type is added.
            appendMinForType( fieldName , MaxKey ); return;
        }
        log() << "type not supported for appendMaxElementForType: " << t;
        uassert( 14853 ,  "type not supported for appendMaxElementForType" , false );
    }