Skip to content

Commit af12aca

Browse files
committed
Simplify Operations by uniting Sync and Async operations into a single interface.
Merged Async Read / Write Operations into their sync operations counterparts. * AsyncWriteOperation into WriteOperation is a simple merge * AsyncReadOperation into ReadOperation requires an additional type parameter This is due to async and sync cursors have different types. Added extra ReadOperations interfaces to represent: * Read operations that return the same type for sync / async * Read operations that represent cursors Removed SyncOperations and AsyncOperations builders which both use the same Operations builder class. JAVA-4900
1 parent a0173ff commit af12aca

File tree

79 files changed

+513
-1242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+513
-1242
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* <p>This class is not part of the public API and may be removed or changed at any time</p>
3939
*/
40-
abstract class AbstractWriteSearchIndexOperation implements AsyncWriteOperation<Void>, WriteOperation<Void> {
40+
abstract class AbstractWriteSearchIndexOperation implements WriteOperation<Void> {
4141
private final MongoNamespace namespace;
4242

4343
AbstractWriteSearchIndexOperation(final MongoNamespace namespace) {

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*
4242
* <p>This class is not part of the public API and may be removed or changed at any time</p>
4343
*/
44-
public class AggregateOperation<T> implements AsyncExplainableReadOperation<AsyncBatchCursor<T>>, ExplainableReadOperation<BatchCursor<T>> {
44+
public class AggregateOperation<T> implements ReadOperationExplainable<T> {
4545
private final AggregateOperationImpl<T> wrapped;
4646

4747
public AggregateOperation(final MongoNamespace namespace, final List<BsonDocument> pipeline, final Decoder<T> decoder) {
@@ -151,13 +151,7 @@ public void executeAsync(final AsyncReadBinding binding, final SingleResultCallb
151151
}
152152

153153
@Override
154-
public <R> ReadOperation<R> asExplainableOperation(@Nullable final ExplainVerbosity verbosity, final Decoder<R> resultDecoder) {
155-
return createExplainableOperation(verbosity, resultDecoder);
156-
}
157-
158-
@Override
159-
public <R> AsyncReadOperation<R> asAsyncExplainableOperation(@Nullable final ExplainVerbosity verbosity,
160-
final Decoder<R> resultDecoder) {
154+
public <R> ReadOperationSimple<R> asExplainableOperation(@Nullable final ExplainVerbosity verbosity, final Decoder<R> resultDecoder) {
161155
return createExplainableOperation(verbosity, resultDecoder);
162156
}
163157

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import static com.mongodb.internal.operation.SyncOperationHelper.CommandReadTransformer;
5353
import static com.mongodb.internal.operation.SyncOperationHelper.executeRetryableRead;
5454

55-
class AggregateOperationImpl<T> implements AsyncReadOperation<AsyncBatchCursor<T>>, ReadOperation<BatchCursor<T>> {
55+
class AggregateOperationImpl<T> implements ReadOperationCursor<T> {
5656
private static final String COMMAND_NAME = "aggregate";
5757
private static final String RESULT = "result";
5858
private static final String CURSOR = "cursor";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
*
5555
* <p>This class is not part of the public API and may be removed or changed at any time</p>
5656
*/
57-
public class AggregateToCollectionOperation implements ReadOperation<Void>, AsyncReadOperation<Void> {
57+
public class AggregateToCollectionOperation implements ReadOperationSimple<Void> {
5858
private static final String COMMAND_NAME = "aggregate";
5959
private final MongoNamespace namespace;
6060
private final List<BsonDocument> pipeline;

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

Lines changed: 0 additions & 390 deletions
This file was deleted.

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

Lines changed: 0 additions & 43 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
*
4646
* <p>This class is not part of the public API and may be removed or changed at any time</p>
4747
*/
48-
public abstract class BaseFindAndModifyOperation<T> implements AsyncWriteOperation<T>, WriteOperation<T> {
48+
public abstract class BaseFindAndModifyOperation<T> implements WriteOperation<T> {
4949
private static final String COMMAND_NAME = "findAndModify";
5050
private final MongoNamespace namespace;
5151
private final WriteConcern writeConcern;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
*
5252
* <p>This class is not part of the public API and may be removed or changed at any time</p>
5353
*/
54-
public class ChangeStreamOperation<T> implements AsyncReadOperation<AsyncBatchCursor<T>>, ReadOperation<BatchCursor<T>> {
54+
public class ChangeStreamOperation<T> implements ReadOperationCursor<T> {
5555
private static final RawBsonDocumentCodec RAW_BSON_DOCUMENT_CODEC = new RawBsonDocumentCodec();
5656
private final AggregateOperationImpl<RawBsonDocument> wrapped;
5757
private final FullDocument fullDocument;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
/**
147147
* This class is not part of the public API and may be removed or changed at any time.
148148
*/
149-
public final class ClientBulkWriteOperation implements AsyncWriteOperation<ClientBulkWriteResult>, WriteOperation<ClientBulkWriteResult> {
149+
public final class ClientBulkWriteOperation implements WriteOperation<ClientBulkWriteResult> {
150150
private static final ConcreteClientBulkWriteOptions EMPTY_OPTIONS = new ConcreteClientBulkWriteOptions();
151151
private static final String BULK_WRITE_COMMAND_NAME = "bulkWrite";
152152
private static final EncoderContext DEFAULT_ENCODER_CONTEXT = EncoderContext.builder().build();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*
3333
* <p>This class is not part of the public API and may be removed or changed at any time</p>
3434
*/
35-
public class CommandReadOperation<T> implements AsyncReadOperation<T>, ReadOperation<T> {
35+
public class CommandReadOperation<T> implements ReadOperationSimple<T> {
3636
private final String commandName;
3737
private final String databaseName;
3838
private final CommandCreator commandCreator;

0 commit comments

Comments
 (0)