Skip to content

Commit 57b811d

Browse files
haleyConnellyevergreen
authored andcommitted
SERVER-41853 Remove unused CompactStats class
1 parent b00ddb0 commit 57b811d

File tree

5 files changed

+19
-49
lines changed

5 files changed

+19
-49
lines changed

src/mongo/db/catalog/collection.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@
3737

3838
namespace mongo {
3939

40-
std::string CompactOptions::toString() const {
41-
return str::stream() << " validateDocuments: " << validateDocuments;
42-
}
43-
4440
//
4541
// CappedInsertNotifier
4642
//

src/mongo/db/catalog/collection_compact.cpp

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/mongo/db/catalog/collection_compact.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,14 @@
2929

3030
#pragma once
3131

32-
#include "mongo/base/status_with.h"
32+
#include "mongo/base/status.h"
3333
#include "mongo/db/storage/record_store.h"
3434

3535
namespace mongo {
3636

3737
/**
3838
* Compacts collection.
39-
* See record_store.h for CompactStats and CompactOptions definitions.
4039
*/
41-
StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
42-
const NamespaceString& collectionNss,
43-
const CompactOptions* options);
40+
Status compactCollection(OperationContext* opCtx, const NamespaceString& collectionNss);
4441

4542
} // namespace mongo

src/mongo/db/commands/compact.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,7 @@ class CompactCmd : public ErrmsgCommandDeprecated {
105105
return false;
106106
}
107107

108-
CompactOptions compactOptions;
109-
110-
if (cmdObj.hasElement("validate"))
111-
compactOptions.validateDocuments = cmdObj["validate"].trueValue();
112-
113-
uassertStatusOK(compactCollection(opCtx, nss, &compactOptions));
108+
uassertStatusOK(compactCollection(opCtx, nss));
114109
return true;
115110
}
116111
};

src/mongo/db/storage/record_store.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ namespace mongo {
4242

4343
class CappedCallback;
4444
class Collection;
45-
struct CompactOptions;
46-
struct CompactStats;
4745
class MAdvise;
4846
class OperationContext;
4947

@@ -52,15 +50,6 @@ class RecordStore;
5250
struct ValidateResults;
5351
class ValidateAdaptor;
5452

55-
struct CompactOptions {
56-
// other
57-
bool validateDocuments = true;
58-
59-
std::string toString() const;
60-
};
61-
62-
struct CompactStats {};
63-
6453
/**
6554
* The data items stored in a RecordStore.
6655
*/

0 commit comments

Comments
 (0)