diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2020-07-15 14:45:50 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-15 22:31:52 +0000 |
commit | 8dd68436b1347849877b013face3184565615636 (patch) | |
tree | 429518548c711686365d93b1477ac6235a8ed6a6 /src/mongo/db/storage/key_string.cpp | |
parent | eaaee39e2c4eaf9938c5a75bce30648435ae10cc (diff) | |
download | mongo-8dd68436b1347849877b013face3184565615636.tar.gz |
SERVER-49351 Implement readKeyStringValueIntoAccessors()
This unreverts commit 0daf2a1c327da1af9c53009cca44a6597373c482
Diffstat (limited to 'src/mongo/db/storage/key_string.cpp')
-rw-r--r-- | src/mongo/db/storage/key_string.cpp | 26 |
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>; |