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

Class FindSubstringRegex

cpp/src/arrow/compute/kernels/scalar_string_ascii.cc:1712–1741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1710
1711#ifdef ARROW_WITH_RE2
1712struct FindSubstringRegex {
1713 std::unique_ptr<RE2> regex_match_;
1714
1715 static Result<FindSubstringRegex> Make(const MatchSubstringOptions& options,
1716 bool is_utf8 = true, bool literal = false) {
1717 auto matcher = FindSubstringRegex(options, is_utf8, literal);
1718 RETURN_NOT_OK(RegexStatus(*matcher.regex_match_));
1719 return matcher;
1720 }
1721
1722 explicit FindSubstringRegex(const MatchSubstringOptions& options, bool is_utf8 = true,
1723 bool literal = false) {
1724 std::string regex = "(";
1725 regex.reserve(options.pattern.length() + 2);
1726 regex += literal ? RE2::QuoteMeta(options.pattern) : options.pattern;
1727 regex += ")";
1728 regex_match_ = std::make_unique<RE2>(
1729 regex, MakeRE2Options(is_utf8, options.ignore_case, /*literal=*/false));
1730 }
1731
1732 template <typename OutValue, typename... Ignored>
1733 OutValue Call(KernelContext*, std::string_view val, Status*) const {
1734 re2::StringPiece piece(val.data(), val.length());
1735 re2::StringPiece match;
1736 if (RE2::PartialMatch(piece, *regex_match_, &match)) {
1737 return static_cast<OutValue>(match.data() - piece.data());
1738 }
1739 return -1;
1740 }
1741};
1742#endif
1743
1744template <typename InputPhysicalType>

Callers 1

MakeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected