@@ -33,9 +33,7 @@ import kotlinx.coroutines.flow.drop
3333import kotlinx.coroutines.flow.emptyFlow
3434import kotlinx.coroutines.flow.filter
3535import kotlinx.coroutines.flow.flow
36- import kotlinx.coroutines.flow.forEach
3736import kotlinx.coroutines.flow.map
38- import kotlinx.coroutines.flow.skip
3937import kotlinx.coroutines.flow.take
4038import kotlinx.coroutines.flow.toList
4139
@@ -54,7 +52,7 @@ sealed class Stage<T : Stage<T>>(
5452
5553 internal abstract fun self (options : InternalOptions ): T
5654
57- protected fun with (key : String , value : Value ): T = self(options.with (key, value))
55+ protected fun withOption (key : String , value : Value ): T = self(options.with (key, value))
5856
5957 /* *
6058 * Specify named [String] parameter
@@ -63,7 +61,7 @@ sealed class Stage<T : Stage<T>>(
6361 * @param value The [String] value of parameter
6462 * @return New stage with named parameter.
6563 */
66- fun with (key : String , value : String ): T = with (key, Values .encodeValue(value))
64+ fun withOption (key : String , value : String ): T = withOption (key, Values .encodeValue(value))
6765
6866 /* *
6967 * Specify named [Boolean] parameter
@@ -72,7 +70,7 @@ sealed class Stage<T : Stage<T>>(
7270 * @param value The [Boolean] value of parameter
7371 * @return New stage with named parameter.
7472 */
75- fun with (key : String , value : Boolean ): T = with (key, Values .encodeValue(value))
73+ fun withOption (key : String , value : Boolean ): T = withOption (key, Values .encodeValue(value))
7674
7775 /* *
7876 * Specify named [Long] parameter
@@ -81,7 +79,7 @@ sealed class Stage<T : Stage<T>>(
8179 * @param value The [Long] value of parameter
8280 * @return New stage with named parameter.
8381 */
84- fun with (key : String , value : Long ): T = with (key, Values .encodeValue(value))
82+ fun withOption (key : String , value : Long ): T = withOption (key, Values .encodeValue(value))
8583
8684 /* *
8785 * Specify named [Double] parameter
@@ -90,7 +88,7 @@ sealed class Stage<T : Stage<T>>(
9088 * @param value The [Double] value of parameter
9189 * @return New stage with named parameter.
9290 */
93- fun with (key : String , value : Double ): T = with (key, Values .encodeValue(value))
91+ fun withOption (key : String , value : Double ): T = withOption (key, Values .encodeValue(value))
9492
9593 /* *
9694 * Specify named [Field] parameter
@@ -99,7 +97,7 @@ sealed class Stage<T : Stage<T>>(
9997 * @param value The [Field] value of parameter
10098 * @return New stage with named parameter.
10199 */
102- fun with (key : String , value : Field ): T = with (key, value.toProto())
100+ fun withOption (key : String , value : Field ): T = withOption (key, value.toProto())
103101
104102 internal open fun evaluate (
105103 context : EvaluationContext ,
@@ -232,7 +230,7 @@ internal constructor(
232230 }
233231 }
234232
235- fun withForceIndex (value : String ) = with (" force_index" , value)
233+ fun withForceIndex (value : String ) = withOption (" force_index" , value)
236234
237235 override fun evaluate (
238236 context : EvaluationContext ,
@@ -276,7 +274,7 @@ private constructor(private val collectionId: String, options: InternalOptions)
276274 }
277275 }
278276
279- fun withForceIndex (value : String ) = with (" force_index" , value)
277+ fun withForceIndex (value : String ) = withOption (" force_index" , value)
280278}
281279
282280internal class DocumentsSource
@@ -508,7 +506,7 @@ internal constructor(
508506 * @param limit must be a positive integer.
509507 * @return [FindNearestStage] with specified [limit].
510508 */
511- fun withLimit (limit : Long ): FindNearestStage = with (" limit" , limit)
509+ fun withLimit (limit : Long ): FindNearestStage = withOption (" limit" , limit)
512510
513511 /* *
514512 * Add a field containing the distance to the result.
@@ -517,7 +515,7 @@ internal constructor(
517515 * @return [FindNearestStage] with specified [distanceField].
518516 */
519517 fun withDistanceField (distanceField : Field ): FindNearestStage =
520- with (" distance_field" , distanceField)
518+ withOption (" distance_field" , distanceField)
521519
522520 /* *
523521 * Add a field containing the distance to the result.
@@ -825,5 +823,5 @@ internal constructor(
825823 * @param indexField The field name of index field.
826824 * @return [SampleStage] that includes specified index field.
827825 */
828- fun withIndexField (indexField : String ): UnnestStage = with (" index_field" , indexField)
826+ fun withIndexField (indexField : String ): UnnestStage = withOption (" index_field" , indexField)
829827}
0 commit comments