38 #include "mongo/platform/basic.h" 52 const RecordId& recId,
53 bool dupsAllowed)
override;
55 void unindex(OperationContext* opCtx,
57 const RecordId& recId,
58 bool dupsAllowed)
override;
61 long long* numKeysOut,
65 BSONObjBuilder* output,
66 double scale)
const override;
70 long long numEntries(OperationContext* opCtx)
const override;
72 bool isEmpty(OperationContext* opCtx)
override;
76 Status dupKeyCheck(OperationContext* opCtx,
const BSONObj& key,
const RecordId& recId)
override;
83 static Status create(OperationContext* opCtx,
const std::string& ident);
88 template <
typename ValueType>
91 const ValueType& value,
92 bool isTransactional =
true);
111 bool _isDup(OperationContext* opCtx,
const BSONObj& key, RecordId recId);
127 const RecordId& recId,
128 bool dupsAllowed) = 0;
130 virtual void _unindex(OperationContext* opCtx,
132 const RecordId& recId,
133 bool dupsAllowed) = 0;
148 const IndexDescriptor*
desc,
149 const std::string& ident);
155 std::unique_ptr<SortedDataInterface::Cursor>
newCursor(OperationContext* opCtx,
156 bool isForward)
const override;
161 const RecordId& recId,
162 bool dupsAllowed)
override;
164 void _unindex(OperationContext* opCtx,
166 const RecordId& recId,
167 bool dupsAllowed)
override;
173 const IndexDescriptor*
desc,
174 const std::string& ident);
180 std::unique_ptr<SortedDataInterface::Cursor>
newCursor(OperationContext* opCtx,
181 bool isForward)
const override;
186 const RecordId& recId,
187 bool dupsAllowed)
override;
189 void _unindex(OperationContext* opCtx,
191 const RecordId& recId,
192 bool dupsAllowed)
override;
194 const bool _isPartial =
false;
virtual std::unique_ptr< Cursor > newCursor(OperationContext *opCtx, bool isForward=true) const =0
Returns an unpositioned cursor over 'this' index.
Bulk builds a unique index.
Definition: mobile_index.cpp:367
Status dupKeyCheck(OperationContext *opCtx, const BSONObj &key, const RecordId &recId) override
Return ErrorCodes::DuplicateKey if 'key' already exists in 'this' index at a RecordId other than 'loc...
Definition: mobile_index.cpp:241
Definition: record_store.h:671
const bool _isUnique
Definition: mobile_index.h:137
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
static Status create(OperationContext *opCtx, const std::string &ident)
Creates a SQLite table suitable for a new Mobile index.
Definition: mobile_index.cpp:231
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
Definition: key_string.h:47
Definition: mobile_index.cpp:297
Version
Selects version of KeyString to use.
Definition: key_string.h:52
BSONObj key
Definition: btree_interface.cpp:334
virtual Status _insert(OperationContext *opCtx, const BSONObj &key, const RecordId &recId, bool dupsAllowed)=0
const Ordering _ordering
Definition: mobile_index.h:140
static const Version kLatestVersion
Provides the latest version of KeyString available.
Definition: key_string.h:60
const KeyString::Version _keyStringVersion
Definition: mobile_index.h:141
void unindex(OperationContext *opCtx, const BSONObj &key, const RecordId &recId, bool dupsAllowed) override
Remove the entry from the index with the specified key and RecordId.
Definition: mobile_index.cpp:135
bool _isDup(OperationContext *opCtx, const BSONObj &key, RecordId recId)
Definition: mobile_index.cpp:252
virtual SortedDataBuilderInterface * getBulkBuilder(OperationContext *opCtx, bool dupsAllowed)=0
Return a bulk builder for 'this' index.
Status doInsert(OperationContext *opCtx, const KeyString &key, const ValueType &value, bool isTransactional=true)
Performs the insert into the table with the given key and value.
Definition: mobile_index.cpp:98
static Status _checkKeySize(const BSONObj &key)
Checks if key size is too long.
Definition: mobile_index.cpp:290
Definition: mobile_index.h:170
bool isEmpty(OperationContext *opCtx) override
Return true if 'this' index is empty, and false otherwise.
Definition: mobile_index.cpp:213
A version-hiding wrapper around the bulk builder for the Btree.
Definition: sorted_data_interface.h:394
KeyString::Version getKeyStringVersion() const
Definition: mobile_index.h:98
void fullValidate(OperationContext *opCtx, long long *numKeysOut, ValidateResults *fullResults) const override
Note: this validates the entire database file, not just the table used by this index.
Definition: mobile_index.cpp:166
MobileIndex(OperationContext *opCtx, const IndexDescriptor *desc, const std::string &ident)
Definition: mobile_index.cpp:74
Ordering getOrdering() const
Definition: mobile_index.h:94
long long getSpaceUsedBytes(OperationContext *opCtx) const override
Return the number of bytes consumed by 'this' index.
Definition: mobile_index.cpp:186
virtual void _unindex(OperationContext *opCtx, const BSONObj &key, const RecordId &recId, bool dupsAllowed)=0
Bulk builds a non-unique index.
Definition: mobile_index.cpp:351
Definition: mobile_index.h:42
bool isUnique()
Definition: mobile_index.h:102
std::string getIdent() const
Definition: mobile_index.h:106
Status insert(OperationContext *opCtx, const BSONObj &key, const RecordId &recId, bool dupsAllowed) override
Insert an entry into the index with the specified key and RecordId.
Definition: mobile_index.cpp:82
Definition: mobile_index.h:145
bool appendCustomStats(OperationContext *opCtx, BSONObjBuilder *output, double scale) const override
Definition: mobile_index.cpp:180
const std::string _ident
Definition: mobile_index.h:142
long long numEntries(OperationContext *opCtx) const override
Return the number of entries in 'this' index.
Definition: mobile_index.cpp:203
virtual ~MobileIndex()
Definition: mobile_index.h:48
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
void _doDelete(OperationContext *opCtx, const KeyString &key, KeyString *value=nullptr)
Performs the deletion from the table matching the given key.
Definition: mobile_index.cpp:145
OperationContext const IndexDescriptor * desc
Definition: index_catalog_impl.cpp:97
Status _dupKeyError(const BSONObj &key)
Definition: mobile_index.cpp:282
This interface is a work in progress.
Definition: sorted_data_interface.h:64
Status initAsEmpty(OperationContext *opCtx) override
Definition: mobile_index.cpp:226