Skip to content

Commit faba36c

Browse files
committed
Remove deprecated mapReduce options
JAVA-5149
1 parent d83b259 commit faba36c

File tree

17 files changed

+4
-206
lines changed

17 files changed

+4
-206
lines changed

driver-core/src/main/com/mongodb/internal/operation/AsyncOperations.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,9 @@ public AsyncWriteOperation<MapReduceStatistics> mapReduceToCollection(final Stri
164164
final long maxTimeMS, final boolean jsMode, final Bson scope,
165165
final Bson sort, final boolean verbose,
166166
final com.mongodb.client.model.MapReduceAction action,
167-
final boolean nonAtomic, final boolean sharded,
168167
final Boolean bypassDocumentValidation, final Collation collation) {
169168
return operations.mapReduceToCollection(databaseName, collectionName, mapFunction, reduceFunction, finalizeFunction, filter, limit,
170-
maxTimeMS, jsMode, scope, sort, verbose, action, nonAtomic, sharded, bypassDocumentValidation, collation);
169+
maxTimeMS, jsMode, scope, sort, verbose, action, bypassDocumentValidation, collation);
171170
}
172171

173172
public <TResult> AsyncReadOperation<MapReduceAsyncBatchCursor<TResult>> mapReduce(final String mapFunction, final String reduceFunction,

driver-core/src/main/com/mongodb/internal/operation/MapReduceToCollectionOperation.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import static com.mongodb.internal.operation.DocumentHelper.putIfNotZero;
4747
import static com.mongodb.internal.operation.DocumentHelper.putIfTrue;
4848
import static com.mongodb.internal.operation.OperationHelper.LOGGER;
49-
import static com.mongodb.internal.operation.ServerVersionHelper.serverIsAtLeastVersionFourDotFour;
5049
import static com.mongodb.internal.operation.SyncOperationHelper.CommandWriteTransformer;
5150
import static com.mongodb.internal.operation.SyncOperationHelper.executeCommand;
5251
import static com.mongodb.internal.operation.SyncOperationHelper.withConnection;
@@ -81,8 +80,6 @@
8180
private long maxTimeMS;
8281
private String action = "replace";
8382
private String databaseName;
84-
private boolean sharded;
85-
private boolean nonAtomic;
8683
private Boolean bypassDocumentValidation;
8784
private Collation collation;
8885
private static final List<String> VALID_ACTIONS = asList("replace", "merge", "reduce");
@@ -217,24 +214,6 @@ public MapReduceToCollectionOperation databaseName(@Nullable final String databa
217214
return this;
218215
}
219216

220-
public boolean isSharded() {
221-
return sharded;
222-
}
223-
224-
public MapReduceToCollectionOperation sharded(final boolean sharded) {
225-
this.sharded = sharded;
226-
return this;
227-
}
228-
229-
public boolean isNonAtomic() {
230-
return nonAtomic;
231-
}
232-
233-
public MapReduceToCollectionOperation nonAtomic(final boolean nonAtomic) {
234-
this.nonAtomic = nonAtomic;
235-
return this;
236-
}
237-
238217
public Boolean getBypassDocumentValidation() {
239218
return bypassDocumentValidation;
240219
}
@@ -318,10 +297,6 @@ private CommandWriteTransformerAsync<BsonDocument, MapReduceStatistics> transfor
318297

319298
private BsonDocument getCommand(@Nullable final ConnectionDescription description) {
320299
BsonDocument outputDocument = new BsonDocument(getAction(), new BsonString(getCollectionName()));
321-
if (description != null && !serverIsAtLeastVersionFourDotFour(description)) {
322-
putIfTrue(outputDocument, "sharded", isSharded());
323-
putIfTrue(outputDocument, "nonAtomic", isNonAtomic());
324-
}
325300
if (getDatabaseName() != null) {
326301
outputDocument.put("db", new BsonString(getDatabaseName()));
327302
}

driver-core/src/main/com/mongodb/internal/operation/Operations.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ MapReduceToCollectionOperation mapReduceToCollection(final String databaseName,
269269
final int limit, final long maxTimeMS, final boolean jsMode,
270270
final Bson scope, final Bson sort, final boolean verbose,
271271
final com.mongodb.client.model.MapReduceAction action,
272-
final boolean nonAtomic, final boolean sharded,
273272
final Boolean bypassDocumentValidation, final Collation collation) {
274273
MapReduceToCollectionOperation operation = new MapReduceToCollectionOperation(assertNotNull(namespace),
275274
new BsonJavaScript(mapFunction), new BsonJavaScript(reduceFunction), collectionName, writeConcern)
@@ -281,8 +280,6 @@ MapReduceToCollectionOperation mapReduceToCollection(final String databaseName,
281280
.sort(toBsonDocument(sort))
282281
.verbose(verbose)
283282
.action(action.getValue())
284-
.nonAtomic(nonAtomic)
285-
.sharded(sharded)
286283
.databaseName(databaseName)
287284
.bypassDocumentValidation(bypassDocumentValidation)
288285
.collation(collation);

driver-core/src/main/com/mongodb/internal/operation/SyncOperations.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,15 @@ public ReadOperation<Void> aggregateToCollection(final List<? extends Bson> pipe
132132
comment, variables, aggregationLevel);
133133
}
134134

135-
@SuppressWarnings("deprecation")
136135
public WriteOperation<MapReduceStatistics> mapReduceToCollection(final String databaseName, final String collectionName,
137136
final String mapFunction, final String reduceFunction,
138137
final String finalizeFunction, final Bson filter, final int limit,
139138
final long maxTimeMS, final boolean jsMode, final Bson scope,
140139
final Bson sort, final boolean verbose,
141140
final com.mongodb.client.model.MapReduceAction action,
142-
final boolean nonAtomic, final boolean sharded,
143141
final Boolean bypassDocumentValidation, final Collation collation) {
144142
return operations.mapReduceToCollection(databaseName, collectionName, mapFunction, reduceFunction, finalizeFunction, filter, limit,
145-
maxTimeMS, jsMode, scope, sort, verbose, action, nonAtomic, sharded, bypassDocumentValidation, collation);
143+
maxTimeMS, jsMode, scope, sort, verbose, action, bypassDocumentValidation, collation);
146144
}
147145

148146
public <TResult> ReadOperation<MapReduceBatchCursor<TResult>> mapReduce(final String mapFunction, final String reduceFunction,

driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceToCollectionOperationSpecification.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ class MapReduceToCollectionOperationSpecification extends OperationFunctionalSpe
9494
operation.getCollation() == null
9595
!operation.isJsMode()
9696
!operation.isVerbose()
97-
!operation.isSharded()
98-
!operation.isNonAtomic()
9997
}
10098

10199
def 'should set optional values correctly'(){

driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncMapReduceIterable.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ data class SyncMapReduceIterable<T : Any>(val wrapped: MapReduceFlow<T>) :
5151
override fun databaseName(databaseName: String?): SyncMapReduceIterable<T> = apply {
5252
wrapped.databaseName(databaseName)
5353
}
54-
@Suppress("OVERRIDE_DEPRECATION")
55-
override fun sharded(sharded: Boolean): SyncMapReduceIterable<T> = apply { wrapped.sharded(sharded) }
56-
@Suppress("OVERRIDE_DEPRECATION")
57-
override fun nonAtomic(nonAtomic: Boolean): SyncMapReduceIterable<T> = apply { wrapped.nonAtomic(nonAtomic) }
5854

5955
override fun bypassDocumentValidation(bypassDocumentValidation: Boolean?): SyncMapReduceIterable<T> = apply {
6056
wrapped.bypassDocumentValidation(bypassDocumentValidation)

driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MapReduceFlow.kt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,28 +165,6 @@ public class MapReduceFlow<T : Any>(private val wrapped: MapReducePublisher<T>)
165165
*/
166166
public fun databaseName(databaseName: String?): MapReduceFlow<T> = apply { wrapped.databaseName(databaseName) }
167167

168-
/**
169-
* Sets if the output database is sharded
170-
*
171-
* @param sharded if the output database is sharded
172-
* @return this
173-
* @see
174-
* [output with an action](https://www.mongodb.com/docs/manual/reference/command/mapReduce/#output-to-a-collection-with-an-action)
175-
*/
176-
public fun sharded(sharded: Boolean): MapReduceFlow<T> = apply { wrapped.sharded(sharded) }
177-
178-
/**
179-
* Sets if the post-processing step will prevent MongoDB from locking the database.
180-
*
181-
* Valid only with the `MapReduceAction.MERGE` or `MapReduceAction.REDUCE` actions.
182-
*
183-
* @param nonAtomic if the post-processing step will prevent MongoDB from locking the database.
184-
* @return this
185-
* @see
186-
* [output with an action](https://www.mongodb.com/docs/manual/reference/command/mapReduce/#output-to-a-collection-with-an-action)
187-
*/
188-
public fun nonAtomic(nonAtomic: Boolean): MapReduceFlow<T> = apply { wrapped.nonAtomic(nonAtomic) }
189-
190168
/**
191169
* Sets the bypass document level validation flag.
192170
*

driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/MapReduceFlowTest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ class MapReduceFlowTest {
6767
flow.limit(1)
6868
flow.maxTime(1)
6969
flow.maxTime(1, TimeUnit.SECONDS)
70-
flow.nonAtomic(true)
7170
flow.scope(bson)
72-
flow.sharded(true)
7371
flow.sort(bson)
7472
flow.verbose(true)
7573
flow.action(MapReduceAction.MERGE)
@@ -85,9 +83,7 @@ class MapReduceFlowTest {
8583
verify(wrapped).limit(1)
8684
verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
8785
verify(wrapped).maxTime(1, TimeUnit.SECONDS)
88-
verify(wrapped).nonAtomic(true)
8986
verify(wrapped).scope(bson)
90-
verify(wrapped).sharded(true)
9187
verify(wrapped).sort(bson)
9288
verify(wrapped).verbose(true)
9389
verify(wrapped).action(MapReduceAction.MERGE)

driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/MapReducePublisher.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,29 +134,6 @@ public interface MapReducePublisher<TResult> extends Publisher<TResult> {
134134
* @mongodb.driver.manual reference/command/mapReduce/#output-to-a-collection-with-an-action output with an action
135135
*/
136136
MapReducePublisher<TResult> databaseName(@Nullable String databaseName);
137-
/**
138-
* Sets if the output database is sharded
139-
*
140-
* @param sharded if the output database is sharded
141-
* @return this
142-
* @mongodb.driver.manual reference/command/mapReduce/#output-to-a-collection-with-an-action output with an action
143-
* @deprecated this option will no longer be supported in MongoDB 4.4
144-
*/
145-
@Deprecated
146-
MapReducePublisher<TResult> sharded(boolean sharded);
147-
148-
/**
149-
* Sets if the post-processing step will prevent MongoDB from locking the database.
150-
* <p>
151-
* Valid only with the {@code MapReduceAction.MERGE} or {@code MapReduceAction.REDUCE} actions.
152-
*
153-
* @param nonAtomic if the post-processing step will prevent MongoDB from locking the database.
154-
* @return this
155-
* @mongodb.driver.manual reference/command/mapReduce/#output-to-a-collection-with-an-action output with an action
156-
* @deprecated this option will no longer be supported in MongoDB 4.4 as it will no longer hold a global or database level write lock.
157-
*/
158-
@Deprecated
159-
MapReducePublisher<TResult> nonAtomic(boolean nonAtomic);
160137

161138
/**
162139
* Sets the bypass document level validation flag.

driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/MapReducePublisherImpl.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ final class MapReducePublisherImpl<T> extends BatchCursorPublisher<T> implements
5757
private long maxTimeMS;
5858
private com.mongodb.client.model.MapReduceAction action = com.mongodb.client.model.MapReduceAction.REPLACE;
5959
private String databaseName;
60-
private boolean sharded;
61-
private boolean nonAtomic;
6260
private Boolean bypassDocumentValidation;
6361
private Collation collation;
6462

@@ -140,20 +138,6 @@ public com.mongodb.reactivestreams.client.MapReducePublisher<T> databaseName(@Nu
140138
return this;
141139
}
142140

143-
@Deprecated
144-
@Override
145-
public com.mongodb.reactivestreams.client.MapReducePublisher<T> sharded(final boolean sharded) {
146-
this.sharded = sharded;
147-
return this;
148-
}
149-
150-
@Deprecated
151-
@Override
152-
public com.mongodb.reactivestreams.client.MapReducePublisher<T> nonAtomic(final boolean nonAtomic) {
153-
this.nonAtomic = nonAtomic;
154-
return this;
155-
}
156-
157141
@Override
158142
public com.mongodb.reactivestreams.client.MapReducePublisher<T> batchSize(final int batchSize) {
159143
super.batchSize(batchSize);
@@ -211,8 +195,7 @@ private WrappedMapReduceWriteOperation createMapReduceToCollectionOperation() {
211195
return new WrappedMapReduceWriteOperation(getOperations().mapReduceToCollection(databaseName, collectionName, mapFunction,
212196
reduceFunction, finalizeFunction, filter, limit,
213197
maxTimeMS, jsMode, scope, sort, verbose, action,
214-
nonAtomic, sharded,
215-
bypassDocumentValidation, collation));
198+
bypassDocumentValidation, collation));
216199
}
217200

218201
private AsyncReadOperation<AsyncBatchCursor<T>> createFindOperation(final int initialBatchSize) {

driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncMapReduceIterable.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,6 @@ public com.mongodb.client.MapReduceIterable<T> databaseName(@Nullable final Stri
106106
return this;
107107
}
108108

109-
@Override
110-
public com.mongodb.client.MapReduceIterable<T> sharded(final boolean sharded) {
111-
wrapped.sharded(sharded);
112-
return this;
113-
}
114-
115-
@Override
116-
public com.mongodb.client.MapReduceIterable<T> nonAtomic(final boolean nonAtomic) {
117-
wrapped.nonAtomic(nonAtomic);
118-
return this;
119-
}
120-
121109
@Override
122110
public com.mongodb.client.MapReduceIterable<T> batchSize(final int batchSize) {
123111
wrapped.batchSize(batchSize);

driver-scala/src/integration/scala/org/mongodb/scala/syncadapter/SyncMapReduceIterable.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,6 @@ case class SyncMapReduceIterable[T](wrapped: MapReduceObservable[T])
8383
this
8484
}
8585

86-
override def sharded(sharded: Boolean): MapReduceIterable[T] = {
87-
wrapped.sharded(sharded)
88-
this
89-
}
90-
91-
override def nonAtomic(nonAtomic: Boolean): MapReduceIterable[T] = {
92-
wrapped.nonAtomic(nonAtomic)
93-
this
94-
}
95-
9686
override def batchSize(batchSize: Int): MapReduceIterable[T] = {
9787
wrapped.batchSize(batchSize)
9888
this

driver-scala/src/main/scala/org/mongodb/scala/MapReduceObservable.scala

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -169,37 +169,6 @@ case class MapReduceObservable[TResult](wrapped: MapReducePublisher[TResult]) ex
169169
this
170170
}
171171

172-
/**
173-
* Sets if the output database is sharded
174-
*
175-
* [[https://www.mongodb.com/docs/manual/reference/command/mapReduce#output-to-a-collection-with-an-action output with an action]]
176-
* @param sharded if the output database is sharded
177-
* @return this
178-
*/
179-
@deprecated("This option will no longer be supported in MongoDB 4.4.", "4.1.0")
180-
def sharded(sharded: Boolean): MapReduceObservable[TResult] = {
181-
wrapped.sharded(sharded)
182-
this
183-
}
184-
185-
/**
186-
* Sets if the post-processing step will prevent MongoDB from locking the database.
187-
*
188-
* Valid only with the `MapReduceAction.MERGE` or `MapReduceAction.REDUCE` actions.
189-
*
190-
* [[https://www.mongodb.com/docs/manual/reference/command/mapReduce/#output-to-a-collection-with-an-action Output with an action]]
191-
* @param nonAtomic if the post-processing step will prevent MongoDB from locking the database.
192-
* @return this
193-
*/
194-
@deprecated(
195-
"This option will no longer be supported in MongoDB 4.4 as it will no longer hold a global or database level write lock",
196-
"4.1.0"
197-
)
198-
def nonAtomic(nonAtomic: Boolean): MapReduceObservable[TResult] = {
199-
wrapped.nonAtomic(nonAtomic)
200-
this
201-
}
202-
203172
/**
204173
* Sets the bypass document level validation flag.
205174
*

driver-scala/src/test/scala/org/mongodb/scala/MapReduceObservableSpec.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ class MapReduceObservableSpec extends BaseSpec with MockitoSugar {
6060
observable.action(MapReduceAction.REPLACE)
6161
observable.jsMode(true)
6262
observable.verbose(true)
63-
observable.sharded(true)
64-
observable.nonAtomic(true)
6563
observable.bypassDocumentValidation(true)
6664
observable.collation(collation)
6765
observable.batchSize(batchSize)
@@ -77,8 +75,6 @@ class MapReduceObservableSpec extends BaseSpec with MockitoSugar {
7775
verify(wrapper).action(MapReduceAction.REPLACE)
7876
verify(wrapper).jsMode(true)
7977
verify(wrapper).verbose(true)
80-
verify(wrapper).sharded(true)
81-
verify(wrapper).nonAtomic(true)
8278
verify(wrapper).bypassDocumentValidation(true)
8379
verify(wrapper).collation(collation)
8480
verify(wrapper).batchSize(batchSize)

driver-sync/src/main/com/mongodb/client/MapReduceIterable.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -146,30 +146,6 @@ public interface MapReduceIterable<TResult> extends MongoIterable<TResult> {
146146
*/
147147
MapReduceIterable<TResult> databaseName(@Nullable String databaseName);
148148

149-
/**
150-
* Sets if the output database is sharded
151-
*
152-
* @param sharded if the output database is sharded
153-
* @return this
154-
* @mongodb.driver.manual reference/command/mapReduce/#output-to-a-collection-with-an-action output with an action
155-
* @deprecated this option will no longer be supported in MongoDB 4.4.
156-
*/
157-
@Deprecated
158-
MapReduceIterable<TResult> sharded(boolean sharded);
159-
160-
/**
161-
* Sets if the post-processing step will prevent MongoDB from locking the database.
162-
* <p>
163-
* Valid only with the {@code MapReduceAction.MERGE} or {@code MapReduceAction.REDUCE} actions.
164-
*
165-
* @param nonAtomic if the post-processing step will prevent MongoDB from locking the database.
166-
* @return this
167-
* @mongodb.driver.manual reference/command/mapReduce/#output-to-a-collection-with-an-action output with an action
168-
* @deprecated this option will no longer be supported in MongoDB 4.4 as it will no longer hold a global or database level write lock.
169-
*/
170-
@Deprecated
171-
MapReduceIterable<TResult> nonAtomic(boolean nonAtomic);
172-
173149
/**
174150
* Sets the number of documents to return per batch.
175151
*

driver-sync/src/main/com/mongodb/client/internal/MapReduceIterableImpl.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ class MapReduceIterableImpl<TDocument, TResult> extends MongoIterableImpl<TResul
6161
private long maxTimeMS;
6262
private com.mongodb.client.model.MapReduceAction action = com.mongodb.client.model.MapReduceAction.REPLACE;
6363
private String databaseName;
64-
private boolean sharded;
65-
private boolean nonAtomic;
6664
private Boolean bypassDocumentValidation;
6765
private Collation collation;
6866

@@ -156,18 +154,6 @@ public com.mongodb.client.MapReduceIterable<TResult> databaseName(@Nullable fina
156154
return this;
157155
}
158156

159-
@Override
160-
public com.mongodb.client.MapReduceIterable<TResult> sharded(final boolean sharded) {
161-
this.sharded = sharded;
162-
return this;
163-
}
164-
165-
@Override
166-
public com.mongodb.client.MapReduceIterable<TResult> nonAtomic(final boolean nonAtomic) {
167-
this.nonAtomic = nonAtomic;
168-
return this;
169-
}
170-
171157
@Override
172158
public com.mongodb.client.MapReduceIterable<TResult> batchSize(final int batchSize) {
173159
super.batchSize(batchSize);
@@ -218,7 +204,7 @@ public ReadOperation<BatchCursor<TResult>> asReadOperation() {
218204

219205
private WriteOperation<MapReduceStatistics> createMapReduceToCollectionOperation() {
220206
return operations.mapReduceToCollection(databaseName, collectionName, mapFunction, reduceFunction, finalizeFunction, filter,
221-
limit, maxTimeMS, jsMode, scope, sort, verbose, action, nonAtomic, sharded, bypassDocumentValidation, collation
207+
limit, maxTimeMS, jsMode, scope, sort, verbose, action, bypassDocumentValidation, collation
222208
);
223209
}
224210

0 commit comments

Comments
 (0)