summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/key_string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/storage/key_string.cpp')
-rw-r--r--src/mongo/db/storage/key_string.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/mongo/db/storage/key_string.cpp b/src/mongo/db/storage/key_string.cpp
index 796995754ff..ec2dae09662 100644
--- a/src/mongo/db/storage/key_string.cpp
+++ b/src/mongo/db/storage/key_string.cpp
@@ -39,6 +39,7 @@
#include "mongo/base/data_cursor.h"
#include "mongo/base/data_view.h"
#include "mongo/bson/bson_depth.h"
+#include "mongo/db/exec/sbe/values/value_builder.h"
#include "mongo/platform/bits.h"
#include "mongo/platform/strnlen.h"
#include "mongo/util/decimal_counter.h"
@@ -1212,12 +1213,13 @@ void BuilderBase<BufferT>::_appendBytes(const void* source, size_t bytes, bool i
// ----------------------------------------------------------------------
namespace {
+template <class Stream>
void toBsonValue(uint8_t ctype,
BufReader* reader,
TypeBits::Reader* typeBits,
bool inverted,
Version version,
- BSONObjBuilderValueStream* stream,
+ Stream* stream,
uint32_t depth);
void toBson(BufReader* reader,
@@ -1276,12 +1278,13 @@ Decimal128 readDecimalContinuation(BufReader* reader, bool inverted, Decimal128
return num;
}
+template <class Stream>
void toBsonValue(uint8_t ctype,
BufReader* reader,
TypeBits::Reader* typeBits,
bool inverted,
Version version,
- BSONObjBuilderValueStream* stream,
+ Stream* stream,
uint32_t depth) {
keyStringAssert(ErrorCodes::Overflow,
"KeyString encoding exceeded maximum allowable BSON nesting depth",
@@ -2568,6 +2571,25 @@ int Value::compareWithTypeBits(const Value& other) const {
return KeyString::compare(getBuffer(), other.getBuffer(), _buffer.size(), other._buffer.size());
}
+bool readSBEValue(BufReader* reader,
+ TypeBits::Reader* typeBits,
+ bool inverted,
+ Version version,
+ sbe::value::ValueBuilder* valueBuilder) {
+ uint8_t ctype;
+ if (!reader->remaining() || (ctype = readType<uint8_t>(reader, inverted)) == kEnd) {
+ return false;
+ }
+
+ // This function is only intended to read stored index entries. The 'kLess' and 'kGreater'
+ // "discriminator" types are used for querying and are never stored in an index.
+ invariant(ctype > kLess && ctype < kGreater);
+
+ const uint32_t depth = 1; // This function only gets called for a top-level KeyString::Value.
+ toBsonValue(ctype, reader, typeBits, inverted, version, valueBuilder, depth);
+ return true;
+}
+
template class BuilderBase<Builder>;
template class BuilderBase<HeapBuilder>;
template class BuilderBase<PooledBuilder>;