@@ -70,9 +70,7 @@ Collection* getCollectionForCompact(OperationContext* opCtx,
7070
7171} // namespace
7272
73- StatusWith<CompactStats> compactCollection (OperationContext* opCtx,
74- const NamespaceString& collectionNss,
75- const CompactOptions* compactOptions) {
73+ Status compactCollection (OperationContext* opCtx, const NamespaceString& collectionNss) {
7674 AutoGetDb autoDb (opCtx, collectionNss.db (), MODE_IX);
7775 Database* database = autoDb.getDb ();
7876 uassert (ErrorCodes::NamespaceNotFound, " database does not exist" , database);
@@ -90,10 +88,9 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
9088 OldClientContext ctx (opCtx, collectionNss.ns ());
9189
9290 if (!recordStore->compactSupported ())
93- return StatusWith<CompactStats>(ErrorCodes::CommandNotSupported,
94- str::stream ()
95- << " cannot compact collection with record store: "
96- << recordStore->name ());
91+ return Status (ErrorCodes::CommandNotSupported,
92+ str::stream () << " cannot compact collection with record store: "
93+ << recordStore->name ());
9794
9895 if (recordStore->supportsOnlineCompaction ()) {
9996 // Storage engines that allow online compaction should do so using an intent lock on the
@@ -105,24 +102,22 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
105102 recordStore = collection->getRecordStore ();
106103 }
107104
108- log (LogComponent::kCommand ) << " compact " << collectionNss
109- << " begin, options: " << *compactOptions;
105+ log (LogComponent::kCommand ) << " compact " << collectionNss << " begin" ;
110106
111107 auto indexCatalog = collection->getIndexCatalog ();
112108
113109 if (recordStore->compactsInPlace ()) {
114- CompactStats stats;
115110 Status status = recordStore->compact (opCtx);
116111 if (!status.isOK ())
117- return StatusWith<CompactStats>( status) ;
112+ return status;
118113
119114 // Compact all indexes (not including unfinished indexes)
120115 status = indexCatalog->compactIndexes (opCtx);
121116 if (!status.isOK ())
122- return StatusWith<CompactStats>( status) ;
117+ return status;
123118
124119 log () << " compact " << collectionNss << " end" ;
125- return StatusWith<CompactStats>(stats) ;
120+ return status ;
126121 }
127122
128123 invariant (opCtx->lockState ()->isCollectionLockedForMode (collectionNss, MODE_X));
@@ -147,9 +142,9 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
147142 const Status keyStatus =
148143 index_key_validate::validateKeyPattern (key, descriptor->version ());
149144 if (!keyStatus.isOK ()) {
150- return StatusWith<CompactStats>(
151- ErrorCodes::CannotCreateIndex,
152- str::stream () << " Cannot compact collection due to invalid index " << spec
145+ return Status (ErrorCodes::CannotCreateIndex,
146+ str::stream ()
147+ << " Cannot compact collection due to invalid index " << spec
153148 << " : " << keyStatus.reason () << " For more info see"
154149 << " http://dochub.mongodb.org/core/index-validation" );
155150 }
@@ -169,8 +164,6 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
169164 wunit.commit ();
170165 }
171166
172- CompactStats stats;
173-
174167 MultiIndexBlock indexer;
175168 indexer.ignoreUniqueConstraint (); // in compact we should be doing no checking
176169
@@ -180,16 +173,16 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
180173 Status status =
181174 indexer.init (opCtx, collection, indexSpecs, MultiIndexBlock::kNoopOnInitFn ).getStatus ();
182175 if (!status.isOK ())
183- return StatusWith<CompactStats>( status) ;
176+ return status;
184177
185178 status = recordStore->compact (opCtx);
186179 if (!status.isOK ())
187- return StatusWith<CompactStats>( status) ;
180+ return status;
188181
189182 log () << " starting index commits" ;
190183 status = indexer.dumpInsertsFromBulk (opCtx);
191184 if (!status.isOK ())
192- return StatusWith<CompactStats>( status) ;
185+ return status;
193186
194187 {
195188 WriteUnitOfWork wunit (opCtx);
@@ -198,13 +191,13 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
198191 MultiIndexBlock::kNoopOnCreateEachFn ,
199192 MultiIndexBlock::kNoopOnCommitFn );
200193 if (!status.isOK ()) {
201- return StatusWith<CompactStats>( status) ;
194+ return status;
202195 }
203196 wunit.commit ();
204197 }
205198
206199 log () << " compact " << collectionNss << " end" ;
207- return StatusWith<CompactStats>(stats );
200+ return Status::OK ( );
208201}
209202
210203} // namespace mongo
0 commit comments