MB-20852 [8/N]: Improve documentation of putCursorsInCollapsedChk 17/69017/5
authorDave Rigby <daver@couchbase.com>
Tue, 11 Oct 2016 14:12:03 +0000 (15:12 +0100)
committerDave Rigby <daver@couchbase.com>
Mon, 31 Oct 2016 15:57:57 +0000 (15:57 +0000)
Change-Id: Ibe29d7507aea0f49593454416e9e58e4994ffa4e
Reviewed-on: http://review.couchbase.org/69017
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: buildbot <build@couchbase.com>
src/checkpoint.cc
src/checkpoint.h

index b069ba1..71fdba8 100644 (file)
@@ -1521,11 +1521,13 @@ void CheckpointManager::collapseCheckpoints(uint64_t id) {
 
 void CheckpointManager::
 putCursorsInCollapsedChk(CursorIdToPositionMap& cursors,
-                         std::list<Checkpoint*>::iterator chkItr) {
+                         const std::list<Checkpoint*>::iterator chkItr) {
     size_t i;
     Checkpoint *chk = *chkItr;
     auto cit = chk->begin();
     auto last = chk->begin();
+    // Stage 1 - iterate over the checkpoint items, checking if any of the
+    // cursors were positioned at that item.
     for (i = 0; cit != chk->end(); ++i, ++cit) {
         uint64_t id = chk->getMutationIdForKey((*cit)->getKey(),
                                                (*cit)->isCheckPointMetaItem());
@@ -1559,6 +1561,9 @@ putCursorsInCollapsedChk(CursorIdToPositionMap& cursors,
         }
     }
 
+    // For any remaining cursors which were not repositioned in stage 1,
+    // position either at the checkpoint start (if
+    // fromBeginningOnChkCollapse==true) or otherwise at the checkpoint end.
     for (auto& cur : cursors) {
         cursor_index::iterator cc = connCursors.find(cur.first);
         if (cc == connCursors.end()) {
index 439d62c..ae2278f 100644 (file)
@@ -859,7 +859,7 @@ private:
     void resetCursors(bool resetPersistenceCursor = true);
 
     void putCursorsInCollapsedChk(CursorIdToPositionMap& cursors,
-                                  std::list<Checkpoint*>::iterator chkItr);
+                                  const std::list<Checkpoint*>::iterator chkItr);
 
     queued_item createCheckpointItem(uint64_t id, uint16_t vbid,
                                      queue_op checkpoint_op);