summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishnu Kaushik <vishnu.kaushik@mongodb.com>2020-09-01 18:32:08 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-02 17:19:49 +0000
commit9ede1ee4cca29667ec90e8e3cdcfd5399a3fd303 (patch)
treef84053c9c9dd0f330d65cf18a61ffb2854d551ba
parent261e6666abccebaf183dd419820f1a843d97b40a (diff)
downloadmongo-9ede1ee4cca29667ec90e8e3cdcfd5399a3fd303.tar.gz
SERVER-50234 delete the unused function toBsonWithSafeDiscriminator
-rw-r--r--src/mongo/db/storage/key_string.cpp70
-rw-r--r--src/mongo/db/storage/key_string.h4
2 files changed, 0 insertions, 74 deletions
diff --git a/src/mongo/db/storage/key_string.cpp b/src/mongo/db/storage/key_string.cpp
index ab5b518202d..30025e8ea7d 100644
--- a/src/mongo/db/storage/key_string.cpp
+++ b/src/mongo/db/storage/key_string.cpp
@@ -2382,76 +2382,6 @@ size_t getKeySize(const char* buffer, size_t len, Ordering ord, const TypeBits&
return (len - (remainingBytes - 1));
}
-// Unlike toBsonSafe(), this function will convert the discriminator byte back.
-// This discriminator byte only exists in KeyStrings for queries, not in KeyStrings stored in an
-// index. This function is only used by EphemeralForTest because it uses BSON with discriminator
-// rather than KeyString to compare.
-BSONObj toBsonSafeWithDiscriminator(const char* buffer,
- size_t len,
- Ordering ord,
- const TypeBits& typeBits) {
- boost::optional<std::string> discriminatorFieldName;
- int fieldNo = -1; // Record which field should add the discriminator field name.
-
- // First pass, get the discriminator byte if there is any.
- {
- BSONObjBuilder builder;
- BufReader reader(buffer, len);
- TypeBits::Reader typeBitsReader(typeBits);
- for (int i = 0; reader.remaining(); i++) {
- const bool invert = (ord.get(i) == -1);
- uint8_t ctype = readType<uint8_t>(&reader, invert);
- if (ctype == kLess || ctype == kGreater) {
- // Discriminator byte should not be inverted. It's possible when `ord` has more
- // fields than keystring and `invert` got mistakenly applied to discriminator byte.
- if (invert)
- ctype = ~ctype; // Invert it back.
- discriminatorFieldName = ctype == kLess ? "l" : "g";
- fieldNo = i - 1;
- ctype = readType<uint8_t>(&reader, false);
- invariant(ctype == kEnd);
- }
-
- if (ctype == kEnd) {
- break;
- }
-
- toBsonValue(
- ctype, &reader, &typeBitsReader, invert, typeBits.version, &(builder << ""), 1);
- }
- // Early return if there is no discriminator byte.
- if (!discriminatorFieldName)
- return builder.obj();
- }
-
- // Second pass, add discriminator byte as the fieldName.
- {
- BSONObjBuilder builder;
- BufReader reader(buffer, len);
- TypeBits::Reader typeBitsReader(typeBits);
- for (int i = 0; reader.remaining(); i++) {
- const bool invert = (ord.get(i) == -1);
- uint8_t ctype = readType<uint8_t>(&reader, invert);
- if (ctype == kLess || ctype == kGreater) {
- // Invert it back if discriminator byte got mistakenly inverted.
- if (invert)
- ctype = ~ctype;
- ctype = readType<uint8_t>(&reader, false);
- invariant(ctype == kEnd);
- }
-
- if (ctype == kEnd) {
- break;
- }
-
- auto fn = i == fieldNo ? discriminatorFieldName.get() : "";
- toBsonValue(
- ctype, &reader, &typeBitsReader, invert, typeBits.version, &(builder << fn), 1);
- }
- return builder.obj();
- }
-}
-
// This discriminator byte only exists in KeyStrings for queries, not in KeyStrings stored in an
// index.
Discriminator decodeDiscriminator(const char* buffer,
diff --git a/src/mongo/db/storage/key_string.h b/src/mongo/db/storage/key_string.h
index b516533f596..bc49042d172 100644
--- a/src/mongo/db/storage/key_string.h
+++ b/src/mongo/db/storage/key_string.h
@@ -935,10 +935,6 @@ size_t getKeySize(const char* buffer, size_t len, Ordering ord, const TypeBits&
BSONObj toBson(StringData data, Ordering ord, const TypeBits& types);
BSONObj toBson(const char* buffer, size_t len, Ordering ord, const TypeBits& types) noexcept;
BSONObj toBsonSafe(const char* buffer, size_t len, Ordering ord, const TypeBits& types);
-BSONObj toBsonSafeWithDiscriminator(const char* buffer,
- size_t len,
- Ordering ord,
- const TypeBits& typeBits);
Discriminator decodeDiscriminator(const char* buffer,
size_t len,
Ordering ord,