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

Function GetSeedGenerator

cpp/src/arrow/util/io_util.cc:2125–2142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2123}
2124
2125std::mt19937_64 GetSeedGenerator() {
2126 // Initialize Mersenne Twister PRNG with a true random seed.
2127 // Make sure to mix in process id to minimize risks of clashes when parallel testing.
2128#ifdef ARROW_VALGRIND
2129 // Valgrind can crash, hang or enter an infinite loop on std::random_device,
2130 // use a crude initializer instead.
2131 const uint8_t dummy = 0;
2132 ARROW_UNUSED(dummy);
2133 std::mt19937_64 seed_gen(reinterpret_cast<uintptr_t>(&dummy) ^
2134 static_cast<uintptr_t>(GetPid()));
2135#else
2136 std::random_device true_random;
2137 std::mt19937_64 seed_gen(static_cast<uint64_t>(true_random()) ^
2138 (static_cast<uint64_t>(true_random()) << 32) ^
2139 static_cast<uint64_t>(GetPid()));
2140#endif
2141 return seed_gen;
2142}
2143
2144} // namespace
2145

Callers 1

GetRandomSeedFunction · 0.85

Calls 1

GetPidFunction · 0.85

Tested by

no test coverage detected