sample method
Keeps a random sample of the inputs: either a number of documents, or
a percentage of them between 0 and 1. Exactly one must be given.
Implementation
Pipeline sample({
int? documents,
double? percentage,
Map<String, Object?>? rawOptions,
}) {
if ((documents == null) == (percentage == null)) {
throw ArgumentError(
'sample() needs exactly one of documents and percentage.',
);
}
return _append(
Stage(
'sample',
args: <pb.Value Function(PipelineEncoder)>[
(_) => documents != null
? integerValue(documents)
: doubleValue(percentage!),
(_) => stringValue(documents != null ? 'documents' : 'percent'),
],
rawOptions: rawOptions,
),
);
}