31 #include <wiredtiger.h> 33 #include "mongo/base/status_with.h" 43 class IndexCatalogEntry;
44 class IndexDescriptor;
45 struct WiredTigerItem;
76 const std::string& sysIndexConfig,
77 const std::string& collIndexConfig,
78 const IndexDescriptor&
desc,
85 static int Create(OperationContext*
opCtx,
const std::string&
uri,
const std::string& config);
88 const std::string&
uri,
89 const IndexDescriptor*
desc,
104 long long* numKeysOut,
107 BSONObjBuilder* output,
121 const std::string&
uri()
const {
155 virtual bool unique()
const = 0;
165 bool dupsAllowed) = 0;
171 bool dupsAllowed) = 0;
173 void setKey(WT_CURSOR* cursor,
const WT_ITEM* item);
176 class StandardBulkBuilder;
195 const std::string&
uri,
196 const IndexDescriptor*
desc,
198 bool readOnly =
false);
200 std::unique_ptr<SortedDataInterface::Cursor>
newCursor(OperationContext*
opCtx,
201 bool forward)
const override;
214 const RecordId&
id)
override;
220 bool dupsAllowed)
override;
238 bool dupsAllowed)
override;
259 const std::string&
uri,
260 const IndexDescriptor*
desc,
262 bool readOnly =
false);
264 std::unique_ptr<SortedDataInterface::Cursor>
newCursor(OperationContext*
opCtx,
265 bool forward)
const override;
281 bool dupsAllowed)
override;
287 bool dupsAllowed)
override;
Status dupKeyError(const BSONObj &key)
Definition: wiredtiger_index.cpp:129
void setKey(WT_CURSOR *cursor, const WT_ITEM *item)
Definition: wiredtiger_index.cpp:138
bool isTimestampSafeUniqueIdx() const override
Definition: wiredtiger_index.cpp:1245
Definition: wiredtiger_index.h:256
std::unique_ptr< SortedDataInterface::Cursor > newCursor(OperationContext *opCtx, bool forward) const override
Returns an unpositioned cursor over 'this' index.
Definition: wiredtiger_index.cpp:1614
virtual bool isDup(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id)
Definition: wiredtiger_index.cpp:504
std::string collectionNamespace() const
Definition: wiredtiger_index.h:143
bool isTimestampSafeUniqueIdx() const override
Definition: wiredtiger_index.h:273
Definition: record_store.h:673
bool _isIdIndex
Definition: wiredtiger_index.h:189
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
Status _insertTimestampUnsafe(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id, bool dupsAllowed)
Definition: wiredtiger_index.cpp:1323
std::unique_ptr< SortedDataInterface::Cursor > newCursor(OperationContext *opCtx, bool forward) const override
Returns an unpositioned cursor over 'this' index.
Definition: wiredtiger_index.cpp:1235
WiredTigerIndex(OperationContext *ctx, const std::string &uri, const IndexDescriptor *desc, KVPrefix prefix, bool readOnly)
Definition: wiredtiger_index.cpp:270
static StatusWith< std::string > generateCreateString(const std::string &engineName, const std::string &sysIndexConfig, const std::string &collIndexConfig, const IndexDescriptor &desc, bool isPrefixed)
Creates a configuration string suitable for 'config' parameter in WT_SESSION::create().
Definition: wiredtiger_index.cpp:195
virtual Status touch(OperationContext *opCtx) const
Attempt to bring the entirety of 'this' index into memory.
Definition: wiredtiger_index.cpp:455
static StatusWith< std::string > parseIndexOptions(const BSONObj &options)
Parses index options for wired tiger configuration string suitable for table creation.
Definition: wiredtiger_index.cpp:147
bool _partial
Definition: wiredtiger_index.h:253
Version
Selects version of KeyString to use.
Definition: key_string.h:52
BSONObj key
Definition: btree_interface.cpp:334
int _dataFormatVersion
Definition: wiredtiger_index.h:183
void _unindexTimestampUnsafe(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id, bool dupsAllowed)
Definition: wiredtiger_index.cpp:1463
WiredTigerIndexStandard(OperationContext *ctx, const std::string &uri, const IndexDescriptor *desc, KVPrefix prefix, bool readOnly=false)
Definition: wiredtiger_index.cpp:1607
KeyString::Version keyStringVersion() const
Definition: wiredtiger_index.h:139
Bulk builds a unique index.
Definition: wiredtiger_index.cpp:663
const std::string & uri() const
Definition: wiredtiger_index.h:121
SortedDataBuilderInterface * getBulkBuilder(OperationContext *opCtx, bool dupsAllowed) override
Return a bulk builder for 'this' index.
Definition: wiredtiger_index.cpp:1240
static int Create(OperationContext *opCtx, const std::string &uri, const std::string &config)
Creates a WiredTiger table suitable for implementing a MongoDB index.
Definition: wiredtiger_index.cpp:260
virtual bool isEmpty(OperationContext *opCtx)
Return true if 'this' index is empty, and false otherwise.
Definition: wiredtiger_index.cpp:435
virtual Status initAsEmpty(OperationContext *opCtx)
Definition: wiredtiger_index.cpp:536
bool unique() const override
Definition: wiredtiger_index.h:269
std::string indexName() const
Definition: wiredtiger_index.h:147
Status _insertTimestampSafe(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id, bool dupsAllowed)
Definition: wiredtiger_index.cpp:1388
std::string _collectionNamespace
Definition: wiredtiger_index.h:186
Status _insert(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id, bool dupsAllowed) override
Definition: wiredtiger_index.cpp:1312
static std::string generateAppMetadataString(const IndexDescriptor &desc)
Creates the "app_metadata" string for the index from the index descriptor, to be stored in WiredTiger...
Definition: wiredtiger_index.cpp:168
OperationContext Database StringData CollectionOptions bool const BSONObj &idIndex Status
Definition: database_impl.cpp:955
uint64_t tableId() const
Definition: wiredtiger_index.h:132
std::string _uri
Definition: wiredtiger_index.h:184
A version-hiding wrapper around the bulk builder for the Btree.
Definition: sorted_data_interface.h:394
std::string _indexName
Definition: wiredtiger_index.h:187
virtual void unindex(OperationContext *opCtx, const BSONObj &key, const RecordId &id, bool dupsAllowed)
Remove the entry from the index with the specified key and RecordId.
Definition: wiredtiger_index.cpp:325
Definition: index_key_validate.h:40
virtual Status _insert(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id, bool dupsAllowed)=0
virtual bool isTimestampSafeUniqueIdx() const =0
void _unindexTimestampSafe(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id, bool dupsAllowed)
Definition: wiredtiger_index.cpp:1569
virtual void _unindex(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id, bool dupsAllowed)=0
virtual bool unique() const =0
void _unindex(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id, bool dupsAllowed) override
Definition: wiredtiger_index.cpp:1452
Definition: wiredtiger_index.h:192
bool unique() const override
Definition: wiredtiger_index.h:205
Ordering ordering() const
Definition: wiredtiger_index.h:135
bool isIdIndex() const
Definition: wiredtiger_index.h:151
KVPrefix _prefix
Definition: wiredtiger_index.h:188
void _unindex(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id, bool dupsAllowed) override
Definition: wiredtiger_index.cpp:1654
virtual Status dupKeyCheck(OperationContext *opCtx, const BSONObj &key, const RecordId &id)
Return ErrorCodes::DuplicateKey if 'key' already exists in 'this' index at a RecordId other than 'loc...
Definition: wiredtiger_index.cpp:421
virtual void fullValidate(OperationContext *opCtx, long long *numKeysOut, ValidateResults *fullResults) const
TODO: expose full set of args for testing?
Definition: wiredtiger_index.cpp:341
virtual Status insert(OperationContext *opCtx, const BSONObj &key, const RecordId &id, bool dupsAllowed)
Insert an entry into the index with the specified key and RecordId.
Definition: wiredtiger_index.cpp:306
A KVPrefix may be prepended to the keys of entries in an underlying KV store.
Definition: kv_prefix.h:44
const Ordering _ordering
Definition: wiredtiger_index.h:177
WiredTigerIndexUnique(OperationContext *ctx, const std::string &uri, const IndexDescriptor *desc, KVPrefix prefix, bool readOnly=false)
Definition: wiredtiger_index.cpp:1228
Status _insert(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id, bool dupsAllowed) override
Definition: wiredtiger_index.cpp:1626
uint64_t _tableId
Definition: wiredtiger_index.h:185
virtual bool appendCustomStats(OperationContext *opCtx, BSONObjBuilder *output, double scale) const
Definition: wiredtiger_index.cpp:381
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
virtual Status compact(OperationContext *opCtx)
Attempt to reduce the storage space used by this index via compaction.
Definition: wiredtiger_index.cpp:541
OperationContext const IndexDescriptor * desc
Definition: index_catalog_impl.cpp:97
KeyString::Version _keyStringVersion
Definition: wiredtiger_index.h:182
SortedDataBuilderInterface * getBulkBuilder(OperationContext *opCtx, bool dupsAllowed) override
Return a bulk builder for 'this' index.
Definition: wiredtiger_index.cpp:1619
Definition: wiredtiger_index.h:47
bool isDup(OperationContext *opCtx, WT_CURSOR *c, const BSONObj &key, const RecordId &id) override
Definition: wiredtiger_index.cpp:1253
This interface is a work in progress.
Definition: sorted_data_interface.h:64
virtual long long getSpaceUsedBytes(OperationContext *opCtx) const
Return the number of bytes consumed by 'this' index.
Definition: wiredtiger_index.cpp:464