summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackson Xie <jackson.xie@mongodb.com>2021-06-21 18:49:57 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-22 17:47:24 +0000
commit6d369b6416e0bed07ffe8098b2351e3d6bfaedd9 (patch)
tree7df904644196cb4d254326c4fa8421da25480b3f
parent0f191f938b5ad943212123a147646e957913ca04 (diff)
downloadmongo-6d369b6416e0bed07ffe8098b2351e3d6bfaedd9.tar.gz
SERVER-57643: Simple8b renaming and spec changes
-rw-r--r--src/mongo/bson/util/simple8b.cpp26
-rw-r--r--src/mongo/bson/util/simple8b.h3
-rw-r--r--src/mongo/bson/util/simple8b_test.cpp11
3 files changed, 21 insertions, 19 deletions
diff --git a/src/mongo/bson/util/simple8b.cpp b/src/mongo/bson/util/simple8b.cpp
index 741b0186593..ec5ac83aa53 100644
--- a/src/mongo/bson/util/simple8b.cpp
+++ b/src/mongo/bson/util/simple8b.cpp
@@ -32,7 +32,7 @@
namespace mongo {
namespace {
-static constexpr uint8_t _maxSelector = 14; // Change to 15 in SERVER-57794
+static constexpr uint8_t _maxSelector = 14; // TODO (SERVER-57794): Change to 15.
static constexpr uint8_t _minSelector = 1;
static constexpr uint64_t _selectorMask = 0x000000000000000F;
static constexpr uint8_t _selectorSize = 4;
@@ -50,18 +50,18 @@ constexpr uint8_t _selectorForIntegersCoded[16] = {
constexpr uint64_t _selectorForMask[16] = {0,
1,
2,
- (1 << 3) - 1,
- (1 << 4) - 1,
- (1 << 5) - 1,
- (1 << 6) - 1,
- (1 << 7) - 1,
- (1 << 8) - 1,
- (1 << 10) - 1,
- (1 << 12) - 1,
- (1 << 15) - 1,
- (1 << 20) - 1,
- (1 << 30) - 1,
- ((uint64_t)1 << 60) - 1,
+ (1ull << 3) - 1,
+ (1ull << 4) - 1,
+ (1ull << 5) - 1,
+ (1ull << 6) - 1,
+ (1ull << 7) - 1,
+ (1ull << 8) - 1,
+ (1ull << 10) - 1,
+ (1ull << 12) - 1,
+ (1ull << 15) - 1,
+ (1ull << 20) - 1,
+ (1ull << 30) - 1,
+ (1ull << 60) - 1,
1};
} // namespace
diff --git a/src/mongo/bson/util/simple8b.h b/src/mongo/bson/util/simple8b.h
index 19fec8e5937..42f6f89af55 100644
--- a/src/mongo/bson/util/simple8b.h
+++ b/src/mongo/bson/util/simple8b.h
@@ -41,7 +41,8 @@ namespace mongo {
*/
class Simple8b {
public:
- static const uint64_t errCode = 0x0000000000000000; // Temporary error code.
+ // TODO (SERVER-57724): Remove temporary error code.
+ static constexpr uint64_t errCode = 0x0000000000000000;
/**
* encodeSimple8b takes a selector and a vector of integers to be compressed into a 64 bit word.
diff --git a/src/mongo/bson/util/simple8b_test.cpp b/src/mongo/bson/util/simple8b_test.cpp
index f7e4dba9581..c7543bb3a39 100644
--- a/src/mongo/bson/util/simple8b_test.cpp
+++ b/src/mongo/bson/util/simple8b_test.cpp
@@ -34,7 +34,8 @@
using namespace mongo;
-void areVectorsEqual(std::vector<uint64_t> actualVector, std::vector<uint64_t> expectedVector) {
+void assertVectorsEqual(const std::vector<uint64_t>& actualVector,
+ const std::vector<uint64_t>& expectedVector) {
ASSERT_EQ(actualVector.size(), expectedVector.size());
for (unsigned i = 0; i < actualVector.size(); ++i) {
@@ -53,7 +54,7 @@ TEST(Simple8b, DecodeOneValueTest) {
uint64_t simple8bWord = 0x0000000000000001E;
std::vector<uint64_t> values = Simple8b::decodeSimple8b(simple8bWord);
std::vector<uint64_t> expectedValues = {1};
- areVectorsEqual(values, expectedValues);
+ assertVectorsEqual(values, expectedValues);
}
TEST(Simple8b, EncodeMultipleValuesTest) {
@@ -67,7 +68,7 @@ TEST(Simple8b, DecodeMultipleValuesTest) {
uint64_t simple8bWord = 0x000030000200001C;
std::vector<uint64_t> values = Simple8b::decodeSimple8b(simple8bWord);
std::vector<uint64_t> expectedValues = {1, 2, 3};
- areVectorsEqual(values, expectedValues);
+ assertVectorsEqual(values, expectedValues);
}
TEST(Simple8b, EncodeMaxValuesTest) {
@@ -81,7 +82,7 @@ TEST(Simple8b, DecodeMaxValuesTest) {
uint64_t simple8bWord = 0xFFFFFFFFFFFFFFF1;
std::vector<uint64_t> values = Simple8b::decodeSimple8b(simple8bWord);
std::vector<uint64_t> expectedValues(60, 1);
- areVectorsEqual(values, expectedValues);
+ assertVectorsEqual(values, expectedValues);
}
TEST(Simple8b, EncodeWithTrailingDirtyBitsTest) {
@@ -95,7 +96,7 @@ TEST(Simple8b, DecodeWithTrailingDirtyBitsTest) {
uint64_t simple8bWord = 0x0010101010101018;
std::vector<uint64_t> values = Simple8b::decodeSimple8b(simple8bWord);
std::vector<uint64_t> expectedValues(7, 1);
- areVectorsEqual(values, expectedValues);
+ assertVectorsEqual(values, expectedValues);
}
TEST(Simple8b, InvalidEncodeZeroSelectorTest) {