kou commented on code in PR #33806:
URL: https://github.com/apache/arrow/pull/33806#discussion_r1083228638
##########
cpp/src/arrow/compute/kernels/scalar_string_ascii.cc:
##########
@@ -1505,6 +1508,13 @@ struct MatchLike {
static const RE2 kLikePatternIsStartsWith(R"(([^%_]*[^\\%_])?%+)",
kRE2Options);
// A LIKE pattern matching this regex can be translated into a suffix
search.
static const RE2 kLikePatternIsEndsWith(R"(%+([^%_]*))", kRE2Options);
+ static bool global_checked = false;
Review Comment:
Can we use `std::once_flag`?
##########
cpp/src/arrow/compute/kernels/scalar_string_ascii.cc:
##########
@@ -1505,6 +1508,13 @@ struct MatchLike {
static const RE2 kLikePatternIsStartsWith(R"(([^%_]*[^\\%_])?%+)",
kRE2Options);
// A LIKE pattern matching this regex can be translated into a suffix
search.
static const RE2 kLikePatternIsEndsWith(R"(%+([^%_]*))", kRE2Options);
+ static bool global_checked = false;
+ if (ARROW_PREDICT_FALSE(!global_checked)) {
+ RETURN_NOT_OK(RegexStatus(kLikePatternIsSubstringMatch));
+ RETURN_NOT_OK(RegexStatus(kLikePatternIsStartsWith));
+ RETURN_NOT_OK(RegexStatus(kLikePatternIsEndsWith));
Review Comment:
If we have an error in these patterns, does this code report an error on the
second call? (It seems that this code reports an error only on the first call.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]