diff options
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r-- | src/mongo/db/pipeline/document_value_test.cpp | 36 | ||||
-rw-r--r-- | src/mongo/db/pipeline/value.cpp | 30 | ||||
-rw-r--r-- | src/mongo/db/pipeline/value.h | 10 | ||||
-rw-r--r-- | src/mongo/db/pipeline/value_internal.h | 4 |
4 files changed, 40 insertions, 40 deletions
diff --git a/src/mongo/db/pipeline/document_value_test.cpp b/src/mongo/db/pipeline/document_value_test.cpp index 28e63419242..0deb17f7341 100644 --- a/src/mongo/db/pipeline/document_value_test.cpp +++ b/src/mongo/db/pipeline/document_value_test.cpp @@ -375,7 +375,7 @@ namespace DocumentTests { append("codeWScope", BSONCodeWScope("asdf", BSONObj())); append("codeWScopeWScope", BSONCodeWScope("asdf", BSON("one" << 1))); append("int", 1); - append("timestamp", OpTime()); + append("timestamp", Timestamp()); append("long", 1LL); append("very long", 1LL << 40); append("maxkey", MAXKEY); @@ -533,12 +533,12 @@ namespace DocumentTests { }; /** Timestamp type. */ - class Timestamp { + class JSTimestamp { public: void run() { - Value value = Value( OpTime( 777 ) ); - ASSERT( OpTime( 777 ) == value.getTimestamp() ); - ASSERT_EQUALS( mongo::Timestamp, value.getType() ); + Value value = Value( Timestamp( 777 ) ); + ASSERT( Timestamp( 777 ) == value.getTimestamp() ); + ASSERT_EQUALS( mongo::bsonTimestamp, value.getType() ); assertRoundTrips( value ); } }; @@ -1024,7 +1024,7 @@ namespace DocumentTests { */ class TimestampToDate : public ToDateBase { Value value() { - return Value( OpTime( 777, 666 ) ); + return Value( Timestamp( 777, 666 ) ); } long long expected() { return 777 * 1000; } }; @@ -1076,9 +1076,9 @@ namespace DocumentTests { /** Coerce timestamp to string. */ class TimestampToString : public ToStringBase { Value value() { - return Value( OpTime( 1, 2 ) ); + return Value( Timestamp( 1, 2 ) ); } - string expected() { return OpTime( 1, 2 ).toStringPretty(); } + string expected() { return Timestamp( 1, 2 ).toStringPretty(); } }; /** Coerce date to string. */ @@ -1111,8 +1111,8 @@ namespace DocumentTests { class TimestampToTimestamp { public: void run() { - Value value = Value( OpTime( 1010 ) ); - ASSERT( OpTime( 1010 ) == value.coerceToTimestamp() ); + Value value = Value( Timestamp( 1010 ) ); + ASSERT( Timestamp( 1010 ) == value.coerceToTimestamp() ); } }; @@ -1272,8 +1272,8 @@ namespace DocumentTests { assertComparison( -1, fromjson( "{'':/a/}" ), fromjson( "{'':/aa/}" ) ); // Timestamp. - assertComparison( 0, OpTime( 1234 ), OpTime( 1234 ) ); - assertComparison( -1, OpTime( 4 ), OpTime( 1234 ) ); + assertComparison( 0, Timestamp( 1234 ), Timestamp( 1234 ) ); + assertComparison( -1, Timestamp( 4 ), Timestamp( 1234 ) ); // Cross-type comparisons. Listed in order of canonical types. assertComparison(-1, Value(mongo::MINKEY), Value()); @@ -1291,8 +1291,8 @@ namespace DocumentTests { assertComparison(-1, Value(BSONBinData("", 0, MD5Type)), Value(mongo::OID())); assertComparison(-1, Value(mongo::OID()), Value(false)); assertComparison(-1, Value(false), Value(Date_t(0))); - assertComparison(-1, Value(Date_t(0)), Value(OpTime())); - assertComparison(-1, Value(OpTime()), Value(BSONRegEx(""))); + assertComparison(-1, Value(Date_t(0)), Value(Timestamp())); + assertComparison(-1, Value(Timestamp()), Value(BSONRegEx(""))); assertComparison(-1, Value(BSONRegEx("")), Value(BSONDBRef("", mongo::OID()))); assertComparison(-1, Value(BSONDBRef("", mongo::OID())), Value(BSONCode(""))); assertComparison(-1, Value(BSONCode("")), Value(BSONCodeWScope("", BSONObj()))); @@ -1303,11 +1303,11 @@ namespace DocumentTests { void assertComparison( int expectedResult, const T& a, const U& b ) { assertComparison( expectedResult, BSON( "" << a ), BSON( "" << b ) ); } - void assertComparison( int expectedResult, const OpTime& a, const OpTime& b ) { + void assertComparison( int expectedResult, const Timestamp& a, const Timestamp& b ) { BSONObjBuilder first; - first.appendTimestamp( "", a.asDate() ); + first.append( "", a ); BSONObjBuilder second; - second.appendTimestamp( "", b.asDate() ); + second.append( "", b ); assertComparison( expectedResult, first.obj(), second.obj() ); } int sign(int cmp) { @@ -1433,7 +1433,7 @@ namespace DocumentTests { add<Value::String>(); add<Value::StringWithNull>(); add<Value::Date>(); - add<Value::Timestamp>(); + add<Value::JSTimestamp>(); add<Value::EmptyDocument>(); add<Value::EmptyArray>(); add<Value::Array>(); diff --git a/src/mongo/db/pipeline/value.cpp b/src/mongo/db/pipeline/value.cpp index f96e8c0aeca..8ef22166e84 100644 --- a/src/mongo/db/pipeline/value.cpp +++ b/src/mongo/db/pipeline/value.cpp @@ -56,7 +56,7 @@ namespace mongo { case MaxKey: case jstOID: case Date: - case Timestamp: + case bsonTimestamp: case EOO: case jstNULL: case Undefined: @@ -199,8 +199,8 @@ namespace mongo { _storage.intValue = elem.numberInt(); break; - case Timestamp: - _storage.timestampValue = elem._opTime().asDate(); + case bsonTimestamp: + _storage.timestampValue = elem.timestamp().asULL(); break; case NumberLong: @@ -289,7 +289,7 @@ namespace mongo { case String: return builder << val.getStringData(); case Bool: return builder << val.getBool(); case Date: return builder << Date_t(val.getDate()); - case Timestamp: return builder << val.getTimestamp(); + case bsonTimestamp: return builder << val.getTimestamp(); case Object: return builder << val.getDocument(); case Symbol: return builder << BSONSymbol(val.getStringData()); case Code: return builder << BSONCode(val.getStringData()); @@ -347,7 +347,7 @@ namespace mongo { case Date: case RegEx: case Symbol: - case Timestamp: + case bsonTimestamp: return true; case EOO: @@ -425,7 +425,7 @@ namespace mongo { case Date: return getDate(); - case Timestamp: + case bsonTimestamp: return getTimestamp().getSecs() * 1000LL; default: @@ -502,7 +502,7 @@ namespace mongo { case String: return getStringData().toString(); - case Timestamp: + case bsonTimestamp: return getTimestamp().toStringPretty(); case Date: @@ -521,9 +521,9 @@ namespace mongo { } // switch(getType()) } - OpTime Value::coerceToTimestamp() const { + Timestamp Value::coerceToTimestamp() const { switch(getType()) { - case Timestamp: + case bsonTimestamp: return getTimestamp(); default: @@ -578,7 +578,7 @@ namespace mongo { case Bool: return rL.getBool() - rR.getBool(); - case Timestamp: // unsigned + case bsonTimestamp: // unsigned return cmp(rL._storage.timestampValue, rR._storage.timestampValue); case Date: // signed @@ -705,7 +705,7 @@ namespace mongo { boost::hash_combine(seed, getBool()); break; - case Timestamp: + case bsonTimestamp: case Date: BOOST_STATIC_ASSERT(sizeof(_storage.dateValue) == sizeof(_storage.timestampValue)); boost::hash_combine(seed, _storage.dateValue); @@ -864,7 +864,7 @@ namespace mongo { case Bool: case Date: case NumberInt: - case Timestamp: + case bsonTimestamp: case NumberLong: case jstNULL: case Undefined: @@ -897,7 +897,7 @@ namespace mongo { case jstNULL: return out << "null"; case Undefined: return out << "undefined"; case Date: return out << tmToISODateString(val.coerceToTm()); - case Timestamp: return out << val.getTimestamp().toString(); + case bsonTimestamp: return out << val.getTimestamp().toString(); case Object: return out << val.getDocument().toString(); case Array: { out << "["; @@ -948,7 +948,7 @@ namespace mongo { case NumberDouble: buf.appendNum(_storage.doubleValue); break; case Bool: buf.appendChar(_storage.boolValue); break; case Date: buf.appendNum(_storage.dateValue); break; - case Timestamp: buf.appendStruct(getTimestamp()); break; + case bsonTimestamp: buf.appendStruct(getTimestamp()); break; // types that are like strings case String: @@ -1019,7 +1019,7 @@ namespace mongo { case NumberDouble: return Value(buf.read<double>()); case Bool: return Value(bool(buf.read<char>())); case Date: return Value(Date_t(buf.read<long long>())); - case Timestamp: return Value(buf.read<OpTime>()); + case bsonTimestamp: return Value(buf.read<Timestamp>()); // types that are like strings case String: diff --git a/src/mongo/db/pipeline/value.h b/src/mongo/db/pipeline/value.h index dc10ea3246e..4e30c30564d 100644 --- a/src/mongo/db/pipeline/value.h +++ b/src/mongo/db/pipeline/value.h @@ -72,7 +72,7 @@ namespace mongo { explicit Value(int value) : _storage(NumberInt, value) {} explicit Value(long long value) : _storage(NumberLong, value) {} explicit Value(double value) : _storage(NumberDouble, value) {} - explicit Value(const OpTime& value) : _storage(Timestamp, value) {} + explicit Value(const Timestamp& value) : _storage(bsonTimestamp, value) {} explicit Value(const OID& value) : _storage(jstOID, value) {} explicit Value(StringData value) : _storage(String, value) {} explicit Value(const std::string& value) : _storage(String, StringData(value)) {} @@ -150,7 +150,7 @@ namespace mongo { OID getOid() const; bool getBool() const; long long getDate() const; // in milliseconds - OpTime getTimestamp() const; + Timestamp getTimestamp() const; const char* getRegex() const; const char* getRegexFlags() const; std::string getSymbol() const; @@ -189,7 +189,7 @@ namespace mongo { int coerceToInt() const; long long coerceToLong() const; double coerceToDouble() const; - OpTime coerceToTimestamp() const; + Timestamp coerceToTimestamp() const; long long coerceToDate() const; time_t coerceToTimeT() const; tm coerceToTm() const; // broken-out time struct (see man gmtime) @@ -326,8 +326,8 @@ namespace mongo { return _storage.dateValue; } - inline OpTime Value::getTimestamp() const { - verify(getType() == Timestamp); + inline Timestamp Value::getTimestamp() const { + verify(getType() == bsonTimestamp); return Date_t(_storage.timestampValue); } diff --git a/src/mongo/db/pipeline/value_internal.h b/src/mongo/db/pipeline/value_internal.h index 910728019ce..834c2e7d1d6 100644 --- a/src/mongo/db/pipeline/value_internal.h +++ b/src/mongo/db/pipeline/value_internal.h @@ -37,7 +37,7 @@ #include "mongo/bson/oid.h" #include "mongo/util/debug_util.h" #include "mongo/util/intrusive_counter.h" -#include "mongo/bson/optime.h" +#include "mongo/bson/timestamp.h" namespace mongo { @@ -81,7 +81,7 @@ namespace mongo { ValueStorage(BSONType t, int i) { zero(); type = t; intValue = i; } ValueStorage(BSONType t, long long l) { zero(); type = t; longValue = l; } ValueStorage(BSONType t, double d) { zero(); type = t; doubleValue = d; } - ValueStorage(BSONType t, OpTime r) { zero(); type = t; timestampValue = r.asDate(); } + ValueStorage(BSONType t, Timestamp r) { zero(); type = t; timestampValue = r.asULL(); } ValueStorage(BSONType t, bool b) { zero(); type = t; boolValue = b; } ValueStorage(BSONType t, const Document& d) { zero(); type = t; putDocument(d); } ValueStorage(BSONType t, const RCVector* a) { zero(); type = t; putVector(a); } |