MCPcopy Create free account
hub / github.com/apache/arrow / ExecRandom

Function ExecRandom

cpp/src/arrow/compute/kernels/scalar_random.cc:61–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61Status 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
81const FunctionDoc random_doc{
82 "Generate numbers in the range [0, 1)",

Callers

nothing calls this directly

Calls 4

MakeSeedGeneratorFunction · 0.85
generate_uniformFunction · 0.85
GetFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected