From 45847bd4ac7b6f784a50f6a9f0b89bfda1276f86 Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Wed, 18 Dec 2024 20:14:35 -0800 Subject: [PATCH 1/5] Add Kotlin Bulk Write API - Add sync and coroutine Bulk Write API. - Enable unified spec tests. JAVA-5532 --- config/detekt/detekt.yml | 2 +- .../coroutine/syncadapter/SyncMongoCluster.kt | 24 +--- .../kotlin/client/coroutine/MongoCluster.kt | 109 ++++++++++++++++++ .../client/syncadapter/SyncMongoCluster.kt | 25 +--- .../com/mongodb/kotlin/client/MongoCluster.kt | 108 +++++++++++++++++ .../mongodb/client/unified/UnifiedTest.java | 12 -- 6 files changed, 228 insertions(+), 52 deletions(-) diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml index 4c083b0bce5..4ac460b0738 100644 --- a/config/detekt/detekt.yml +++ b/config/detekt/detekt.yml @@ -159,7 +159,7 @@ complexity: active: true excludes: ['**/test/**'] thresholdInFiles: 25 - thresholdInClasses: 25 + thresholdInClasses: 27 thresholdInInterfaces: 25 thresholdInObjects: 25 thresholdInEnums: 25 diff --git a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncMongoCluster.kt b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncMongoCluster.kt index 2c377e41d41..01d0e27ff58 100644 --- a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncMongoCluster.kt +++ b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncMongoCluster.kt @@ -114,39 +114,25 @@ internal open class SyncMongoCluster(open val wrapped: MongoCluster) : JMongoClu ): ChangeStreamIterable = SyncChangeStreamIterable(wrapped.watch(clientSession.unwrapped(), pipeline, resultClass)) - override fun bulkWrite(models: MutableList): ClientBulkWriteResult { - org.junit.jupiter.api.Assumptions.assumeTrue( - java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement") - TODO("BULK-TODO Kotlin implement") + override fun bulkWrite(models: MutableList): ClientBulkWriteResult = runBlocking { + wrapped.bulkWrite(models) } override fun bulkWrite( models: MutableList, options: ClientBulkWriteOptions - ): ClientBulkWriteResult { - org.junit.jupiter.api.Assumptions.assumeTrue( - java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement") - TODO("BULK-TODO Kotlin implement") - } + ): ClientBulkWriteResult = runBlocking { wrapped.bulkWrite(models, options) } override fun bulkWrite( clientSession: ClientSession, models: MutableList - ): ClientBulkWriteResult { - org.junit.jupiter.api.Assumptions.assumeTrue( - java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement") - TODO("BULK-TODO Kotlin implement") - } + ): ClientBulkWriteResult = runBlocking { wrapped.bulkWrite(clientSession.unwrapped(), models) } override fun bulkWrite( clientSession: ClientSession, models: MutableList, options: ClientBulkWriteOptions - ): ClientBulkWriteResult { - org.junit.jupiter.api.Assumptions.assumeTrue( - java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement") - TODO("BULK-TODO Kotlin implement") - } + ): ClientBulkWriteResult = runBlocking { wrapped.bulkWrite(clientSession.unwrapped(), models, options) } private fun ClientSession.unwrapped() = (this as SyncClientSession).wrapped } diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt index 88df39dd23d..0f56212916b 100644 --- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt +++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt @@ -15,12 +15,20 @@ */ package com.mongodb.kotlin.client.coroutine +import com.mongodb.ClientBulkWriteException import com.mongodb.ClientSessionOptions +import com.mongodb.MongoClientSettings +import com.mongodb.MongoException import com.mongodb.ReadConcern import com.mongodb.ReadPreference import com.mongodb.WriteConcern import com.mongodb.annotations.Alpha import com.mongodb.annotations.Reason +import com.mongodb.client.model.bulk.ClientBulkWriteOptions +import com.mongodb.client.model.bulk.ClientBulkWriteResult +import com.mongodb.client.model.bulk.ClientNamespacedDeleteManyModel +import com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel +import com.mongodb.client.model.bulk.ClientNamespacedWriteModel import com.mongodb.reactivestreams.client.MongoCluster as JMongoCluster import java.util.concurrent.TimeUnit import kotlinx.coroutines.flow.Flow @@ -307,4 +315,105 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo clientSession: ClientSession, pipeline: List = emptyList() ): ChangeStreamFlow = watch(clientSession, pipeline, T::class.java) + + /** + * Executes a client-level bulk write operation. This method is functionally equivalent to [.bulkWrite] with the + * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. + * + * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of + * `models`, encoded size of `models`, and the size limits in effect, executing this operation may require multiple + * `bulkWrite` commands. The eligibility for retries is determined per each `bulkWrite` command: + * [ClientNamespacedUpdateManyModel], [ClientNamespacedDeleteManyModel] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * @param models The [individual write operations][ClientNamespacedWriteModel]. + * @return The [ClientBulkWriteResult] if the operation is successful. + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: + * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], + * [ClientBulkWriteException.getPartialResult]. + * @throws MongoException Only if the operation is unsuccessful. + * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + */ + public suspend fun bulkWrite(models: List): ClientBulkWriteResult = + wrapped.bulkWrite(models).awaitSingle() + + /** + * Executes a client-level bulk write operation. + * + * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of + * `models`, encoded size of `models`, and the size limits in effect, executing this operation may require multiple + * `bulkWrite` commands. The eligibility for retries is determined per each `bulkWrite` command: + * [ClientNamespacedUpdateManyModel], [ClientNamespacedDeleteManyModel] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * @param models The [individual write operations][ClientNamespacedWriteModel]. + * @param options The options. + * @return The [ClientBulkWriteResult] if the operation is successful. + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: + * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], + * [ClientBulkWriteException.getPartialResult]. + * @throws MongoException Only if the operation is unsuccessful. + * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + */ + public suspend fun bulkWrite( + models: List, + options: ClientBulkWriteOptions + ): ClientBulkWriteResult = wrapped.bulkWrite(models, options).awaitSingle() + + /** + * Executes a client-level bulk write operation. This method is functionally equivalent to [.bulkWrite] with the + * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. + * + * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of + * `models`, encoded size of `models`, and the size limits in effect, executing this operation may require multiple + * `bulkWrite` commands. The eligibility for retries is determined per each `bulkWrite` command: + * [ClientNamespacedUpdateManyModel], [ClientNamespacedDeleteManyModel] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * @param clientSession The [client session][ClientSession] with which to associate this operation. + * @param models The [individual write operations][ClientNamespacedWriteModel]. + * @return The [ClientBulkWriteResult] if the operation is successful. + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: + * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], + * [ClientBulkWriteException.getPartialResult]. + * @throws MongoException Only if the operation is unsuccessful. + * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + */ + public suspend fun bulkWrite( + clientSession: ClientSession, + models: List + ): ClientBulkWriteResult = wrapped.bulkWrite(clientSession.wrapped, models).awaitSingle() + + /** + * Executes a client-level bulk write operation. + * + * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the + * number of `models`, encoded size of `models`, and the size limits in effect, executing this operation may require + * multiple `bulkWrite` commands. The eligibility for retries is determined per each `bulkWrite` command: + * [ClientNamespacedUpdateManyModel], [ClientNamespacedDeleteManyModel] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * @param clientSession The [client session][ClientSession] with which to associate this operation. + * @param models The [individual write operations][ClientNamespacedWriteModel]. + * @param options The options. + * @return The [ClientBulkWriteResult] if the operation is successful. + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: + * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], + * [ClientBulkWriteException.getPartialResult]. + * @throws MongoException Only if the operation is unsuccessful. + * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + */ + public suspend fun bulkWrite( + clientSession: ClientSession, + models: List, + options: ClientBulkWriteOptions + ): ClientBulkWriteResult = wrapped.bulkWrite(clientSession.wrapped, models, options).awaitSingle() } diff --git a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncMongoCluster.kt b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncMongoCluster.kt index a4ad9bd1418..b86f2447a17 100644 --- a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncMongoCluster.kt +++ b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncMongoCluster.kt @@ -113,39 +113,24 @@ internal open class SyncMongoCluster(open val wrapped: MongoCluster) : JMongoClu ): ChangeStreamIterable = SyncChangeStreamIterable(wrapped.watch(clientSession.unwrapped(), pipeline, resultClass)) - override fun bulkWrite(models: MutableList): ClientBulkWriteResult { - org.junit.jupiter.api.Assumptions.assumeTrue( - java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement") - TODO("BULK-TODO Kotlin implement") - } + override fun bulkWrite(models: MutableList): ClientBulkWriteResult = + wrapped.bulkWrite(models) override fun bulkWrite( models: MutableList, options: ClientBulkWriteOptions - ): ClientBulkWriteResult { - org.junit.jupiter.api.Assumptions.assumeTrue( - java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement") - TODO("BULK-TODO Kotlin implement") - } + ): ClientBulkWriteResult = wrapped.bulkWrite(models, options) override fun bulkWrite( clientSession: ClientSession, models: MutableList - ): ClientBulkWriteResult { - org.junit.jupiter.api.Assumptions.assumeTrue( - java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement") - TODO("BULK-TODO Kotlin implement") - } + ): ClientBulkWriteResult = wrapped.bulkWrite(clientSession.unwrapped(), models) override fun bulkWrite( clientSession: ClientSession, models: MutableList, options: ClientBulkWriteOptions - ): ClientBulkWriteResult { - org.junit.jupiter.api.Assumptions.assumeTrue( - java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement") - TODO("BULK-TODO Kotlin implement") - } + ): ClientBulkWriteResult = wrapped.bulkWrite(clientSession.unwrapped(), models, options) private fun ClientSession.unwrapped() = (this as SyncClientSession).wrapped } diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt index f541aaf1a9f..2d12adab677 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt @@ -15,13 +15,21 @@ */ package com.mongodb.kotlin.client +import com.mongodb.ClientBulkWriteException import com.mongodb.ClientSessionOptions +import com.mongodb.MongoClientSettings +import com.mongodb.MongoException import com.mongodb.ReadConcern import com.mongodb.ReadPreference import com.mongodb.WriteConcern import com.mongodb.annotations.Alpha import com.mongodb.annotations.Reason import com.mongodb.client.MongoCluster as JMongoCluster +import com.mongodb.client.model.bulk.ClientBulkWriteOptions +import com.mongodb.client.model.bulk.ClientBulkWriteResult +import com.mongodb.client.model.bulk.ClientNamespacedDeleteManyModel +import com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel +import com.mongodb.client.model.bulk.ClientNamespacedWriteModel import java.util.concurrent.TimeUnit import org.bson.Document import org.bson.codecs.configuration.CodecRegistry @@ -303,4 +311,104 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo clientSession: ClientSession, pipeline: List = emptyList() ): ChangeStreamIterable = watch(clientSession, pipeline, T::class.java) + + /** + * Executes a client-level bulk write operation. This method is functionally equivalent to [.bulkWrite] with the + * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. + * + * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of + * `models`, encoded size of `models`, and the size limits in effect, executing this operation may require multiple + * `bulkWrite` commands. The eligibility for retries is determined per each `bulkWrite` command: + * [ClientNamespacedUpdateManyModel], [ClientNamespacedDeleteManyModel] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * @param models The [individual write operations][ClientNamespacedWriteModel]. + * @return The [ClientBulkWriteResult] if the operation is successful. + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: + * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], + * [ClientBulkWriteException.getPartialResult]. + * @throws MongoException Only if the operation is unsuccessful. + * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + */ + public fun bulkWrite(models: List): ClientBulkWriteResult = wrapped.bulkWrite(models) + + /** + * Executes a client-level bulk write operation. + * + * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of + * `models`, encoded size of `models`, and the size limits in effect, executing this operation may require multiple + * `bulkWrite` commands. The eligibility for retries is determined per each `bulkWrite` command: + * [ClientNamespacedUpdateManyModel], [ClientNamespacedDeleteManyModel] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * @param models The [individual write operations][ClientNamespacedWriteModel]. + * @param options The options. + * @return The [ClientBulkWriteResult] if the operation is successful. + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: + * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], + * [ClientBulkWriteException.getPartialResult]. + * @throws MongoException Only if the operation is unsuccessful. + * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + */ + public fun bulkWrite( + models: List, + options: ClientBulkWriteOptions + ): ClientBulkWriteResult = wrapped.bulkWrite(models, options) + + /** + * Executes a client-level bulk write operation. This method is functionally equivalent to [.bulkWrite] with the + * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. + * + * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of + * `models`, encoded size of `models`, and the size limits in effect, executing this operation may require multiple + * `bulkWrite` commands. The eligibility for retries is determined per each `bulkWrite` command: + * [ClientNamespacedUpdateManyModel], [ClientNamespacedDeleteManyModel] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * @param clientSession The [client session][ClientSession] with which to associate this operation. + * @param models The [individual write operations][ClientNamespacedWriteModel]. + * @return The [ClientBulkWriteResult] if the operation is successful. + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: + * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], + * [ClientBulkWriteException.getPartialResult]. + * @throws MongoException Only if the operation is unsuccessful. + * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + */ + public fun bulkWrite( + clientSession: ClientSession, + models: List + ): ClientBulkWriteResult = wrapped.bulkWrite(clientSession.wrapped, models) + + /** + * Executes a client-level bulk write operation. + * + * This operation supports [retryable writes][com.mongodb.MongoClientSettings.getRetryWrites]. Depending on the + * number of `models`, encoded size of `models`, and the size limits in effect, executing this operation may require + * multiple `bulkWrite` commands. The eligibility for retries is determined per each `bulkWrite` command: + * [ClientNamespacedUpdateManyModel], [ClientNamespacedDeleteManyModel] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * @param clientSession The [client session][ClientSession] with which to associate this operation. + * @param models The [individual write operations][ClientNamespacedWriteModel]. + * @param options The options. + * @return The [ClientBulkWriteResult] if the operation is successful. + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: + * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], + * [ClientBulkWriteException.getPartialResult]. + * @throws MongoException Only if the operation is unsuccessful. + * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + */ + public fun bulkWrite( + clientSession: ClientSession, + models: List, + options: ClientBulkWriteOptions + ): ClientBulkWriteResult = wrapped.bulkWrite(clientSession.wrapped, models, options) } diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java index 1b7c3a40716..8141af36918 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java @@ -403,18 +403,6 @@ private void assertOperation(final UnifiedTestContext context, final BsonDocumen private static void assertOperationResult(final UnifiedTestContext context, final BsonDocument operation, final int operationIndex, final OperationResult result) { - if (result.getException() instanceof org.opentest4j.TestAbortedException) { - // BULK-TODO remove - if (result.getException().getMessage().contains("BULK-TODO Kotlin implement")) { - throw (org.opentest4j.TestAbortedException) result.getException(); - } - } - if (result.getException() instanceof org.junit.AssumptionViolatedException) { - // BULK-TODO remove - if (result.getException().getMessage().contains("BULK-TODO Kotlin implement")) { - throw (org.junit.AssumptionViolatedException) result.getException(); - } - } context.getAssertionContext().push(ContextElement.ofCompletedOperation(operation, result, operationIndex)); if (!operation.getBoolean("ignoreResultAndError", BsonBoolean.FALSE).getValue()) { From c82f9c8d057980d57ef06626f20074f80a3e8676 Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Thu, 2 Jan 2025 20:56:09 -0800 Subject: [PATCH 2/5] Add tests and correct Javadoc. JAVA-5532 --- .../kotlin/client/coroutine/MongoCluster.kt | 24 ++++++++----- .../client/coroutine/MongoClientTest.kt | 28 +++++++++++++++ .../com/mongodb/kotlin/client/MongoCluster.kt | 36 +++++++++++-------- .../mongodb/kotlin/client/MongoClientTest.kt | 26 ++++++++++++++ 4 files changed, 90 insertions(+), 24 deletions(-) diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt index 0f56212916b..b49ea077322 100644 --- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt +++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt @@ -317,7 +317,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ChangeStreamFlow = watch(clientSession, pipeline, T::class.java) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to [.bulkWrite] with the + * Executes a client-level bulk write operation. This method is functionally equivalent to `bulkWrite(models: + * List, options: ClientBulkWriteOptions)` with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of @@ -334,7 +335,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) + * @since 5.3 */ public suspend fun bulkWrite(models: List): ClientBulkWriteResult = wrapped.bulkWrite(models).awaitSingle() @@ -357,7 +359,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) + * @since 5.3 */ public suspend fun bulkWrite( models: List, @@ -365,7 +368,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ClientBulkWriteResult = wrapped.bulkWrite(models, options).awaitSingle() /** - * Executes a client-level bulk write operation. This method is functionally equivalent to [.bulkWrite] with the + * Executes a client-level bulk write operation. This method is functionally equivalent to `bulkWrite(clientSession: + * ClientSession, models: List, options: ClientBulkWriteOptions)`with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of @@ -383,7 +387,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) + * @since 5.3 */ public suspend fun bulkWrite( clientSession: ClientSession, @@ -393,9 +398,9 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo /** * Executes a client-level bulk write operation. * - * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the - * number of `models`, encoded size of `models`, and the size limits in effect, executing this operation may require - * multiple `bulkWrite` commands. The eligibility for retries is determined per each `bulkWrite` command: + * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of + * `models`, encoded size of `models`, and the size limits in effect, executing this operation may require multiple + * `bulkWrite` commands. The eligibility for retries is determined per each `bulkWrite` command: * [ClientNamespacedUpdateManyModel], [ClientNamespacedDeleteManyModel] in a command render it non-retryable. * * This operation is not supported by MongoDB Atlas Serverless instances. @@ -409,7 +414,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) + * @since 5.3 */ public suspend fun bulkWrite( clientSession: ClientSession, diff --git a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/MongoClientTest.kt b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/MongoClientTest.kt index 9ac4805f6fa..fd66e4de31b 100644 --- a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/MongoClientTest.kt +++ b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/MongoClientTest.kt @@ -16,6 +16,9 @@ package com.mongodb.kotlin.client.coroutine import com.mongodb.ClientSessionOptions +import com.mongodb.MongoNamespace +import com.mongodb.client.model.bulk.ClientBulkWriteOptions +import com.mongodb.client.model.bulk.ClientNamespacedWriteModel import com.mongodb.reactivestreams.client.MongoClient as JMongoClient import kotlin.reflect.full.declaredFunctions import kotlin.test.assertEquals @@ -166,4 +169,29 @@ class MongoClientTest { verify(wrapped, times(2)).watch(clientSession.wrapped, pipeline, BsonDocument::class.java) verifyNoMoreInteractions(wrapped) } + + @Test + fun shouldCallTheUnderlyingBulkWrite() { + val mongoClient = MongoClient(wrapped) + val requests = listOf(ClientNamespacedWriteModel.insertOne(MongoNamespace("test.test"), Document())) + val options = ClientBulkWriteOptions.clientBulkWriteOptions().bypassDocumentValidation(true) + + whenever(wrapped.bulkWrite(requests)).doReturn(Mono.fromCallable { mock() }) + whenever(wrapped.bulkWrite(requests, options)).doReturn(Mono.fromCallable { mock() }) + whenever(wrapped.bulkWrite(clientSession.wrapped, requests)).doReturn(Mono.fromCallable { mock() }) + whenever(wrapped.bulkWrite(clientSession.wrapped, requests, options)).doReturn(Mono.fromCallable { mock() }) + + runBlocking { + mongoClient.bulkWrite(requests) + mongoClient.bulkWrite(requests, options) + mongoClient.bulkWrite(clientSession, requests) + mongoClient.bulkWrite(clientSession, requests, options) + } + + verify(wrapped).bulkWrite(requests) + verify(wrapped).bulkWrite(requests, options) + verify(wrapped).bulkWrite(clientSession.wrapped, requests) + verify(wrapped).bulkWrite(clientSession.wrapped, requests, options) + verifyNoMoreInteractions(wrapped) + } } diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt index 2d12adab677..546590645cb 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt @@ -313,7 +313,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ChangeStreamIterable = watch(clientSession, pipeline, T::class.java) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to [.bulkWrite] with the + * Executes a client-level bulk write operation. This method is functionally equivalent to + * `bulkWrite(models: List, options: ClientBulkWriteOptions)` with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of @@ -325,12 +326,13 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * * @param models The [individual write operations][ClientNamespacedWriteModel]. * @return The [ClientBulkWriteResult] if the operation is successful. - * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and - * there is at least one of the following pieces of information to report: + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, + * and there is at least one of the following pieces of information to report: * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + * @since 5.3 + * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) */ public fun bulkWrite(models: List): ClientBulkWriteResult = wrapped.bulkWrite(models) @@ -347,12 +349,13 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * @param models The [individual write operations][ClientNamespacedWriteModel]. * @param options The options. * @return The [ClientBulkWriteResult] if the operation is successful. - * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and - * there is at least one of the following pieces of information to report: + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, + * and there is at least one of the following pieces of information to report: * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + * @since 5.3 + * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) */ public fun bulkWrite( models: List, @@ -360,8 +363,9 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ClientBulkWriteResult = wrapped.bulkWrite(models, options) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to [.bulkWrite] with the - * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. + * Executes a client-level bulk write operation. This method is functionally equivalent to + * `bulkWrite(clientSession: ClientSession, models: List, options: + * ClientBulkWriteOptions)` with the [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of * `models`, encoded size of `models`, and the size limits in effect, executing this operation may require multiple @@ -373,12 +377,13 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * @param clientSession The [client session][ClientSession] with which to associate this operation. * @param models The [individual write operations][ClientNamespacedWriteModel]. * @return The [ClientBulkWriteResult] if the operation is successful. - * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and - * there is at least one of the following pieces of information to report: + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, + * and there is at least one of the following pieces of information to report: * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + * @since 5.3 + * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) */ public fun bulkWrite( clientSession: ClientSession, @@ -399,12 +404,13 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * @param models The [individual write operations][ClientNamespacedWriteModel]. * @param options The options. * @return The [ClientBulkWriteResult] if the operation is successful. - * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and - * there is at least one of the following pieces of information to report: + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, + * and there is at least one of the following pieces of information to report: * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 @mongodb.server.release 8.0 @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite + * @since 5.3 + * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) */ public fun bulkWrite( clientSession: ClientSession, diff --git a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoClientTest.kt b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoClientTest.kt index 0999e77080e..75bbd7608ed 100644 --- a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoClientTest.kt +++ b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoClientTest.kt @@ -16,6 +16,9 @@ package com.mongodb.kotlin.client import com.mongodb.ClientSessionOptions +import com.mongodb.MongoNamespace +import com.mongodb.client.model.bulk.ClientBulkWriteOptions +import com.mongodb.client.model.bulk.ClientNamespacedWriteModel import com.mongodb.client.MongoClient as JMongoClient import kotlin.reflect.full.declaredFunctions import kotlin.reflect.full.declaredMemberProperties @@ -168,4 +171,27 @@ class MongoClientTest { verify(wrapped, times(2)).watch(clientSession.wrapped, pipeline, BsonDocument::class.java) verifyNoMoreInteractions(wrapped) } + + @Test + fun shouldCallTheUnderlyingBulkWrite() { + val mongoClient = MongoClient(wrapped) + val requests = listOf(ClientNamespacedWriteModel.insertOne(MongoNamespace("test.test"), Document())) + val options = ClientBulkWriteOptions.clientBulkWriteOptions().bypassDocumentValidation(true) + + whenever(wrapped.bulkWrite(requests)).doReturn(mock()) + whenever(wrapped.bulkWrite(requests, options)).doReturn(mock()) + whenever(wrapped.bulkWrite(clientSession.wrapped, requests)).doReturn(mock()) + whenever(wrapped.bulkWrite(clientSession.wrapped, requests, options)).doReturn(mock()) + + mongoClient.bulkWrite(requests) + mongoClient.bulkWrite(requests, options) + mongoClient.bulkWrite(clientSession, requests) + mongoClient.bulkWrite(clientSession, requests, options) + + verify(wrapped).bulkWrite(requests) + verify(wrapped).bulkWrite(requests, options) + verify(wrapped).bulkWrite(clientSession.wrapped, requests) + verify(wrapped).bulkWrite(clientSession.wrapped, requests, options) + verifyNoMoreInteractions(wrapped) + } } From 80ba415e2d1e2f79b6f3fbc4f8af7cbe18d9e9bd Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Thu, 2 Jan 2025 20:57:19 -0800 Subject: [PATCH 3/5] Apply spotless. JAVA-5532 --- .../com/mongodb/kotlin/client/MongoCluster.kt | 34 +++++++++---------- .../mongodb/kotlin/client/MongoClientTest.kt | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt index 546590645cb..8bda3849e98 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt @@ -313,8 +313,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ChangeStreamIterable = watch(clientSession, pipeline, T::class.java) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to - * `bulkWrite(models: List, options: ClientBulkWriteOptions)` with the + * Executes a client-level bulk write operation. This method is functionally equivalent to `bulkWrite(models: + * List, options: ClientBulkWriteOptions)` with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of @@ -326,13 +326,13 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * * @param models The [individual write operations][ClientNamespacedWriteModel]. * @return The [ClientBulkWriteResult] if the operation is successful. - * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, - * and there is at least one of the following pieces of information to report: + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) + * @since 5.3 */ public fun bulkWrite(models: List): ClientBulkWriteResult = wrapped.bulkWrite(models) @@ -349,13 +349,13 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * @param models The [individual write operations][ClientNamespacedWriteModel]. * @param options The options. * @return The [ClientBulkWriteResult] if the operation is successful. - * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, - * and there is at least one of the following pieces of information to report: + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) + * @since 5.3 */ public fun bulkWrite( models: List, @@ -363,9 +363,9 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ClientBulkWriteResult = wrapped.bulkWrite(models, options) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to - * `bulkWrite(clientSession: ClientSession, models: List, options: - * ClientBulkWriteOptions)` with the [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. + * Executes a client-level bulk write operation. This method is functionally equivalent to `bulkWrite(clientSession: + * ClientSession, models: List, options: ClientBulkWriteOptions)` with the + * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of * `models`, encoded size of `models`, and the size limits in effect, executing this operation may require multiple @@ -377,13 +377,13 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * @param clientSession The [client session][ClientSession] with which to associate this operation. * @param models The [individual write operations][ClientNamespacedWriteModel]. * @return The [ClientBulkWriteResult] if the operation is successful. - * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, - * and there is at least one of the following pieces of information to report: + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) + * @since 5.3 */ public fun bulkWrite( clientSession: ClientSession, @@ -404,13 +404,13 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * @param models The [individual write operations][ClientNamespacedWriteModel]. * @param options The options. * @return The [ClientBulkWriteResult] if the operation is successful. - * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, - * and there is at least one of the following pieces of information to report: + * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and + * there is at least one of the following pieces of information to report: * [ClientBulkWriteException.getWriteConcernErrors], [ClientBulkWriteException.getWriteErrors], * [ClientBulkWriteException.getPartialResult]. * @throws MongoException Only if the operation is unsuccessful. - * @since 5.3 * @see [BulkWrite command](https://www.mongodb.com/docs/manual/reference/command/bulkWrite/) + * @since 5.3 */ public fun bulkWrite( clientSession: ClientSession, diff --git a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoClientTest.kt b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoClientTest.kt index 75bbd7608ed..0aa0c582ff4 100644 --- a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoClientTest.kt +++ b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoClientTest.kt @@ -17,9 +17,9 @@ package com.mongodb.kotlin.client import com.mongodb.ClientSessionOptions import com.mongodb.MongoNamespace +import com.mongodb.client.MongoClient as JMongoClient import com.mongodb.client.model.bulk.ClientBulkWriteOptions import com.mongodb.client.model.bulk.ClientNamespacedWriteModel -import com.mongodb.client.MongoClient as JMongoClient import kotlin.reflect.full.declaredFunctions import kotlin.reflect.full.declaredMemberProperties import kotlin.test.assertEquals From 8f93e81e73441676a174daddfd6283c19043e76a Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Thu, 2 Jan 2025 22:38:40 -0800 Subject: [PATCH 4/5] Change Kdoc. JAVA-5532 --- .../com/mongodb/kotlin/client/coroutine/MongoCluster.kt | 6 ++---- .../main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt index b49ea077322..5f55f590812 100644 --- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt +++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt @@ -317,8 +317,7 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ChangeStreamFlow = watch(clientSession, pipeline, T::class.java) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to `bulkWrite(models: - * List, options: ClientBulkWriteOptions)` with the + * Executes a client-level bulk write operation. This method is functionally equivalent to [bulkWrite] with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of @@ -368,8 +367,7 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ClientBulkWriteResult = wrapped.bulkWrite(models, options).awaitSingle() /** - * Executes a client-level bulk write operation. This method is functionally equivalent to `bulkWrite(clientSession: - * ClientSession, models: List, options: ClientBulkWriteOptions)`with the + * Executes a client-level bulk write operation. This method is functionally equivalent to [bulkWrite] with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt index 8bda3849e98..996fb39e8b0 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt @@ -313,8 +313,7 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ChangeStreamIterable = watch(clientSession, pipeline, T::class.java) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to `bulkWrite(models: - * List, options: ClientBulkWriteOptions)` with the + * Executes a client-level bulk write operation. This method is functionally equivalent to [bulkWrite] with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of @@ -363,8 +362,7 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ClientBulkWriteResult = wrapped.bulkWrite(models, options) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to `bulkWrite(clientSession: - * ClientSession, models: List, options: ClientBulkWriteOptions)` with the + * Executes a client-level bulk write operation. This method is functionally equivalent to [bulkWrite] with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of From 33c5eb6979a2c74c8b949e0bf2020491234d9955 Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Thu, 2 Jan 2025 22:53:26 -0800 Subject: [PATCH 5/5] Change Kdoc. JAVA-5532 --- .../mongodb/kotlin/client/coroutine/MongoCluster.kt | 10 ++++++---- .../kotlin/com/mongodb/kotlin/client/MongoCluster.kt | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt index 5f55f590812..65ec0aa7f45 100644 --- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt +++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCluster.kt @@ -317,7 +317,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ChangeStreamFlow = watch(clientSession, pipeline, T::class.java) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to [bulkWrite] with the + * Executes a client-level bulk write operation. This method is functionally equivalent to + * [bulkWrite(models, options)][bulkWrite] with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of @@ -351,7 +352,7 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * This operation is not supported by MongoDB Atlas Serverless instances. * * @param models The [individual write operations][ClientNamespacedWriteModel]. - * @param options The options. + * @param options The [options][ClientBulkWriteOptions]. * @return The [ClientBulkWriteResult] if the operation is successful. * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and * there is at least one of the following pieces of information to report: @@ -367,7 +368,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ClientBulkWriteResult = wrapped.bulkWrite(models, options).awaitSingle() /** - * Executes a client-level bulk write operation. This method is functionally equivalent to [bulkWrite] with the + * Executes a client-level bulk write operation. This method is functionally equivalent to + * [bulkWrite(clientSession, models, options)][bulkWrite] with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of @@ -405,7 +407,7 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * * @param clientSession The [client session][ClientSession] with which to associate this operation. * @param models The [individual write operations][ClientNamespacedWriteModel]. - * @param options The options. + * @param options The [options][ClientBulkWriteOptions]. * @return The [ClientBulkWriteResult] if the operation is successful. * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and * there is at least one of the following pieces of information to report: diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt index 996fb39e8b0..90fb45d1dbd 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt @@ -313,7 +313,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ChangeStreamIterable = watch(clientSession, pipeline, T::class.java) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to [bulkWrite] with the + * Executes a client-level bulk write operation. This method is functionally equivalent to + * [bulkWrite(models, options)][bulkWrite] with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of @@ -346,7 +347,7 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * This operation is not supported by MongoDB Atlas Serverless instances. * * @param models The [individual write operations][ClientNamespacedWriteModel]. - * @param options The options. + * @param options The [options][ClientBulkWriteOptions]. * @return The [ClientBulkWriteResult] if the operation is successful. * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and * there is at least one of the following pieces of information to report: @@ -362,7 +363,8 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo ): ClientBulkWriteResult = wrapped.bulkWrite(models, options) /** - * Executes a client-level bulk write operation. This method is functionally equivalent to [bulkWrite] with the + * Executes a client-level bulk write operation. This method is functionally equivalent to + * [bulkWrite(clientSession, models, options)][bulkWrite] with the * [default options][ClientBulkWriteOptions.clientBulkWriteOptions]. * * This operation supports [retryable writes][MongoClientSettings.getRetryWrites]. Depending on the number of @@ -400,7 +402,7 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * * @param clientSession The [client session][ClientSession] with which to associate this operation. * @param models The [individual write operations][ClientNamespacedWriteModel]. - * @param options The options. + * @param options The [options][ClientBulkWriteOptions]. * @return The [ClientBulkWriteResult] if the operation is successful. * @throws ClientBulkWriteException If and only if the operation is unsuccessful or partially unsuccessful, and * there is at least one of the following pieces of information to report: