SampleStage

class SampleStage : Stage


Performs a pseudo-random sampling of the input documents.

The documents produced from this stage are non-deterministic, running the same query over the same dataset multiple times will produce different results. There are two different ways to dictate how the sample is calculated either by specifying a target output size, or by specifying a target percentage of the input size.

Summary

Nested types

Public companion functions

SampleStage
withDocLimit(results: Int)

Creates SampleStage with the specified number of results returned.

SampleStage
withPercentage(percentage: Double)

Creates SampleStage with size limited to percentage of prior stages results.

Public functions

open operator Boolean
equals(other: Any?)
open Int

Inherited functions

From com.google.firebase.firestore.pipeline.Stage
SampleStage
SampleStage
withOption(key: String, value: Boolean)

Specify named Boolean parameter

SampleStage
withOption(key: String, value: Double)

Specify named Double parameter

SampleStage
withOption(key: String, value: Field)

Specify named Field parameter

SampleStage
withOption(key: String, value: Long)

Specify named Long parameter

SampleStage
withOption(key: String, value: String)

Specify named String parameter

Public companion functions

withDocLimit

fun withDocLimit(results: Int): SampleStage

Creates SampleStage with the specified number of results returned.

The results parameter represents the number of results to produce and must be a non-negative integer value. If the previous stage produces less than the specified number, the entire previous results are returned. If the previous stage produces more than the specified number, this stage samples the specified number of documents from the previous stage, with equal probability for each result.

Parameters
results: Int

The number of documents to emit.

Returns
SampleStage

SampleStage with specified documents.

withPercentage

fun withPercentage(percentage: Double): SampleStage

Creates SampleStage with size limited to percentage of prior stages results.

The percentage parameter is the target percentage (between 0.0 & 1.0) of the number of input documents to produce. Each input document is independently selected against the given percentage. As a result the output size will be approximately documents * percentage.

Parameters
percentage: Double

The percentage of the prior stages documents to emit.

Returns
SampleStage

SampleStage with specified percentage.

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int