| 59 | } |
| 60 | |
| 61 | Status ExecRandom(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) { |
| 62 | static random::pcg64_oneseq seed_gen = MakeSeedGenerator(); |
| 63 | static std::mutex seed_gen_mutex; |
| 64 | |
| 65 | random::pcg64_oneseq gen; |
| 66 | const RandomOptions& options = RandomState::Get(ctx); |
| 67 | |
| 68 | if (options.initializer == RandomOptions::Seed) { |
| 69 | gen.seed(options.seed); |
| 70 | } else { |
| 71 | std::lock_guard<std::mutex> seed_gen_lock(seed_gen_mutex); |
| 72 | gen.seed(seed_gen()); |
| 73 | } |
| 74 | double* out_values = out->array_span_mutable()->GetValues<double>(1); |
| 75 | for (int64_t i = 0; i < batch.length; ++i) { |
| 76 | out_values[i] = generate_uniform(&gen); |
| 77 | } |
| 78 | return Status::OK(); |
| 79 | } |
| 80 | |
| 81 | const FunctionDoc random_doc{ |
| 82 | "Generate numbers in the range [0, 1)", |
nothing calls this directly
no test coverage detected