MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / sample

Method sample

programs/obfuscator/Obfuscator.cpp:607–624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605 }
606
607 CodePoint sample(UInt64 random, double end_multiplier) const
608 {
609 UInt64 range = total + static_cast<UInt64>(static_cast<double>(count_end) * end_multiplier);
610 if (range == 0)
611 return END;
612
613 random %= range;
614
615 UInt64 sum = 0;
616 for (const auto & elem : buckets)
617 {
618 sum += elem.second;
619 if (sum > random)
620 return elem.first;
621 }
622
623 return END;
624 }
625
626 void serialize(WriteBuffer & out) const
627 {

Callers 1

generateMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected