0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00

prep for signed dates

This commit is contained in:
Dwight 2011-06-03 14:01:41 -04:00
parent 303961a949
commit 5133061a17
3 changed files with 7 additions and 2 deletions

View File

@ -365,6 +365,7 @@ namespace mongo {
return *reinterpret_cast< const mongo::OID* >( start );
}
/** this does not use fieldName in the comparison, just the value */
bool operator<( const BSONElement& other ) const {
int x = (int)canonicalType() - (int)other.canonicalType();
if ( x < 0 ) return true;

View File

@ -362,7 +362,7 @@ namespace mongo {
switch ( l.type() ) {
case EOO:
case Undefined:
case Undefined: // EOO and Undefined are same canonicalType
case jstNULL:
case MaxKey:
case MinKey:
@ -372,6 +372,10 @@ namespace mongo {
case Bool:
return *l.value() - *r.value();
case Timestamp:
// unsigned compare for timestamps - note they are not really dates but (ordinal + time_t)
if ( l.date() < r.date() )
return -1;
return l.date() == r.date() ? 0 : 1;
case Date:
if ( l.date() < r.date() )
return -1;

View File

@ -36,7 +36,7 @@ namespace mongo {
*/
#pragma pack(4)
class OpTime {
unsigned i;
unsigned i; // ordinal comes first so we can do a single 64 bit compare on little endian
unsigned secs;
static OpTime last;
static OpTime skewed();