diff options
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_index.h')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_index.h | 278 |
1 files changed, 138 insertions, 140 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.h b/src/mongo/db/storage/wiredtiger/wiredtiger_index.h index c2b3d42538f..1d61b2b3c9e 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.h @@ -37,156 +37,154 @@ namespace mongo { - class IndexCatalogEntry; - class IndexDescriptor; - struct WiredTigerItem; - - class WiredTigerIndex : public SortedDataInterface { - public: - - /** - * Parses index options for wired tiger configuration string suitable for table creation. - * The document 'options' is typically obtained from the 'storageEngine.wiredTiger' field - * of an IndexDescriptor's info object. - */ - static StatusWith<std::string> parseIndexOptions(const BSONObj& options); - - /** - * Creates a configuration string suitable for 'config' parameter in WT_SESSION::create(). - * Configuration string is constructed from: - * built-in defaults - * 'extraConfig' - * storageEngine.wiredTiger.configString in index descriptor's info object. - * Performs simple validation on the supplied parameters. - * Returns error status if validation fails. - * Note that even if this function returns an OK status, WT_SESSION:create() may still - * fail with the constructed configuration string. - */ - static StatusWith<std::string> generateCreateString(const std::string& extraConfig, - const IndexDescriptor& desc); - - /** - * Creates a WiredTiger table suitable for implementing a MongoDB index. - * 'config' should be created with generateCreateString(). - */ - static int Create(OperationContext* txn, +class IndexCatalogEntry; +class IndexDescriptor; +struct WiredTigerItem; + +class WiredTigerIndex : public SortedDataInterface { +public: + /** + * Parses index options for wired tiger configuration string suitable for table creation. + * The document 'options' is typically obtained from the 'storageEngine.wiredTiger' field + * of an IndexDescriptor's info object. + */ + static StatusWith<std::string> parseIndexOptions(const BSONObj& options); + + /** + * Creates a configuration string suitable for 'config' parameter in WT_SESSION::create(). + * Configuration string is constructed from: + * built-in defaults + * 'extraConfig' + * storageEngine.wiredTiger.configString in index descriptor's info object. + * Performs simple validation on the supplied parameters. + * Returns error status if validation fails. + * Note that even if this function returns an OK status, WT_SESSION:create() may still + * fail with the constructed configuration string. + */ + static StatusWith<std::string> generateCreateString(const std::string& extraConfig, + const IndexDescriptor& desc); + + /** + * Creates a WiredTiger table suitable for implementing a MongoDB index. + * 'config' should be created with generateCreateString(). + */ + static int Create(OperationContext* txn, const std::string& uri, const std::string& config); + + /** + * @param unique - If this is a unique index. + * Note: even if unique, it may be allowed ot be non-unique at times. + */ + WiredTigerIndex(OperationContext* ctx, const std::string& uri, const IndexDescriptor* desc); + + virtual Status insert(OperationContext* txn, + const BSONObj& key, + const RecordId& loc, + bool dupsAllowed); + + virtual void unindex(OperationContext* txn, + const BSONObj& key, + const RecordId& loc, + bool dupsAllowed); + + virtual void fullValidate(OperationContext* txn, + bool full, + long long* numKeysOut, + BSONObjBuilder* output) const; + virtual bool appendCustomStats(OperationContext* txn, + BSONObjBuilder* output, + double scale) const; + virtual Status dupKeyCheck(OperationContext* txn, const BSONObj& key, const RecordId& loc); + + virtual bool isEmpty(OperationContext* txn); + + virtual long long getSpaceUsedBytes(OperationContext* txn) const; + + bool isDup(WT_CURSOR* c, const BSONObj& key, const RecordId& loc); + + virtual Status initAsEmpty(OperationContext* txn); + + const std::string& uri() const { + return _uri; + } + + uint64_t instanceId() const { + return _instanceId; + } + Ordering ordering() const { + return _ordering; + } + + virtual bool unique() const = 0; + + Status dupKeyError(const BSONObj& key); + +protected: + virtual Status _insert(WT_CURSOR* c, + const BSONObj& key, + const RecordId& loc, + bool dupsAllowed) = 0; + + virtual void _unindex(WT_CURSOR* c, + const BSONObj& key, + const RecordId& loc, + bool dupsAllowed) = 0; + + class BulkBuilder; + class StandardBulkBuilder; + class UniqueBulkBuilder; + + const Ordering _ordering; + std::string _uri; + uint64_t _instanceId; + std::string _collectionNamespace; + std::string _indexName; +}; + + +class WiredTigerIndexUnique : public WiredTigerIndex { +public: + WiredTigerIndexUnique(OperationContext* ctx, const std::string& uri, - const std::string& config); + const IndexDescriptor* desc); - /** - * @param unique - If this is a unique index. - * Note: even if unique, it may be allowed ot be non-unique at times. - */ - WiredTigerIndex(OperationContext* ctx, - const std::string& uri, - const IndexDescriptor* desc); + std::unique_ptr<SortedDataInterface::Cursor> newCursor(OperationContext* txn, + bool forward) const override; - virtual Status insert(OperationContext* txn, - const BSONObj& key, - const RecordId& loc, - bool dupsAllowed); + SortedDataBuilderInterface* getBulkBuilder(OperationContext* txn, bool dupsAllowed) override; - virtual void unindex(OperationContext* txn, - const BSONObj& key, - const RecordId& loc, - bool dupsAllowed); + bool unique() const override { + return true; + } - virtual void fullValidate(OperationContext* txn, bool full, long long *numKeysOut, - BSONObjBuilder* output) const; - virtual bool appendCustomStats(OperationContext* txn, BSONObjBuilder* output, double scale) - const; - virtual Status dupKeyCheck(OperationContext* txn, const BSONObj& key, const RecordId& loc); + Status _insert(WT_CURSOR* c, + const BSONObj& key, + const RecordId& loc, + bool dupsAllowed) override; - virtual bool isEmpty(OperationContext* txn); + void _unindex(WT_CURSOR* c, const BSONObj& key, const RecordId& loc, bool dupsAllowed) override; +}; - virtual long long getSpaceUsedBytes( OperationContext* txn ) const; +class WiredTigerIndexStandard : public WiredTigerIndex { +public: + WiredTigerIndexStandard(OperationContext* ctx, + const std::string& uri, + const IndexDescriptor* desc); - bool isDup(WT_CURSOR *c, const BSONObj& key, const RecordId& loc ); + std::unique_ptr<SortedDataInterface::Cursor> newCursor(OperationContext* txn, + bool forward) const override; - virtual Status initAsEmpty(OperationContext* txn); + SortedDataBuilderInterface* getBulkBuilder(OperationContext* txn, bool dupsAllowed) override; - const std::string& uri() const { return _uri; } + bool unique() const override { + return false; + } - uint64_t instanceId() const { return _instanceId; } - Ordering ordering() const { return _ordering; } + Status _insert(WT_CURSOR* c, + const BSONObj& key, + const RecordId& loc, + bool dupsAllowed) override; - virtual bool unique() const = 0; + void _unindex(WT_CURSOR* c, const BSONObj& key, const RecordId& loc, bool dupsAllowed) override; +}; - Status dupKeyError(const BSONObj& key); - - protected: - - virtual Status _insert( WT_CURSOR* c, - const BSONObj& key, - const RecordId& loc, - bool dupsAllowed ) = 0; - - virtual void _unindex( WT_CURSOR* c, - const BSONObj& key, - const RecordId& loc, - bool dupsAllowed ) = 0; - - class BulkBuilder; - class StandardBulkBuilder; - class UniqueBulkBuilder; - - const Ordering _ordering; - std::string _uri; - uint64_t _instanceId; - std::string _collectionNamespace; - std::string _indexName; - }; - - - class WiredTigerIndexUnique : public WiredTigerIndex { - public: - WiredTigerIndexUnique( OperationContext* ctx, - const std::string& uri, - const IndexDescriptor* desc ); - - std::unique_ptr<SortedDataInterface::Cursor> newCursor(OperationContext* txn, - bool forward) const override; - - SortedDataBuilderInterface* getBulkBuilder(OperationContext* txn, - bool dupsAllowed) override; - - bool unique() const override { return true; } - - Status _insert(WT_CURSOR* c, - const BSONObj& key, - const RecordId& loc, - bool dupsAllowed) override; - - void _unindex(WT_CURSOR* c, - const BSONObj& key, - const RecordId& loc, - bool dupsAllowed) override; - }; - - class WiredTigerIndexStandard : public WiredTigerIndex { - public: - WiredTigerIndexStandard( OperationContext* ctx, - const std::string& uri, - const IndexDescriptor* desc ); - - std::unique_ptr<SortedDataInterface::Cursor> newCursor(OperationContext* txn, - bool forward) const override; - - SortedDataBuilderInterface* getBulkBuilder(OperationContext* txn, - bool dupsAllowed) override; - - bool unique() const override { return false; } - - Status _insert(WT_CURSOR* c, - const BSONObj& key, - const RecordId& loc, - bool dupsAllowed) override; - - void _unindex(WT_CURSOR* c, - const BSONObj& key, - const RecordId& loc, - bool dupsAllowed) override; - - }; - -} // namespace +} // namespace |