MCPcopy Create free account
hub / github.com/apache/impala / ParseProbability

Function ParseProbability

be/src/util/debug-util.cc:403–414  ·  view source on GitHub ↗

Helper to DebugActionImpl(). Given a probability as a string (e.g. "0.3"), determine whether the action should be executed, as returned in 'should_execute'. Returns true if the parsing was successful.

Source from the content-addressed store, hash-verified

401/// determine whether the action should be executed, as returned in 'should_execute'.
402/// Returns true if the parsing was successful.
403static bool ParseProbability(const string& prob_str, bool* should_execute) {
404 StringParser::ParseResult parse_result;
405 double probability = StringParser::StringToFloat<double>(
406 prob_str.c_str(), prob_str.size(), &parse_result);
407 if (parse_result != StringParser::PARSE_SUCCESS ||
408 probability < 0.0 || probability > 1.0) {
409 return false;
410 }
411 // +1L ensures probability of 0.0 and 1.0 work as expected.
412 *should_execute = rand() < probability * (RAND_MAX + 1L);
413 return true;
414}
415
416/// The catalog java code also implements a equivalent method for processing the debug
417/// actions in the Java code. See DebugUtils.java for more details. Any changes to the

Callers 1

DebugActionImplFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected