Move in same loop as move can now fail.
@@ -74,29 +74,6 @@ DocumentBucketMover::setupForBucket(const BucketId &bucket,
_lastGidValid = false;
}
-
-namespace
-{
-
-class MoveKey
-{
-public:
- DocumentIdT _lid;
- document::GlobalId _gid;
- Timestamp _timestamp;
-
- MoveKey(DocumentIdT lid,
- const document::GlobalId &gid,
- Timestamp timestamp)
- : _lid(lid),
- _gid(gid),
- _timestamp(timestamp)
- {
- }
-};
-
-}
-
void
DocumentBucketMover::setBucketDone() {
_bucketDone = true;
@@ -113,8 +90,6 @@ DocumentBucketMover::moveDocuments(size_t maxDocsToMove)
const Iterator end = _source->meta_store()->upperBound(_bucket);
size_t docsMoved = 0;
size_t docsSkipped = 0; // In absence of a proper cost metric
- typedef std::vector<MoveKey> MoveVec;
- MoveVec toMove;
for (; itr != end && docsMoved < maxDocsToMove; ++itr) {
DocumentIdT lid = itr.getKey();
const RawDocumentMetaData &metaData = _source->meta_store()->getRawMetaData(lid);
@@ -125,8 +100,9 @@ DocumentBucketMover::moveDocuments(size_t maxDocsToMove)
docsSkipped = 0;
}
} else {
- // moveDocument(lid, metaData.getTimestamp());
- toMove.push_back(MoveKey(lid, metaData.getGid(), metaData.getTimestamp()));
+ if ( ! moveDocument(lid, metaData.getGid(), metaData.getTimestamp())) {
+ return false;
+ }
++docsMoved;
}
_lastGid = metaData.getGid();
@@ -135,11 +111,6 @@ DocumentBucketMover::moveDocuments(size_t maxDocsToMove)
if (itr == end) {
setBucketDone();
}
- for (const MoveKey & key : toMove) {
- if ( ! moveDocument(key._lid, key._gid, key._timestamp)) {
- return false;
- }
- }
return true;
}
