summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2018-11-30 15:44:58 -0500
committerGregory Wlodarek <gregory.wlodarek@mongodb.com>2018-12-03 17:02:24 -0500
commitf439d76860cf8307c5d6ba3fe421b8c88a7c3d8c (patch)
treea5f31e7082f791f622199bc6781a876ee86f795e /src/mongo
parent2c124b76e1d51a9427efffd804e3ca1cff6a1a11 (diff)
downloadmongo-f439d76860cf8307c5d6ba3fe421b8c88a7c3d8c.tar.gz
SERVER-38333 Support partial indexes in BiggieSE
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/storage/biggie/SConscript2
-rw-r--r--src/mongo/db/storage/biggie/biggie_sorted_impl.cpp30
-rw-r--r--src/mongo/db/storage/biggie/biggie_sorted_impl.h12
-rw-r--r--src/mongo/db/storage/biggie/biggie_sorted_impl_test.cpp26
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp2
-rw-r--r--src/mongo/db/storage/mobile/mobile_index_test.cpp2
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_bulkbuilder.cpp21
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_cursor.cpp14
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_cursor_advanceto.cpp36
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_cursor_end_position.cpp14
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_cursor_locate.cpp42
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_cursor_saverestore.cpp40
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_cursor_seek_exact.cpp8
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp12
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp3
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_harness.cpp49
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_harness.h5
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_insert.cpp26
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_isempty.cpp3
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_rollback.cpp6
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_spaceused.cpp6
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_touch.cpp6
-rw-r--r--src/mongo/db/storage/sorted_data_interface_test_unindex.cpp106
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp9
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp9
25 files changed, 378 insertions, 111 deletions
diff --git a/src/mongo/db/storage/biggie/SConscript b/src/mongo/db/storage/biggie/SConscript
index bc5cb1061c0..e7374e93868 100644
--- a/src/mongo/db/storage/biggie/SConscript
+++ b/src/mongo/db/storage/biggie/SConscript
@@ -64,6 +64,8 @@ env.CppUnitTest(
],
LIBDEPS=[
'storage_biggie_core',
+ '$BUILD_DIR/mongo/db/common',
+ '$BUILD_DIR/mongo/db/index/index_descriptor',
'$BUILD_DIR/mongo/db/storage/key_string',
'$BUILD_DIR/mongo/db/storage/sorted_data_interface_test_harness'
],
diff --git a/src/mongo/db/storage/biggie/biggie_sorted_impl.cpp b/src/mongo/db/storage/biggie/biggie_sorted_impl.cpp
index 76b09aba93b..f0a9485c773 100644
--- a/src/mongo/db/storage/biggie/biggie_sorted_impl.cpp
+++ b/src/mongo/db/storage/biggie/biggie_sorted_impl.cpp
@@ -262,7 +262,8 @@ SortedDataInterface::SortedDataInterface(OperationContext* opCtx,
_collectionNamespace(desc->parentNS()),
_indexName(desc->indexName()),
_keyPattern(desc->keyPattern()),
- _isUnique(desc->unique()) {
+ _isUnique(desc->unique()),
+ _isPartial(desc->isPartial()) {
// This is the string representation of the KeyString before elements in this ident, which is
// ident + \0. This is before all elements in this ident.
_KSForIdentStart = createKeyString(
@@ -276,7 +277,8 @@ SortedDataInterface::SortedDataInterface(const Ordering& ordering, bool isUnique
: _order(ordering),
_prefix(ident.toString().append(1, '\1')),
_identEnd(ident.toString().append(1, '\2')),
- _isUnique(isUnique) {
+ _isUnique(isUnique),
+ _isPartial(false) {
_KSForIdentStart = createKeyString(
BSONObj(), RecordId::min(), ident.toString().append(1, '\0'), _order, _isUnique);
_KSForIdentEnd = createKeyString(BSONObj(), RecordId::min(), _identEnd, _order, _isUnique);
@@ -375,6 +377,11 @@ void SortedDataInterface::unindex(OperationContext* opCtx,
removeKeyString = createKeyString(key, loc, _prefix, _order, /* isUnique */ false);
else
removeKeyString = createKeyString(key, loc, _prefix, _order, /* isUnique */ true);
+
+ // Check that the record id matches when using partial indexes. We may be called to unindex
+ // records that are not present in the index due to the partial filter expression.
+ if (!ifPartialCheckRecordIdEquals(opCtx, removeKeyString, loc))
+ return;
numErased = workingCopy->erase(removeKeyString);
if (numErased == 0) {
@@ -385,6 +392,9 @@ void SortedDataInterface::unindex(OperationContext* opCtx,
removeKeyString = createKeyString(key, loc, _prefix, _order, /* isUnique */ true);
else
removeKeyString = createKeyString(key, loc, _prefix, _order, /* isUnique */ false);
+
+ if (!ifPartialCheckRecordIdEquals(opCtx, removeKeyString, loc))
+ return;
numErased = workingCopy->erase(removeKeyString);
}
} else {
@@ -509,6 +519,22 @@ Status SortedDataInterface::initAsEmpty(OperationContext* opCtx) {
return Status::OK();
}
+bool SortedDataInterface::ifPartialCheckRecordIdEquals(OperationContext* opCtx,
+ const std::string key,
+ const RecordId rid) const {
+ if (!_isPartial)
+ return true;
+
+ StringStore* workingCopy(RecoveryUnit::get(opCtx)->getHead());
+ auto workingCopyIt = workingCopy->find(key);
+ if (workingCopyIt == workingCopy->end())
+ return true;
+
+ IndexKeyEntry entry =
+ keyStringToIndexKeyEntry(workingCopyIt->first, workingCopyIt->second, _order);
+ return entry.loc == rid;
+}
+
// Cursor
SortedDataInterface::Cursor::Cursor(OperationContext* opCtx,
bool isForward,
diff --git a/src/mongo/db/storage/biggie/biggie_sorted_impl.h b/src/mongo/db/storage/biggie/biggie_sorted_impl.h
index 220110bb1a5..0f9257aa0ba 100644
--- a/src/mongo/db/storage/biggie/biggie_sorted_impl.h
+++ b/src/mongo/db/storage/biggie/biggie_sorted_impl.h
@@ -173,6 +173,16 @@ public:
};
private:
+ /**
+ * Returns false only when the index is partial and the IndexKeyEntry's record id does not match
+ * the provided rid from the given key.
+ *
+ * Returns true in all other cases.
+ */
+ bool ifPartialCheckRecordIdEquals(OperationContext* opCtx,
+ const std::string key,
+ const RecordId rid) const;
+
const Ordering _order;
// These two are the same as before.
std::string _prefix;
@@ -186,6 +196,8 @@ private:
std::string _KSForIdentEnd;
// This stores whether or not the end position is inclusive.
bool _isUnique;
+ // Whether or not the index is partial
+ bool _isPartial;
};
} // namespace biggie
} // namespace mongo
diff --git a/src/mongo/db/storage/biggie/biggie_sorted_impl_test.cpp b/src/mongo/db/storage/biggie/biggie_sorted_impl_test.cpp
index d4b68da318e..cb4f4f2caa9 100644
--- a/src/mongo/db/storage/biggie/biggie_sorted_impl_test.cpp
+++ b/src/mongo/db/storage/biggie/biggie_sorted_impl_test.cpp
@@ -31,6 +31,7 @@
#include "mongo/platform/basic.h"
#include "mongo/base/init.h"
+#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/storage/biggie/biggie_kv_engine.h"
#include "mongo/db/storage/biggie/biggie_recovery_unit.h"
#include "mongo/db/storage/biggie/biggie_sorted_impl.h"
@@ -49,8 +50,29 @@ private:
public:
SortedDataInterfaceTestHarnessHelper() : _order(Ordering::make(BSONObj())) {}
- std::unique_ptr<mongo::SortedDataInterface> newSortedDataInterface(bool unique) final {
- return std::make_unique<SortedDataInterface>(_order, unique, "ident"_sd);
+ std::unique_ptr<mongo::SortedDataInterface> newSortedDataInterface(bool unique,
+ bool partial) final {
+ std::string ns = "test.biggie";
+ OperationContextNoop opCtx(newRecoveryUnit().release());
+
+ BSONObj spec = BSON("key" << BSON("a" << 1) << "name"
+ << "testIndex"
+ << "v"
+ << static_cast<int>(IndexDescriptor::kLatestIndexVersion)
+ << "ns"
+ << ns
+ << "unique"
+ << unique);
+ if (partial) {
+ auto partialBSON =
+ BSON(IndexDescriptor::kPartialFilterExprFieldName.toString() << BSON(""
+ << ""));
+ spec = spec.addField(partialBSON.firstElement());
+ }
+
+ IndexDescriptor desc(NULL, "", spec);
+
+ return std::make_unique<SortedDataInterface>(&opCtx, "ident"_sd, &desc);
}
std::unique_ptr<mongo::RecoveryUnit> newRecoveryUnit() final {
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp
index 19296045476..bc730000713 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp
@@ -45,7 +45,7 @@ class EphemeralForBtreeImplTestHarnessHelper final
public:
EphemeralForBtreeImplTestHarnessHelper() : _order(Ordering::make(BSONObj())) {}
- std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique) final {
+ std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique, bool partial) final {
return std::unique_ptr<SortedDataInterface>(getEphemeralForTestBtreeImpl(
_order, unique, "test.EphemeralForTest", "indexName", BSONObj(), &_data));
}
diff --git a/src/mongo/db/storage/mobile/mobile_index_test.cpp b/src/mongo/db/storage/mobile/mobile_index_test.cpp
index 310e4251a1c..f07e7e46828 100644
--- a/src/mongo/db/storage/mobile/mobile_index_test.cpp
+++ b/src/mongo/db/storage/mobile/mobile_index_test.cpp
@@ -55,7 +55,7 @@ public:
_sessionPool.reset(new MobileSessionPool(_fullPath));
}
- std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool isUnique) {
+ std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool isUnique, bool isPartial) {
std::string ident("index_" + std::to_string(inc++));
OperationContextNoop opCtx(newRecoveryUnit().release());
Status status = MobileIndex::create(&opCtx, ident);
diff --git a/src/mongo/db/storage/sorted_data_interface_test_bulkbuilder.cpp b/src/mongo/db/storage/sorted_data_interface_test_bulkbuilder.cpp
index 72ff41eff0e..813286cf410 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_bulkbuilder.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_bulkbuilder.cpp
@@ -43,7 +43,8 @@ namespace {
// Add a key using a bulk builder.
TEST(SortedDataInterface, BuilderAddKey) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -68,7 +69,8 @@ TEST(SortedDataInterface, BuilderAddKey) {
// Add a reserved RecordId using a bulk builder.
TEST(SortedDataInterface, BuilderAddKeyWithReservedRecordId) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
@@ -95,7 +97,8 @@ TEST(SortedDataInterface, BuilderAddKeyWithReservedRecordId) {
// Add a compound key using a bulk builder.
TEST(SortedDataInterface, BuilderAddCompoundKey) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -122,7 +125,8 @@ TEST(SortedDataInterface, BuilderAddCompoundKey) {
// not allowed.
TEST(SortedDataInterface, BuilderAddSameKey) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -149,7 +153,8 @@ TEST(SortedDataInterface, BuilderAddSameKey) {
// the returned status is OK when duplicates are allowed.
TEST(SortedDataInterface, BuilderAddSameKeyWithDupsAllowed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -175,7 +180,8 @@ TEST(SortedDataInterface, BuilderAddSameKeyWithDupsAllowed) {
// Add multiple keys using a bulk builder.
TEST(SortedDataInterface, BuilderAddMultipleKeys) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -202,7 +208,8 @@ TEST(SortedDataInterface, BuilderAddMultipleKeys) {
// Add multiple compound keys using a bulk builder.
TEST(SortedDataInterface, BuilderAddMultipleCompoundKeys) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
diff --git a/src/mongo/db/storage/sorted_data_interface_test_cursor.cpp b/src/mongo/db/storage/sorted_data_interface_test_cursor.cpp
index 9ad00610a75..59935a26c58 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_cursor.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_cursor.cpp
@@ -44,7 +44,8 @@ namespace {
// Verify that a forward cursor is positioned at EOF when the index is empty.
TEST(SortedDataInterface, CursorIsEOFWhenEmpty) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -65,7 +66,8 @@ TEST(SortedDataInterface, CursorIsEOFWhenEmpty) {
// Verify that a reverse cursor is positioned at EOF when the index is empty.
TEST(SortedDataInterface, CursorIsEOFWhenEmptyReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -88,7 +90,8 @@ TEST(SortedDataInterface, CursorIsEOFWhenEmptyReversed) {
// When a cursor positioned at EOF is advanced, it stays at EOF.
TEST(SortedDataInterface, ExhaustCursor) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -130,7 +133,8 @@ TEST(SortedDataInterface, ExhaustCursor) {
// When a cursor positioned at EOF is advanced, it stays at EOF.
TEST(SortedDataInterface, ExhaustCursorReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -172,7 +176,7 @@ TEST(SortedDataInterface, ExhaustCursorReversed) {
void testBoundaries(bool unique, bool forward, bool inclusive) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
const std::unique_ptr<SortedDataInterface> sorted(
- harnessHelper->newSortedDataInterface(unique));
+ harnessHelper->newSortedDataInterface(unique, /*partial=*/false));
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
diff --git a/src/mongo/db/storage/sorted_data_interface_test_cursor_advanceto.cpp b/src/mongo/db/storage/sorted_data_interface_test_cursor_advanceto.cpp
index b2ea89eeda1..f0f5532cb49 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_cursor_advanceto.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_cursor_advanceto.cpp
@@ -47,7 +47,8 @@ namespace {
// order by RecordId.
TEST(SortedDataInterface, AdvanceTo) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -102,7 +103,8 @@ TEST(SortedDataInterface, AdvanceTo) {
// order by RecordId (last occurrence in index order).
TEST(SortedDataInterface, AdvanceToReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -156,7 +158,8 @@ TEST(SortedDataInterface, AdvanceToReversed) {
// and should not be effected by current position.
TEST(SortedDataInterface, AdvanceToKeyBeforeCursorPosition) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -200,7 +203,8 @@ TEST(SortedDataInterface, AdvanceToKeyBeforeCursorPosition) {
// and should not be effected by current position.
TEST(SortedDataInterface, AdvanceToKeyAfterCursorPositionReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -247,7 +251,8 @@ TEST(SortedDataInterface, AdvanceToKeyAfterCursorPositionReversed) {
// position the cursor on the next position, which may be EOF.
TEST(SortedDataInterface, AdvanceToKeyAtCursorPosition) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -292,7 +297,8 @@ TEST(SortedDataInterface, AdvanceToKeyAtCursorPosition) {
// position the cursor on the next position, which may be EOF.
TEST(SortedDataInterface, AdvanceToKeyAtCursorPositionReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -337,7 +343,8 @@ TEST(SortedDataInterface, AdvanceToKeyAtCursorPositionReversed) {
// positioned at the key that comes after the one specified.
TEST(SortedDataInterface, AdvanceToExclusive) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -391,7 +398,8 @@ TEST(SortedDataInterface, AdvanceToExclusive) {
// positioned at the key that comes before the one specified.
TEST(SortedDataInterface, AdvanceToExclusiveReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -445,7 +453,8 @@ TEST(SortedDataInterface, AdvanceToExclusiveReversed) {
// exact key and the current position of the cursor.
TEST(SortedDataInterface, AdvanceToIndirect) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
BSONObj unusedKey = key6; // larger than any inserted key
@@ -495,7 +504,8 @@ TEST(SortedDataInterface, AdvanceToIndirect) {
// exact key and the current position of the cursor.
TEST(SortedDataInterface, AdvanceToIndirectReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
BSONObj unusedKey = key0; // smaller than any inserted key
@@ -548,7 +558,8 @@ TEST(SortedDataInterface, AdvanceToIndirectReversed) {
// that comes after the one specified.
TEST(SortedDataInterface, AdvanceToIndirectExclusive) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
BSONObj unusedKey = key6; // larger than any inserted key
@@ -605,7 +616,8 @@ TEST(SortedDataInterface, AdvanceToIndirectExclusive) {
// that comes before the one specified.
TEST(SortedDataInterface, AdvanceToIndirectExclusiveReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
BSONObj unusedKey = key0; // smaller than any inserted key
diff --git a/src/mongo/db/storage/sorted_data_interface_test_cursor_end_position.cpp b/src/mongo/db/storage/sorted_data_interface_test_cursor_end_position.cpp
index 8db0dcee9e0..14934bef7f1 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_cursor_end_position.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_cursor_end_position.cpp
@@ -43,6 +43,7 @@ void testSetEndPosition_Next_Forward(bool unique, bool inclusive) {
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(
unique,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key3, loc1}, {key4, loc1}, {key5, loc1},
});
@@ -82,6 +83,7 @@ void testSetEndPosition_Next_Reverse(bool unique, bool inclusive) {
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(
unique,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key3, loc1}, {key4, loc1}, {key5, loc1},
});
@@ -121,6 +123,7 @@ void testSetEndPosition_Seek_Forward(bool unique, bool inclusive) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(unique,
+ /*partial=*/false,
{
{key1, loc1},
// No key2
@@ -169,6 +172,7 @@ void testSetEndPosition_Seek_Reverse(bool unique, bool inclusive) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(unique,
+ /*partial=*/false,
{
{key1, loc1},
{key2, loc1},
@@ -219,6 +223,7 @@ void testSetEndPosition_Restore_Forward(bool unique) {
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(
unique,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key3, loc1}, {key4, loc1},
});
@@ -255,6 +260,7 @@ void testSetEndPosition_Restore_Reverse(bool unique) {
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(
unique,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key3, loc1}, {key4, loc1},
});
@@ -295,6 +301,7 @@ void testSetEndPosition_RestoreEndCursor_Forward(bool unique) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(unique,
+ /*partial=*/false,
{
{key1, loc1}, {key4, loc1},
});
@@ -329,6 +336,7 @@ void testSetEndPosition_RestoreEndCursor_Reverse(bool unique) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(unique,
+ /*partial=*/false,
{
{key1, loc1}, {key4, loc1},
});
@@ -365,6 +373,7 @@ void testSetEndPosition_Empty_Forward(bool unique, bool inclusive) {
auto opCtx = harnessHelper->newOperationContext();
auto sorted =
harnessHelper->newSortedDataInterface(unique,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key3, loc1},
});
@@ -395,6 +404,7 @@ void testSetEndPosition_Empty_Reverse(bool unique, bool inclusive) {
auto opCtx = harnessHelper->newOperationContext();
auto sorted =
harnessHelper->newSortedDataInterface(unique,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key3, loc1},
});
@@ -423,7 +433,8 @@ TEST(SortedDataInterface, SetEndPosition_Empty_Reverse_Standard_Exclusive) {
void testSetEndPosition_Character_Limits(bool unique, bool inclusive) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
- auto sorted = harnessHelper->newSortedDataInterface(unique, {{key7, loc1}, {key8, loc1}});
+ auto sorted = harnessHelper->newSortedDataInterface(
+ unique, /*partial=*/false, {{key7, loc1}, {key8, loc1}});
auto cursor = sorted->newCursor(opCtx.get());
cursor->setEndPosition(key7, inclusive);
@@ -460,5 +471,6 @@ TEST(SortedDataInterface, SetEndPosition_Character_Limits_Standard_Inclusive) {
TEST(SortedDataInterface, SetEndPosition_Character_Limits_Standard_Exclusive) {
testSetEndPosition_Character_Limits(false, false);
}
+
} // namespace
} // namespace mongo
diff --git a/src/mongo/db/storage/sorted_data_interface_test_cursor_locate.cpp b/src/mongo/db/storage/sorted_data_interface_test_cursor_locate.cpp
index 8498b1b2b7a..8cc38703e84 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_cursor_locate.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_cursor_locate.cpp
@@ -44,7 +44,8 @@ namespace {
// by specifying its exact key and RecordId.
TEST(SortedDataInterface, Locate) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -74,7 +75,8 @@ TEST(SortedDataInterface, Locate) {
// by specifying its exact key and RecordId.
TEST(SortedDataInterface, LocateReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -106,7 +108,8 @@ TEST(SortedDataInterface, LocateReversed) {
// by specifying its exact key and RecordId.
TEST(SortedDataInterface, LocateCompoundKey) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -136,7 +139,8 @@ TEST(SortedDataInterface, LocateCompoundKey) {
// by specifying its exact key and RecordId.
TEST(SortedDataInterface, LocateCompoundKeyReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -168,7 +172,8 @@ TEST(SortedDataInterface, LocateCompoundKeyReversed) {
// by specifying their exact key and RecordId.
TEST(SortedDataInterface, LocateMultiple) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -223,7 +228,8 @@ TEST(SortedDataInterface, LocateMultiple) {
// by specifying their exact key and RecordId.
TEST(SortedDataInterface, LocateMultipleReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -281,7 +287,8 @@ TEST(SortedDataInterface, LocateMultipleReversed) {
// by specifying their exact key and RecordId.
TEST(SortedDataInterface, LocateMultipleCompoundKeys) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -337,7 +344,8 @@ TEST(SortedDataInterface, LocateMultipleCompoundKeys) {
// by specifying their exact key and RecordId.
TEST(SortedDataInterface, LocateMultipleCompoundKeysReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -396,7 +404,8 @@ TEST(SortedDataInterface, LocateMultipleCompoundKeysReversed) {
// by specifying either a smaller key or RecordId.
TEST(SortedDataInterface, LocateIndirect) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -446,7 +455,8 @@ TEST(SortedDataInterface, LocateIndirect) {
// by specifying either a larger key or RecordId.
TEST(SortedDataInterface, LocateIndirectReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -499,7 +509,8 @@ TEST(SortedDataInterface, LocateIndirectReversed) {
// by specifying either a smaller key or RecordId.
TEST(SortedDataInterface, LocateIndirectCompoundKeys) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -551,7 +562,8 @@ TEST(SortedDataInterface, LocateIndirectCompoundKeys) {
// by specifying either a larger key or RecordId.
TEST(SortedDataInterface, LocateIndirectCompoundKeysReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -607,7 +619,8 @@ TEST(SortedDataInterface, LocateIndirectCompoundKeysReversed) {
// is positioned at EOF.
TEST(SortedDataInterface, LocateEmpty) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -627,7 +640,8 @@ TEST(SortedDataInterface, LocateEmpty) {
// is positioned at EOF.
TEST(SortedDataInterface, LocateEmptyReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
diff --git a/src/mongo/db/storage/sorted_data_interface_test_cursor_saverestore.cpp b/src/mongo/db/storage/sorted_data_interface_test_cursor_saverestore.cpp
index 2f460f3896d..15c559736fe 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_cursor_saverestore.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_cursor_saverestore.cpp
@@ -45,7 +45,8 @@ namespace {
// restorePosition() in succession.
TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursor) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -90,7 +91,8 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursor) {
// restorePosition() in succession.
TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -137,7 +139,8 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorReversed) {
// as part of the current position of the cursor.
TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorWithDupKeys) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -182,7 +185,8 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorWithDupKeys) {
// as part of the current position of the cursor.
TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorWithDupKeysReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -226,7 +230,8 @@ TEST(SortedDataInterface, SaveAndRestorePositionWhileIterateCursorWithDupKeysRev
// May be useful to run this test under valgrind to verify there are no leaks.
TEST(SortedDataInterface, SavePositionWithoutRestore) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -258,7 +263,8 @@ TEST(SortedDataInterface, SavePositionWithoutRestore) {
// May be useful to run this test under valgrind to verify there are no leaks.
TEST(SortedDataInterface, SavePositionWithoutRestoreReversed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -293,6 +299,7 @@ void testSaveAndRestorePositionSeesNewInserts(bool forward, bool unique) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(unique,
+ /*partial=*/false,
{
{key1, loc1}, {key3, loc1},
});
@@ -327,6 +334,7 @@ void testSaveAndRestorePositionSeesNewInsertsAfterRemove(bool forward, bool uniq
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(unique,
+ /*partial=*/false,
{
{key1, loc1}, {key3, loc1},
});
@@ -366,7 +374,8 @@ TEST(SortedDataInterface, SaveAndRestorePositionSeesNewInsertsAfterRemove_Revers
void testSaveAndRestorePositionSeesNewInsertsAfterEOF(bool forward, bool unique) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
- auto sorted = harnessHelper->newSortedDataInterface(false,
+ auto sorted = harnessHelper->newSortedDataInterface(/*unique=*/false,
+ /*partial=*/false,
{
{key1, loc1},
});
@@ -407,7 +416,8 @@ TEST(SortedDataInterface, SaveAndRestorePositionStandardIndexConsidersRecordId_F
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted =
- harnessHelper->newSortedDataInterface(/*isUnique*/ false,
+ harnessHelper->newSortedDataInterface(/*unique*/ false,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key3, loc1},
});
@@ -447,7 +457,9 @@ TEST(SortedDataInterface, SaveAndRestorePositionUniqueIndexWontReturnDupKeys_For
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(
- /*isUnique*/ true, {{key1, loc1}, {key2, loc2}, {key3, loc2}, {key4, loc2}});
+ /*unique*/ true,
+ /*partial=*/false,
+ {{key1, loc1}, {key2, loc2}, {key3, loc2}, {key4, loc2}});
auto cursor = sorted->newCursor(opCtx.get());
@@ -487,7 +499,8 @@ TEST(SortedDataInterface, SaveAndRestorePositionStandardIndexConsidersRecordId_R
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted =
- harnessHelper->newSortedDataInterface(/*isUnique*/ false,
+ harnessHelper->newSortedDataInterface(/*unique*/ false,
+ /*partial=*/false,
{
{key0, loc1}, {key1, loc1}, {key2, loc2},
});
@@ -527,7 +540,9 @@ TEST(SortedDataInterface, SaveAndRestorePositionUniqueIndexWontReturnDupKeys_Rev
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(
- /*isUnique*/ true, {{key1, loc1}, {key2, loc1}, {key3, loc1}, {key4, loc2}});
+ /*unique*/ true,
+ /*partial=*/false,
+ {{key1, loc1}, {key2, loc1}, {key3, loc1}, {key4, loc2}});
auto cursor = sorted->newCursor(opCtx.get(), false);
@@ -567,7 +582,8 @@ TEST(SortedDataInterface, SaveUnpositionedAndRestore) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted =
- harnessHelper->newSortedDataInterface(false,
+ harnessHelper->newSortedDataInterface(/*unique=*/false,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key3, loc1},
});
diff --git a/src/mongo/db/storage/sorted_data_interface_test_cursor_seek_exact.cpp b/src/mongo/db/storage/sorted_data_interface_test_cursor_seek_exact.cpp
index bae070849e5..1067981c845 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_cursor_seek_exact.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_cursor_seek_exact.cpp
@@ -43,6 +43,7 @@ void testSeekExact_Hit(bool unique, bool forward) {
auto opCtx = harnessHelper->newOperationContext();
auto sorted =
harnessHelper->newSortedDataInterface(unique,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key3, loc1},
});
@@ -74,6 +75,7 @@ void testSeekExact_Miss(bool unique, bool forward) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(unique,
+ /*partial=*/false,
{
{key1, loc1},
// No key2.
@@ -107,7 +109,8 @@ TEST(SortedDataInterface, SeekExact_HitWithDups_Forward) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(
- false,
+ /*unique=*/false,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key2, loc2}, {key3, loc1},
});
@@ -126,7 +129,8 @@ TEST(SortedDataInterface, SeekExact_HitWithDups_Reverse) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
auto opCtx = harnessHelper->newOperationContext();
auto sorted = harnessHelper->newSortedDataInterface(
- false,
+ /*unique=*/false,
+ /*partial=*/false,
{
{key1, loc1}, {key2, loc1}, {key2, loc2}, {key3, loc1},
});
diff --git a/src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp b/src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp
index e384f3d8a7c..95e0cf6b149 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp
@@ -45,7 +45,8 @@ namespace {
// pair that was inserted, it should still return an OK status.
TEST(SortedDataInterface, DupKeyCheckAfterInsert) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -81,7 +82,8 @@ TEST(SortedDataInterface, DupKeyCheckAfterInsert) {
// not exist in the index.
TEST(SortedDataInterface, DupKeyCheckEmpty) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -102,7 +104,8 @@ TEST(SortedDataInterface, DupKeyCheckEmpty) {
// when the insert key is located at a RecordId that comes after the one specified.
TEST(SortedDataInterface, DupKeyCheckWhenDiskLocBefore) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -137,7 +140,8 @@ TEST(SortedDataInterface, DupKeyCheckWhenDiskLocBefore) {
// when the insert key is located at a RecordId that comes before the one specified.
TEST(SortedDataInterface, DupKeyCheckWhenDiskLocAfter) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
diff --git a/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp b/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp
index 79a7a7af0af..bb9e85578bb 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp
@@ -44,7 +44,8 @@ namespace {
// the `numKeysOut` as the number of entries in the index, or as -1.
TEST(SortedDataInterface, FullValidate) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
diff --git a/src/mongo/db/storage/sorted_data_interface_test_harness.cpp b/src/mongo/db/storage/sorted_data_interface_test_harness.cpp
index 82f763ea7ce..20f0e90c2b9 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_harness.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_harness.cpp
@@ -39,12 +39,12 @@
#include "mongo/unittest/unittest.h"
auto mongo::SortedDataInterfaceHarnessHelper::newSortedDataInterface(
- bool unique, std::initializer_list<IndexKeyEntry> toInsert)
+ bool unique, bool partial, std::initializer_list<IndexKeyEntry> toInsert)
-> std::unique_ptr<SortedDataInterface> {
invariant(std::is_sorted(
toInsert.begin(), toInsert.end(), IndexEntryComparison(Ordering::make(BSONObj()))));
- auto index = newSortedDataInterface(unique);
+ auto index = newSortedDataInterface(unique, partial);
insertToIndex(this, index, toInsert);
return index;
}
@@ -74,7 +74,8 @@ namespace {
TEST(SortedDataInterface, InsertWithDups1) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -106,7 +107,8 @@ TEST(SortedDataInterface, InsertWithDups1) {
TEST(SortedDataInterface, InsertWithDups2) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -134,7 +136,8 @@ TEST(SortedDataInterface, InsertWithDups2) {
TEST(SortedDataInterface, InsertWithDups3AndRollback) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -162,7 +165,8 @@ TEST(SortedDataInterface, InsertWithDups3AndRollback) {
TEST(SortedDataInterface, InsertNoDups1) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -190,7 +194,8 @@ TEST(SortedDataInterface, InsertNoDups1) {
TEST(SortedDataInterface, InsertNoDups2) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -218,7 +223,8 @@ TEST(SortedDataInterface, InsertNoDups2) {
TEST(SortedDataInterface, Unindex1) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -283,7 +289,8 @@ TEST(SortedDataInterface, Unindex1) {
TEST(SortedDataInterface, Unindex2Rollback) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -318,7 +325,8 @@ TEST(SortedDataInterface, Unindex2Rollback) {
TEST(SortedDataInterface, CursorIterate1) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
int N = 5;
for (int i = 0; i < N; i++) {
@@ -344,7 +352,8 @@ TEST(SortedDataInterface, CursorIterate1) {
TEST(SortedDataInterface, CursorIterate1WithSaveRestore) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
int N = 5;
for (int i = 0; i < N; i++) {
@@ -373,7 +382,8 @@ TEST(SortedDataInterface, CursorIterate1WithSaveRestore) {
TEST(SortedDataInterface, CursorIterateAllDupKeysWithSaveRestore) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
int N = 5;
for (int i = 0; i < N; i++) {
@@ -402,7 +412,8 @@ TEST(SortedDataInterface, CursorIterateAllDupKeysWithSaveRestore) {
TEST(SortedDataInterface, Locate1) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
BSONObj key = BSON("" << 1);
RecordId loc(5, 16);
@@ -431,7 +442,8 @@ TEST(SortedDataInterface, Locate1) {
TEST(SortedDataInterface, Locate2) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -457,7 +469,8 @@ TEST(SortedDataInterface, Locate2) {
TEST(SortedDataInterface, Locate2Empty) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -488,7 +501,8 @@ TEST(SortedDataInterface, Locate2Empty) {
TEST(SortedDataInterface, Locate3Descending) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
auto buildEntry = [](int i) { return IndexKeyEntry(BSON("" << i), RecordId(1, i * 2)); };
@@ -531,7 +545,8 @@ TEST(SortedDataInterface, Locate3Descending) {
TEST(SortedDataInterface, Locate4) {
const auto harnessHelper = newSortedDataInterfaceHarnessHelper();
- auto sorted = harnessHelper->newSortedDataInterface(false,
+ auto sorted = harnessHelper->newSortedDataInterface(/*unique=*/false,
+ /*partial=*/false,
{
{BSON("" << 1), RecordId(1, 2)},
{BSON("" << 1), RecordId(1, 4)},
diff --git a/src/mongo/db/storage/sorted_data_interface_test_harness.h b/src/mongo/db/storage/sorted_data_interface_test_harness.h
index 6f3124dabc6..c045d3fa8f5 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_harness.h
+++ b/src/mongo/db/storage/sorted_data_interface_test_harness.h
@@ -90,7 +90,8 @@ class RecoveryUnit;
class SortedDataInterfaceHarnessHelper : public virtual HarnessHelper {
public:
- virtual std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique) = 0;
+ virtual std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique,
+ bool partial) = 0;
/**
* Creates a new SDI with some initial data.
@@ -98,7 +99,7 @@ public:
* For clarity to readers, toInsert must be sorted.
*/
std::unique_ptr<SortedDataInterface> newSortedDataInterface(
- bool unique, std::initializer_list<IndexKeyEntry> toInsert);
+ bool unique, bool partial, std::initializer_list<IndexKeyEntry> toInsert);
};
/**
diff --git a/src/mongo/db/storage/sorted_data_interface_test_insert.cpp b/src/mongo/db/storage/sorted_data_interface_test_insert.cpp
index 7ccb0c766c6..be700463fdf 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_insert.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_insert.cpp
@@ -43,7 +43,8 @@ namespace {
// Insert a key and verify that the number of entries in the index equals 1.
TEST(SortedDataInterface, Insert) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -68,7 +69,8 @@ TEST(SortedDataInterface, Insert) {
// Insert a compound key and verify that the number of entries in the index equals 1.
TEST(SortedDataInterface, InsertCompoundKey) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -95,7 +97,8 @@ TEST(SortedDataInterface, InsertCompoundKey) {
// when duplicates are not allowed.
TEST(SortedDataInterface, InsertSameDiskLoc) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -137,7 +140,8 @@ TEST(SortedDataInterface, InsertSameDiskLoc) {
// when duplicates are allowed.
TEST(SortedDataInterface, InsertSameDiskLocWithDupsAllowed) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -178,7 +182,8 @@ TEST(SortedDataInterface, InsertSameDiskLocWithDupsAllowed) {
// in the index when duplicates are not allowed.
TEST(SortedDataInterface, InsertSameKey) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -225,7 +230,7 @@ void _testInsertSameKeyWithDupsAllowed(const RecordId locs[3]) {
for (int keeper = 0; keeper < 3; keeper++) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
const std::unique_ptr<SortedDataInterface> sorted(
- harnessHelper->newSortedDataInterface(true));
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(
@@ -287,7 +292,8 @@ TEST(SortedDataInterface, InsertSameKeyWithDupsAllowedLocsDescending) {
// in the index equals the number that were inserted.
TEST(SortedDataInterface, InsertMultiple) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -328,7 +334,8 @@ TEST(SortedDataInterface, InsertMultiple) {
// in the index equals the number that were inserted.
TEST(SortedDataInterface, InsertMultipleCompoundKeys) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -369,7 +376,8 @@ TEST(SortedDataInterface, InsertMultipleCompoundKeys) {
TEST(SortedDataInterface, InsertReservedRecordId) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
ASSERT(sorted->isEmpty(opCtx.get()));
WriteUnitOfWork uow(opCtx.get());
diff --git a/src/mongo/db/storage/sorted_data_interface_test_isempty.cpp b/src/mongo/db/storage/sorted_data_interface_test_isempty.cpp
index 7f1edc8f69d..8bd6b65e29b 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_isempty.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_isempty.cpp
@@ -45,7 +45,8 @@ namespace {
// when that is unindex.
TEST(SortedDataInterface, IsEmpty) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
diff --git a/src/mongo/db/storage/sorted_data_interface_test_rollback.cpp b/src/mongo/db/storage/sorted_data_interface_test_rollback.cpp
index e647e85bd67..e7d4b0a6173 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_rollback.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_rollback.cpp
@@ -44,7 +44,8 @@ namespace {
// on the WriteUnitOfWork causes the changes to not become visible.
TEST(SortedDataInterface, InsertWithoutCommit) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -86,7 +87,8 @@ TEST(SortedDataInterface, InsertWithoutCommit) {
// not become visible.
TEST(SortedDataInterface, UnindexWithoutCommit) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
diff --git a/src/mongo/db/storage/sorted_data_interface_test_spaceused.cpp b/src/mongo/db/storage/sorted_data_interface_test_spaceused.cpp
index 1d64d80f4a5..808f040bdb4 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_spaceused.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_spaceused.cpp
@@ -43,7 +43,8 @@ namespace {
// Verify that an empty index takes up no space.
TEST(SortedDataInterface, GetSpaceUsedBytesEmpty) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -62,7 +63,8 @@ TEST(SortedDataInterface, GetSpaceUsedBytesEmpty) {
// Verify that a nonempty index takes up some space.
TEST(SortedDataInterface, GetSpaceUsedBytesNonEmpty) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
diff --git a/src/mongo/db/storage/sorted_data_interface_test_touch.cpp b/src/mongo/db/storage/sorted_data_interface_test_touch.cpp
index e6ce1b7da47..1eb4ce7a6f2 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_touch.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_touch.cpp
@@ -43,7 +43,8 @@ namespace {
// Verify that calling touch() on an empty index returns an OK status.
TEST(SortedDataInterface, TouchEmpty) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -55,7 +56,8 @@ TEST(SortedDataInterface, TouchEmpty) {
// Verify that calling touch() on a nonempty index returns an OK status.
TEST(SortedDataInterface, TouchNonEmpty) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(true));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
diff --git a/src/mongo/db/storage/sorted_data_interface_test_unindex.cpp b/src/mongo/db/storage/sorted_data_interface_test_unindex.cpp
index 87cd89c38a7..1dfb23ef550 100644
--- a/src/mongo/db/storage/sorted_data_interface_test_unindex.cpp
+++ b/src/mongo/db/storage/sorted_data_interface_test_unindex.cpp
@@ -41,9 +41,10 @@ namespace mongo {
namespace {
// Insert a key and verify that it can be unindexed.
-TEST(SortedDataInterface, Unindex) {
+void unindex(bool partial) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, partial));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -80,10 +81,19 @@ TEST(SortedDataInterface, Unindex) {
}
}
+TEST(SortedDataInterface, Unindex) {
+ unindex(false);
+}
+
+TEST(SortedDataInterface, UnindexPartial) {
+ unindex(true);
+}
+
// Insert a compound key and verify that it can be unindexed.
-TEST(SortedDataInterface, UnindexCompoundKey) {
+void unindexCompoundKey(bool partial) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, partial));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -120,10 +130,19 @@ TEST(SortedDataInterface, UnindexCompoundKey) {
}
}
+TEST(SortedDataInterface, UnindexCompoundKey) {
+ unindexCompoundKey(false);
+}
+
+TEST(SortedDataInterface, UnindexCompoundKeyPartial) {
+ unindexCompoundKey(true);
+}
+
// Insert multiple, distinct keys and verify that they can be unindexed.
-TEST(SortedDataInterface, UnindexMultipleDistinct) {
+void unindexMultipleDistinct(bool partial) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, partial));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -192,10 +211,19 @@ TEST(SortedDataInterface, UnindexMultipleDistinct) {
}
}
+TEST(SortedDataInterface, UnindexMultipleDistinct) {
+ unindexMultipleDistinct(false);
+}
+
+TEST(SortedDataInterface, UnindexMultipleDistinctPartial) {
+ unindexMultipleDistinct(true);
+}
+
// Insert the same key multiple times and verify that each occurrence can be unindexed.
-TEST(SortedDataInterface, UnindexMultipleSameKey) {
+void unindexMultipleSameKey(bool partial) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, partial));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -264,10 +292,20 @@ TEST(SortedDataInterface, UnindexMultipleSameKey) {
}
}
+
+TEST(SortedDataInterface, UnindexMultipleSameKey) {
+ unindexMultipleSameKey(false);
+}
+
+TEST(SortedDataInterface, UnindexMultipleSameKeyPartial) {
+ unindexMultipleSameKey(true);
+}
+
// Call unindex() on a nonexistent key and verify the result is false.
-TEST(SortedDataInterface, UnindexEmpty) {
+void unindexEmpty(bool partial) {
const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
- const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/false, partial));
{
const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
@@ -285,5 +323,53 @@ TEST(SortedDataInterface, UnindexEmpty) {
}
}
+TEST(SortedDataInterface, UnindexEmpty) {
+ unindexEmpty(false);
+}
+
+TEST(SortedDataInterface, UnindexEmptyPartial) {
+ unindexEmpty(true);
+}
+
+// Test partial indexing and unindexing.
+TEST(SortedDataInterface, PartialIndex) {
+ const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
+ const std::unique_ptr<SortedDataInterface> sorted(
+ harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/true));
+
+ {
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
+ ASSERT(sorted->isEmpty(opCtx.get()));
+ }
+
+ {
+ const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
+ {
+ {
+ WriteUnitOfWork uow(opCtx.get());
+ ASSERT_OK(sorted->insert(opCtx.get(), key1, loc1, true));
+ // Assume key1 with loc2 was never indexed due to the partial index.
+ ASSERT_EQUALS(1, sorted->numEntries(opCtx.get()));
+ uow.commit();
+ }
+
+ {
+ WriteUnitOfWork uow(opCtx.get());
+ // Shouldn't unindex anything as key1 with loc2 wasn't indexed in the first place.
+ sorted->unindex(opCtx.get(), key1, loc2, true);
+ ASSERT_EQUALS(1, sorted->numEntries(opCtx.get()));
+ uow.commit();
+ }
+
+ {
+ WriteUnitOfWork uow(opCtx.get());
+ sorted->unindex(opCtx.get(), key1, loc1, true);
+ ASSERT(sorted->isEmpty(opCtx.get()));
+ uow.commit();
+ }
+ }
+ }
+}
+
} // namespace
} // namespace mongo
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp
index 404b9d0f631..d6e2af60630 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp
@@ -69,7 +69,7 @@ public:
_conn->close(_conn, NULL);
}
- std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique) final {
+ std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique, bool partial) final {
std::string ns = "test.wt";
OperationContextNoop opCtx(newRecoveryUnit().release());
@@ -82,6 +82,13 @@ public:
<< "unique"
<< unique);
+ if (partial) {
+ auto partialBSON =
+ BSON(IndexDescriptor::kPartialFilterExprFieldName.toString() << BSON(""
+ << ""));
+ spec = spec.addField(partialBSON.firstElement());
+ }
+
IndexDescriptor desc(NULL, "", spec);
KVPrefix prefix = KVPrefix::generateNextPrefix();
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
index 770baf4d1b7..0078021ff21 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
@@ -69,7 +69,7 @@ public:
_conn->close(_conn, NULL);
}
- std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique) final {
+ std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique, bool partial) final {
std::string ns = "test.wt";
OperationContextNoop opCtx(newRecoveryUnit().release());
@@ -82,6 +82,13 @@ public:
<< "unique"
<< unique);
+ if (partial) {
+ auto partialBSON =
+ BSON(IndexDescriptor::kPartialFilterExprFieldName.toString() << BSON(""
+ << ""));
+ spec = spec.addField(partialBSON.firstElement());
+ }
+
IndexDescriptor desc(NULL, "", spec);
KVPrefix prefix = KVPrefix::kNotPrefixed;