MCPcopy Create free account
hub / github.com/apache/arrow / Call

Method Call

cpp/src/arrow/compute/kernels/scalar_string_utf8.cc:255–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253
254struct IsTitleUnicode {
255 static bool Call(KernelContext*, const uint8_t* input, size_t input_string_ncodeunits,
256 Status* st) {
257 // rules:
258 // 1. lower case follows cased
259 // 2. upper case follows uncased
260 // 3. at least 1 cased character (which logically should be upper/title)
261 bool rules_1_and_2;
262 bool previous_cased = false; // in LL, LU or LT
263 bool rule_3 = false;
264 bool status =
265 arrow::util::UTF8AllOf(input, input + input_string_ncodeunits, &rules_1_and_2,
266 [&previous_cased, &rule_3](uint32_t codepoint) {
267 if (IsLowerCaseCharacterUnicode(codepoint)) {
268 if (!previous_cased) return false; // rule 1 broken
269 // next should be more lower case or uncased
270 previous_cased = true;
271 } else if (IsCasedCharacterUnicode(codepoint)) {
272 if (previous_cased) return false; // rule 2 broken
273 // next should be a lower case or uncased
274 previous_cased = true;
275 rule_3 = true; // rule 3 obeyed
276 } else {
277 // an uncased char, like _ or 1
278 // next should be upper case or more uncased
279 previous_cased = false;
280 }
281 return true;
282 });
283 if (!ARROW_PREDICT_TRUE(status)) {
284 *st = Status::Invalid("Invalid UTF8 sequence in input");
285 return false;
286 }
287 return rules_1_and_2 & rule_3;
288 }
289};
290
291struct IsUpperUnicode : CharacterPredicateUnicode<IsUpperUnicode> {

Callers

nothing calls this directly

Calls 4

UTF8AllOfFunction · 0.85
IsCasedCharacterUnicodeFunction · 0.85
InvalidFunction · 0.50

Tested by

no test coverage detected