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

Function JsonEscapeString

be/src/service/query-profile-redaction.cc:91–101  ·  view source on GitHub ↗

Escapes a string so it can be safely matched within JSON-serialized text.

Source from the content-addressed store, hash-verified

89
90// Escapes a string so it can be safely matched within JSON-serialized text.
91static string JsonEscapeString(const string_view& input) {
92 StringBuffer buffer;
93 Writer<StringBuffer> writer(buffer);
94 writer.String(input.data(), static_cast<rapidjson::SizeType>(input.size()));
95 const char* p = buffer.GetString();
96 const size_t n = buffer.GetSize();
97 const size_t start = n >= 1 && p[0] == '"' ? 1 : 0;
98 const size_t end = n >= 1 && p[n - 1] == '"' ? n - 1 : n;
99 if (end < start) return "";
100 return string(p + start, end - start);
101}
102
103// Collects unique regex matches from text for the requested capture group.
104static vector<string> CollectRegexMatches(

Callers 1

Calls 5

GetSizeMethod · 0.80
StringMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected