Skip to content

HasSample

Pipeline implementing the $sample stage.

Inheritors

Properties

context

@LowLevelApi



abstract val context: BsonContext

The context used to generate this pipeline.

Functions

reinterpret

@DangerousMongoApi



@LowLevelApi



abstract fun <New : Any> reinterpret(): Pipeline<New>

Changes the type of the returned document, with no type-safety.

sample

open fun sample(size: Int): Pipeline<Document>

Randomly selects size documents.

Pipeline optimizations

MongoDB is able to perform sampling more efficiently if it is the first stage of the pipeline and size is less than 5% of the collection size.

External resources

See also

toString

abstract override fun toString(): String

JSON representation of this pipeline.

withStage

@DangerousMongoApi



@LowLevelApi



abstract fun withStage(stage: BsonNode): Pipeline<Document>

Creates a new pipeline that expands on the current one by adding stage.

writeTo

@LowLevelApi



abstract fun writeTo(writer: BsonValueWriter)

Writes the entire pipeline into writer.