summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/ephemeral_for_test
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2015-11-16 15:08:15 -0500
committerDavid Storch <david.storch@10gen.com>2015-11-17 15:43:20 -0500
commit009268e918a1e08d611daad34ec94fa5a351db60 (patch)
tree23d534eea2fbec3a9efaa8768635560591cc2f83 /src/mongo/db/storage/ephemeral_for_test
parent7d0ad1d8e1f4ba8e5b81b0242aae8bd5744530da (diff)
downloadmongo-009268e918a1e08d611daad34ec94fa5a351db60.tar.gz
SERVER-21403 plumb flag indicating whether or not index is unique down to MMAPv1 BtreeLogic
Includes similar plumbing for the ephemeralForTest storage engine. WiredTiger integration layer changes are unnecessary since WT index cursors are already unique-aware.
Diffstat (limited to 'src/mongo/db/storage/ephemeral_for_test')
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp13
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h1
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp3
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp3
4 files changed, 13 insertions, 7 deletions
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp
index 0029b05374d..75df462418a 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp
@@ -138,7 +138,7 @@ private:
class EphemeralForTestBtreeImpl : public SortedDataInterface {
public:
- EphemeralForTestBtreeImpl(IndexSet* data) : _data(data) {
+ EphemeralForTestBtreeImpl(IndexSet* data, bool isUnique) : _data(data), _isUnique(isUnique) {
_currentKeySize = 0;
}
@@ -224,8 +224,8 @@ public:
class Cursor final : public SortedDataInterface::Cursor {
public:
- Cursor(OperationContext* txn, const IndexSet& data, bool isForward)
- : _txn(txn), _data(data), _forward(isForward), _it(data.end()) {}
+ Cursor(OperationContext* txn, const IndexSet& data, bool isForward, bool isUnique)
+ : _txn(txn), _data(data), _forward(isForward), _isUnique(isUnique), _it(data.end()) {}
boost::optional<IndexKeyEntry> next(RequestedInfo parts) override {
if (_lastMoveWasRestore) {
@@ -425,6 +425,7 @@ public:
OperationContext* _txn; // not owned
const IndexSet& _data;
const bool _forward;
+ const bool _isUnique;
bool _isEOF = true;
IndexSet::const_iterator _it;
@@ -449,7 +450,7 @@ public:
virtual std::unique_ptr<SortedDataInterface::Cursor> newCursor(OperationContext* txn,
bool isForward) const {
- return stdx::make_unique<Cursor>(txn, *_data, isForward);
+ return stdx::make_unique<Cursor>(txn, *_data, isForward, _isUnique);
}
virtual Status initAsEmpty(OperationContext* txn) {
@@ -479,18 +480,20 @@ private:
IndexSet* _data;
long long _currentKeySize;
+ const bool _isUnique;
};
} // namespace
// IndexCatalogEntry argument taken by non-const pointer for consistency with other Btree
// factories. We don't actually modify it.
SortedDataInterface* getEphemeralForTestBtreeImpl(const Ordering& ordering,
+ bool isUnique,
std::shared_ptr<void>* dataInOut) {
invariant(dataInOut);
if (!*dataInOut) {
*dataInOut = std::make_shared<IndexSet>(IndexEntryComparison(ordering));
}
- return new EphemeralForTestBtreeImpl(static_cast<IndexSet*>(dataInOut->get()));
+ return new EphemeralForTestBtreeImpl(static_cast<IndexSet*>(dataInOut->get()), isUnique);
}
} // namespace mongo
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h
index 6e19eb4c945..9d44e3e80cd 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h
@@ -42,6 +42,7 @@ class IndexCatalogEntry;
* All permanent data will be stored and fetch from dataInOut.
*/
SortedDataInterface* getEphemeralForTestBtreeImpl(const Ordering& ordering,
+ bool isUnique,
std::shared_ptr<void>* dataInOut);
} // namespace mongo
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 f5d5a8dca3c..5a91de906f2 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
@@ -43,7 +43,8 @@ public:
EphemeralForTestHarnessHelper() : _order(Ordering::make(BSONObj())) {}
std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique) final {
- return std::unique_ptr<SortedDataInterface>(getEphemeralForTestBtreeImpl(_order, &_data));
+ return std::unique_ptr<SortedDataInterface>(
+ getEphemeralForTestBtreeImpl(_order, unique, &_data));
}
std::unique_ptr<RecoveryUnit> newRecoveryUnit() final {
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp
index dad8c56e408..6f0cd2cbaae 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp
@@ -76,7 +76,8 @@ SortedDataInterface* EphemeralForTestEngine::getSortedDataInterface(OperationCon
StringData ident,
const IndexDescriptor* desc) {
stdx::lock_guard<stdx::mutex> lk(_mutex);
- return getEphemeralForTestBtreeImpl(Ordering::make(desc->keyPattern()), &_dataMap[ident]);
+ return getEphemeralForTestBtreeImpl(
+ Ordering::make(desc->keyPattern()), desc->unique(), &_dataMap[ident]);
}
Status EphemeralForTestEngine::dropIdent(OperationContext* opCtx, StringData ident) {