diff options
Diffstat (limited to 'src/mongo/db/exec/sbe/values/value_serialization_test.cpp')
| -rw-r--r-- | src/mongo/db/exec/sbe/values/value_serialization_test.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mongo/db/exec/sbe/values/value_serialization_test.cpp b/src/mongo/db/exec/sbe/values/value_serialization_test.cpp index 5b44bef6549..3be3212c627 100644 --- a/src/mongo/db/exec/sbe/values/value_serialization_test.cpp +++ b/src/mongo/db/exec/sbe/values/value_serialization_test.cpp @@ -268,6 +268,18 @@ TEST_F(ValueSerializeForKeyString, SbeArray) { runTest({{testDataTag, testDataVal}}); } +TEST_F(ValueSerializeForKeyString, ArraySet) { + auto [tag, val] = sbe::value::makeNewArraySet(); + sbe::value::ValueGuard guard{tag, val}; + auto* arraySet = sbe::value::getArraySetView(val); + + arraySet->push_back(value::TypeTags::NumberInt32, value::bitcastFrom<int32_t>(1)); + arraySet->push_back(value::TypeTags::NumberInt64, value::bitcastFrom<int64_t>(2)); + arraySet->push_back(value::TypeTags::NumberDouble, value::bitcastFrom<double>(3.0)); + + runTest({{tag, val}}); +} + TEST_F(ValueSerializeForKeyString, DateTime) { runTest({{value::TypeTags::Date, value::bitcastFrom<int64_t>(1234)}, {value::TypeTags::Timestamp, value::bitcastFrom<uint64_t>(5678)}}); @@ -442,4 +454,17 @@ TEST_F(ValueSerializeForKeyString, BsonCodeWScope) { runTest({{cwsTag1, cwsVal1}, {cwsTag2, cwsVal2}, {cwsTag3, cwsVal3}}); } + +// Test that roundtripping through KeyString works for a wide row. KeyStrings used in indexes are +// typically constrained in the number of components they can have, since we limit compound indexes +// to at most 32 components. But roundtripping rows wider than 32 still needs to work. +// +// This test was originally designed to reproduce SERVER-76321. +TEST_F(ValueSerializeForKeyString, RoundtripWideRow) { + std::vector<std::pair<sbe::value::TypeTags, sbe::value::Value>> row; + for (int32_t i = 0; i < 40; ++i) { + row.emplace_back(sbe::value::TypeTags::NumberInt32, sbe::value::bitcastFrom<int32_t>(i)); + } + runTest(row); +} } // namespace mongo::sbe |
