diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2019-07-17 09:20:36 -0400 |
---|---|---|
committer | Gregory Noma <gregory.noma@gmail.com> | 2019-07-17 09:20:36 -0400 |
commit | 18da05b7e79beb6c6eb68c82d94d2f76003d9f8d (patch) | |
tree | d4ec21f409fd827117d9c598ac5af9e1ef748a4b /src/mongo/db/storage/sorted_data_interface.h | |
parent | 8696830b93eaea25cb8573a3b63db52d283933da (diff) | |
download | mongo-18da05b7e79beb6c6eb68c82d94d2f76003d9f8d.tar.gz |
SERVER-41719 Overload SortedDataInterface::insert, unindex, and addKey to accept KeyString
Diffstat (limited to 'src/mongo/db/storage/sorted_data_interface.h')
-rw-r--r-- | src/mongo/db/storage/sorted_data_interface.h | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/mongo/db/storage/sorted_data_interface.h b/src/mongo/db/storage/sorted_data_interface.h index dd1fcdbd803..d2c3608a073 100644 --- a/src/mongo/db/storage/sorted_data_interface.h +++ b/src/mongo/db/storage/sorted_data_interface.h @@ -35,6 +35,7 @@ #include "mongo/db/operation_context.h" #include "mongo/db/record_id.h" #include "mongo/db/storage/index_entry_comparison.h" +#include "mongo/db/storage/key_string.h" #pragma once @@ -52,6 +53,9 @@ struct ValidateResults; */ class SortedDataInterface { public: + SortedDataInterface(KeyString::Version keyStringVersion, Ordering ordering) + : _keyStringVersion(keyStringVersion), _ordering(ordering) {} + virtual ~SortedDataInterface() {} // @@ -91,6 +95,23 @@ public: bool dupsAllowed) = 0; /** + * Insert an entry into the index with the specified KeyString and RecordId. + * + * @param opCtx the transaction under which the insert takes place + * @param dupsAllowed true if duplicate keys are allowed, and false + * otherwise + * + * @return Status::OK() if the insert succeeded, + * + * ErrorCodes::DuplicateKey if 'keyString' already exists in 'this' index + * at a RecordId other than 'loc' and duplicates were not allowed + */ + virtual Status insert(OperationContext* opCtx, + const KeyString::Builder& keyString, + const RecordId& loc, + bool dupsAllowed) = 0; + + /** * Remove the entry from the index with the specified key and RecordId. * * @param opCtx the transaction under which the remove takes place @@ -103,6 +124,18 @@ public: bool dupsAllowed) = 0; /** + * Remove the entry from the index with the specified KeyString and RecordId. + * + * @param opCtx the transaction under which the remove takes place + * @param dupsAllowed true if duplicate keys are allowed, and false + * otherwise + */ + virtual void unindex(OperationContext* opCtx, + const KeyString::Builder& keyString, + const RecordId& loc, + bool dupsAllowed) = 0; + + /** * Return ErrorCodes::DuplicateKey if there is more than one occurence of 'key' in this index, * and Status::OK() otherwise. This call is only allowed on a unique index, and will invariant * otherwise. @@ -174,6 +207,20 @@ public: return x; } + /* + * Return the KeyString version for 'this' index. + */ + KeyString::Version getKeyStringVersion() const { + return _keyStringVersion; + } + + /* + * Return the ordering for 'this' index. + */ + Ordering getOrdering() const { + return _ordering; + } + /** * Navigates over the sorted data. * @@ -354,6 +401,10 @@ public: // virtual Status initAsEmpty(OperationContext* opCtx) = 0; + +protected: + const KeyString::Version _keyStringVersion; + const Ordering _ordering; }; /** @@ -364,12 +415,13 @@ public: virtual ~SortedDataBuilderInterface() {} /** - * Adds 'key' to intermediate storage. + * Adds 'key' or 'keyString' to intermediate storage. * * 'key' must be > or >= the last key passed to this function (depends on _dupsAllowed). If * this is violated an error Status (ErrorCodes::InternalError) will be returned. */ virtual Status addKey(const BSONObj& key, const RecordId& loc) = 0; + virtual Status addKey(const KeyString::Builder& keyString, const RecordId& loc) = 0; /** * Do any necessary work to finish building the tree. |