summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/sbe/values/value.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/exec/sbe/values/value.h')
-rw-r--r--src/mongo/db/exec/sbe/values/value.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/mongo/db/exec/sbe/values/value.h b/src/mongo/db/exec/sbe/values/value.h
index e783c7f4641..e4fdb27d510 100644
--- a/src/mongo/db/exec/sbe/values/value.h
+++ b/src/mongo/db/exec/sbe/values/value.h
@@ -32,6 +32,7 @@
#include <absl/container/flat_hash_map.h>
#include <absl/container/flat_hash_set.h>
#include <array>
+#include <bitset>
#include <cstdint>
#include <ostream>
#include <string>
@@ -40,6 +41,7 @@
#include "mongo/base/data_type_endian.h"
#include "mongo/base/data_view.h"
+#include "mongo/bson/ordering.h"
#include "mongo/platform/decimal128.h"
#include "mongo/util/assert_util.h"
@@ -58,6 +60,8 @@ namespace sbe {
using FrameId = int64_t;
using SpoolId = int64_t;
+using IndexKeysInclusionSet = std::bitset<Ordering::kMaxCompoundIndexKeys>;
+
namespace value {
/**
@@ -462,15 +466,22 @@ inline std::string_view getStringView(TypeTags tag, Value& val) noexcept {
MONGO_UNREACHABLE;
}
+inline std::pair<TypeTags, Value> makeSmallString(std::string_view input) {
+ size_t len = input.size();
+ invariant(len < kSmallStringThreshold - 1);
+
+ Value smallString;
+ // This is OK - we are aliasing to char*.
+ auto stringAlias = getSmallStringView(smallString);
+ memcpy(stringAlias, input.data(), len);
+ stringAlias[len] = 0;
+ return {TypeTags::StringSmall, smallString};
+}
+
inline std::pair<TypeTags, Value> makeNewString(std::string_view input) {
size_t len = input.size();
if (len < kSmallStringThreshold - 1) {
- Value smallString;
- // This is OK - we are aliasing to char*.
- auto stringAlias = getSmallStringView(smallString);
- memcpy(stringAlias, input.data(), len);
- stringAlias[len] = 0;
- return {TypeTags::StringSmall, smallString};
+ return makeSmallString(input);
} else {
auto str = new char[len + 1];
memcpy(str, input.data(), len);