Ejemplo n.º 1
0
Archivo: jsobj.cpp Proyecto: fes/mongo
 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 );
     }
 }
Ejemplo n.º 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 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 );
     }
 }
Ejemplo n.º 3
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 );
 }
Ejemplo n.º 4
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 );
    }