29 #include <boost/optional/optional.hpp> 30 #include <boost/optional/optional_io.hpp> 33 #include "mongo/db/jsobj.h" 34 #include "mongo/db/operation_context.h" 35 #include "mongo/db/record_id.h" 43 class BucketDeletionNotification;
44 class SortedDataBuilderInterface;
45 struct ValidateResults;
85 bool dupsAllowed) = 0;
102 bool dupsAllowed) = 0;
111 virtual void unindex(OperationContext* opCtx,
114 bool dupsAllowed) = 0;
126 const RecordId& loc) = 0;
144 long long* numKeysOut,
148 BSONObjBuilder* output,
149 double scale)
const = 0;
164 virtual bool isEmpty(OperationContext* opCtx) = 0;
175 return Status(ErrorCodes::CommandNotSupported,
176 "this storage engine does not support touch");
185 virtual long long numEntries(OperationContext* opCtx)
const {
277 virtual boost::optional<IndexKeyEntry>
seek(
const BSONObj& key,
295 virtual boost::optional<IndexKeyEntry>
seekExact(
const BSONObj& key,
298 if (kv && kv->key.woCompare(key, BSONObj(),
false) == 0)
314 virtual void save() = 0;
363 virtual std::unique_ptr<Cursor>
newCursor(OperationContext* opCtx,
364 bool isForward =
true)
const = 0;
404 virtual Status addKey(
const BSONObj&
key,
const RecordId& loc) = 0;
415 virtual void commit(
bool mayInterrupt) {}
virtual std::unique_ptr< Cursor > newCursor(OperationContext *opCtx, bool isForward=true) const =0
Returns an unpositioned cursor over 'this' index.
virtual long long getSpaceUsedBytes(OperationContext *opCtx) const =0
Return the number of bytes consumed by 'this' index.
virtual void restore()=0
Recovers from potential state changes in underlying data.
virtual ~SortedDataBuilderInterface()
Definition: sorted_data_interface.h:396
Definition: record_store.h:671
virtual bool appendCustomStats(OperationContext *opCtx, BSONObjBuilder *output, double scale) const =0
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
virtual void unindex(OperationContext *opCtx, const BSONObj &key, const RecordId &loc, bool dupsAllowed)=0
Remove the entry from the index with the specified key and RecordId.
virtual boost::optional< IndexKeyEntry > next(RequestedInfo parts=kKeyAndLoc)=0
Moves forward and returns the new data or boost::none if there is no more data.
Navigates over the sorted data.
Definition: sorted_data_interface.h:223
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
BSONObj key
Definition: btree_interface.cpp:334
bool inclusive
Definition: btree_interface.cpp:335
virtual SortedDataBuilderInterface * getBulkBuilder(OperationContext *opCtx, bool dupsAllowed)=0
Return a bulk builder for 'this' index.
RequestedInfo
Tells methods that return an IndexKeyEntry what part of the data the caller is interested in...
Definition: sorted_data_interface.h:234
virtual Status insert(OperationContext *opCtx, const BSONObj &key, const RecordId &loc, bool dupsAllowed)=0
Insert an entry into the index with the specified key and RecordId.
virtual boost::optional< IndexKeyEntry > seekExact(const BSONObj &key, RequestedInfo parts=kKeyAndLoc)
Seeks to a key with a hint to the implementation that you only want exact matches.
Definition: sorted_data_interface.h:295
virtual void detachFromOperationContext()=0
Detaches from the OperationContext and releases any storage-engine state.
virtual ~Cursor()=default
A version-hiding wrapper around the bulk builder for the Btree.
Definition: sorted_data_interface.h:394
virtual ~SortedDataInterface()
Definition: sorted_data_interface.h:66
virtual void commit(bool mayInterrupt)
Do any necessary work to finish building the tree.
Definition: sorted_data_interface.h:415
virtual std::unique_ptr< Cursor > newRandomCursor(OperationContext *opCtx) const
Constructs a cursor over an index that returns entries in a randomized order, and allows storage engi...
Definition: sorted_data_interface.h:380
virtual void saveUnpositioned()
Prepares for state changes in underlying data without necessarily saving the current state...
Definition: sorted_data_interface.h:326
Definition: sorted_data_interface.h:238
Definition: sorted_data_interface.h:240
virtual Status initAsEmpty(OperationContext *opCtx)=0
virtual void reattachToOperationContext(OperationContext *opCtx)=0
Reattaches to the OperationContext and reacquires any storage-engine state.
virtual Status dupKeyCheck(OperationContext *opCtx, const BSONObj &key, const RecordId &loc)=0
Return ErrorCodes::DuplicateKey if 'key' already exists in 'this' index at a RecordId other than 'loc...
virtual bool isEmpty(OperationContext *opCtx)=0
Return true if 'this' index is empty, and false otherwise.
Definition: sorted_data_interface.h:242
virtual Status touch(OperationContext *opCtx) const
Attempt to bring the entirety of 'this' index into memory.
Definition: sorted_data_interface.h:174
virtual boost::optional< IndexKeyEntry > seek(const BSONObj &key, bool inclusive, RequestedInfo parts=kKeyAndLoc)=0
Seeks to the provided key and returns current position.
Describes a query that can be compared against an IndexKeyEntry in a way that allows expressing exclu...
Definition: index_entry_comparison.h:104
virtual long long numEntries(OperationContext *opCtx) const
Return the number of entries in 'this' index.
Definition: sorted_data_interface.h:185
virtual Status compact(OperationContext *opCtx)
Attempt to reduce the storage space used by this index via compaction.
Definition: sorted_data_interface.h:132
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
Definition: sorted_data_interface.h:236
virtual void save()=0
Prepares for state changes in underlying data in a way that allows the cursor's current position to b...
virtual void setEndPosition(const BSONObj &key, bool inclusive)=0
Sets the position to stop scanning.
virtual void fullValidate(OperationContext *opCtx, long long *numKeysOut, ValidateResults *fullResults) const =0
TODO: expose full set of args for testing?
This interface is a work in progress.
Definition: sorted_data_interface.h:64