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

Function GetSortedReplacementEntries

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

Materializes replacement map entries as string_views and sorts them deterministically for safe replacement order.

Source from the content-addressed store, hash-verified

187// Materializes replacement map entries as string_views and sorts them
188// deterministically for safe replacement order.
189static vector<pair<string_view, string_view>> GetSortedReplacementEntries(
190 const unordered_map<string, string>& replacements) {
191 vector<pair<string_view, string_view>> entries;
192 entries.reserve(replacements.size());
193 for (const auto& entry : replacements) {
194 entries.emplace_back(entry.first, entry.second);
195 }
196 // Sort longer source tokens first so nested/overlapping names are replaced atomically
197 // (e.g. replacing "table.column" before "table") and avoid partial matches.
198 sort(entries.begin(), entries.end(),
199 [](const auto& a, const auto& b) {
200 if (a.first.size() != b.first.size()) return a.first.size() > b.first.size();
201 return a.first < b.first;
202 });
203 return entries;
204}
205
206// Returns true if the character is part of a SQL identifier token.
207static inline bool IsIdentifierChar(char c) {

Callers 1

ApplyAliasMapFunction · 0.85

Calls 5

sortFunction · 0.85
reserveMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected