diff options
Diffstat (limited to 'src/mongo/db/pipeline/resume_token.cpp')
| -rw-r--r-- | src/mongo/db/pipeline/resume_token.cpp | 48 |
1 files changed, 5 insertions, 43 deletions
diff --git a/src/mongo/db/pipeline/resume_token.cpp b/src/mongo/db/pipeline/resume_token.cpp index fe6468842ea..cc6d3631fd3 100644 --- a/src/mongo/db/pipeline/resume_token.cpp +++ b/src/mongo/db/pipeline/resume_token.cpp @@ -38,6 +38,7 @@ #include "mongo/bson/bsonobjbuilder.h" #include "mongo/db/exec/document_value/value_comparator.h" #include "mongo/db/pipeline/change_stream_helpers_legacy.h" +#include "mongo/db/pipeline/document_source_change_stream_gen.h" #include "mongo/db/storage/key_string.h" #include "mongo/util/hex.h" @@ -87,8 +88,7 @@ bool ResumeTokenData::operator==(const ResumeTokenData& other) const { return clusterTime == other.clusterTime && version == other.version && tokenType == other.tokenType && txnOpIndex == other.txnOpIndex && fromInvalidate == other.fromInvalidate && uuid == other.uuid && - (Value::compare(this->eventIdentifier, other.eventIdentifier, nullptr) == 0) && - fragmentNum == other.fragmentNum; + (Value::compare(this->eventIdentifier, other.eventIdentifier, nullptr) == 0); } std::ostream& operator<<(std::ostream& out, const ResumeTokenData& tokenData) { @@ -102,11 +102,7 @@ std::ostream& operator<<(std::ostream& out, const ResumeTokenData& tokenData) { out << ", fromInvalidate: " << static_cast<bool>(tokenData.fromInvalidate); } out << ", uuid: " << tokenData.uuid; - out << ", eventIdentifier: " << tokenData.eventIdentifier; - if (tokenData.version >= 2) { - out << ", fragmentNum: " << tokenData.fragmentNum; - } - out << "}"; + out << ", eventIdentifier: " << tokenData.eventIdentifier << "}"; return out; } @@ -167,14 +163,6 @@ ResumeToken::ResumeToken(const ResumeTokenData& data) { } data.eventIdentifier.addToBsonObj(&builder, ""); - if (data.fragmentNum) { - uassert(7182504, - str::stream() << "Tokens of version " << data.version - << " cannot have a fragmentNum", - data.version >= 2); - builder.appendNumber("", static_cast<long long>(*data.fragmentNum)); - } - auto keyObj = builder.obj(); KeyString::Builder encodedToken(KeyString::Version::V1, keyObj, Ordering::make(BSONObj())); _hexKeyString = hexblob::encode(encodedToken.getBuffer(), encodedToken.getSize()); @@ -297,38 +285,12 @@ ResumeTokenData ResumeToken::getData() const { "Resume Token eventIdentifier is not an object", result.eventIdentifier.getType() == BSONType::Object); - if (i.more() && result.version >= 2) { - auto fragmentNum = i.next(); - uassert(7182501, - "Resume token 'fragmentNum' must be a non-negative integer.", - fragmentNum.type() == BSONType::NumberInt && fragmentNum.numberInt() >= 0); - result.fragmentNum = fragmentNum.numberInt(); - } - uassert(40646, "invalid oversized resume token", !i.more()); return result; } -Document ResumeToken::toDocument(const SerializationOptions& options) const { - /* - * This is our default resume token for the representative query shape. - * We use a high water mark token, otherwise a resume event is expected when reparsing. - * When serializing the "_typeBits", we purposely avoid serializing with SerializationOptions, - * as this will result in mistakenly add '?undefined' to the Document. - * The serialization of the Document will typically exclude the "_typeBits" if they - * were unset, which is the case for "kDefaultToken". - */ - static const auto kDefaultToken = makeHighWaterMarkToken(Timestamp(), 0); - return Document{{kDataFieldName, - options.serializeLiteral(_hexKeyString, Value(kDefaultToken._hexKeyString))}, - {kTypeBitsFieldName, - options.literalPolicy != LiteralSerializationPolicy::kToDebugTypeString - ? options.serializeLiteral(_typeBits, kDefaultToken._typeBits) - : kDefaultToken._typeBits}}; -} - -BSONObj ResumeToken::toBSON(const SerializationOptions& options) const { - return toDocument(options).toBson(); +Document ResumeToken::toDocument() const { + return Document{{kDataFieldName, _hexKeyString}, {kTypeBitsFieldName, _typeBits}}; } ResumeToken ResumeToken::parse(const Document& resumeDoc) { |
