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

Function markerHexDecode

programs/client/FuzzLoop.cpp:565–584  ·  view source on GitHub ↗

Decode a hex string written by markerHexEncode.

Source from the content-addressed store, hash-verified

563
564/// Decode a hex string written by markerHexEncode.
565static String markerHexDecode(const String & s)
566{
567 if (s.size() % 2 != 0)
568 throw Exception(ErrorCodes::CANNOT_PARSE_TEXT, "markerHexDecode: odd-length input '{}'", s);
569 auto nibble = [&](const char c) -> uint8_t
570 {
571 if (c >= '0' && c <= '9')
572 return static_cast<uint8_t>(c - '0');
573 if (c >= 'A' && c <= 'F')
574 return static_cast<uint8_t>(c - 'A' + 10);
575 if (c >= 'a' && c <= 'f')
576 return static_cast<uint8_t>(c - 'a' + 10);
577 throw Exception(ErrorCodes::CANNOT_PARSE_TEXT, "markerHexDecode: invalid hex character '{}' in '{}'", c, s);
578 };
579 String result;
580 result.reserve(s.size() / 2);
581 for (size_t i = 0; i < s.size(); i += 2)
582 result += static_cast<char>((nibble(s[i]) << 4) | nibble(s[i + 1]));
583 return result;
584}
585
586/// Returns false when server is not available.
587bool Client::buzzHouse()

Callers 1

buzzHouseMethod · 0.85

Calls 3

ExceptionClass · 0.50
sizeMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected