Storage Engine API
record_store_v1_capped_iterator.h
Go to the documentation of this file.
1 
29 #pragma once
30 
33 
34 namespace mongo {
35 
36 class CappedRecordStoreV1;
37 
38 struct Extent;
39 
45 public:
46  CappedRecordStoreV1Iterator(OperationContext* opCtx,
48  bool forward);
49 
50  boost::optional<Record> next() final;
51  boost::optional<Record> seekExact(const RecordId& id) final;
52  void save() final;
53  bool restore() final;
55  _opCtx = nullptr;
56  }
57  void reattachToOperationContext(OperationContext* opCtx) final {
58  _opCtx = opCtx;
59  }
60  void invalidate(OperationContext* opCtx, const RecordId& dl) final;
61  std::unique_ptr<RecordFetcher> fetcherForNext() const final;
62  std::unique_ptr<RecordFetcher> fetcherForId(const RecordId& id) const final;
63 
64 private:
65  void advance();
66  bool isEOF() {
67  return _curr.isNull();
68  }
69 
73  DiskLoc getNextCapped(const DiskLoc& dl);
74  DiskLoc prevLoop(const DiskLoc& curr);
75  DiskLoc nextLoop(const DiskLoc& prev);
76 
77  // some helpers - these move to RecordStore probably
78  Extent* _getExtent(const DiskLoc& loc);
79  DiskLoc _getNextRecord(const DiskLoc& loc);
80  DiskLoc _getPrevRecord(const DiskLoc& loc);
81 
82  // transactional context for read locks. Not owned by us
83  OperationContext* _opCtx;
84 
85  // The collection we're iterating over.
87 
88  // The result returned on the next call to getNext().
90 
91  const bool _forward;
92 
93  // If invalidate kills the DiskLoc we need to move forward, we kill the iterator. See the
94  // comment in the body of invalidate(...).
95  bool _killedByInvalidate = false;
96 };
97 
98 } // namespace mongo
OperationContext * _opCtx
Definition: record_store_v1_capped_iterator.h:83
void save() final
Prepares for state changes in underlying data in a way that allows the cursor&#39;s current position to b...
Definition: record_store_v1_capped_iterator.cpp:104
void detachFromOperationContext() final
Detaches from the OperationContext and releases any storage-engine state.
Definition: record_store_v1_capped_iterator.h:54
Definition: extent.h:50
Extent * _getExtent(const DiskLoc &loc)
Definition: record_store_v1_capped_iterator.cpp:195
bool isNull() const
Definition: diskloc.h:97
bool _killedByInvalidate
Definition: record_store_v1_capped_iterator.h:95
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
Collection *const collection
Definition: collection_info_cache_impl.cpp:53
const CappedRecordStoreV1 *const _recordStore
Definition: record_store_v1_capped_iterator.h:86
CappedRecordStoreV1Iterator(OperationContext *opCtx, const CappedRecordStoreV1 *collection, bool forward)
Definition: record_store_v1_capped_iterator.cpp:42
DiskLoc nextLoop(const DiskLoc &prev)
Definition: record_store_v1_capped_iterator.cpp:176
const bool _forward
Definition: record_store_v1_capped_iterator.h:91
represents a disk location/offset on disk in a database.
Definition: diskloc.h:53
boost::optional< Record > next() final
Moves forward and returns the new data or boost::none if there is no more data.
Definition: record_store_v1_capped_iterator.cpp:76
void invalidate(OperationContext *opCtx, const RecordId &dl) final
Inform the cursor that this id is being invalidated.
Definition: record_store_v1_capped_iterator.cpp:89
boost::optional< Record > seekExact(const RecordId &id) final
Seeks to a Record with the provided id.
Definition: record_store_v1_capped_iterator.cpp:84
This class iterates over a capped collection identified by &#39;ns&#39;.
Definition: record_store_v1_capped_iterator.h:44
DiskLoc prevLoop(const DiskLoc &curr)
Definition: record_store_v1_capped_iterator.cpp:185
DiskLoc _getNextRecord(const DiskLoc &loc)
Definition: record_store_v1_capped_iterator.cpp:199
Adds explicit seeking of records.
Definition: record_store.h:236
Definition: record_store_v1_capped.h:41
bool isEOF()
Definition: record_store_v1_capped_iterator.h:66
DiskLoc _curr
Definition: record_store_v1_capped_iterator.h:89
DiskLoc getNextCapped(const DiskLoc &dl)
Internal collection navigation helper methods.
Definition: record_store_v1_capped_iterator.cpp:110
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
std::unique_ptr< RecordFetcher > fetcherForNext() const final
Returns a RecordFetcher if needed for a call to next() or none if unneeded.
Definition: record_store_v1_capped_iterator.cpp:207
DiskLoc _getPrevRecord(const DiskLoc &loc)
Definition: record_store_v1_capped_iterator.cpp:203
bool restore() final
Recovers from potential state changes in underlying data.
Definition: record_store_v1_capped_iterator.cpp:106
void reattachToOperationContext(OperationContext *opCtx) final
Reattaches to the OperationContext and reacquires any storage-engine state.
Definition: record_store_v1_capped_iterator.h:57
std::unique_ptr< RecordFetcher > fetcherForId(const RecordId &id) const final
Returns a RecordFetcher if needed to fetch the provided Record or none if unneeded.
Definition: record_store_v1_capped_iterator.cpp:211