Skip to content

Commit

Permalink
apacheGH-38282 [C++]: Implement ReplaceString with the right type sig…
Browse files Browse the repository at this point in the history
…nature (apache#38283)

### Rationale for this change

The type signature of `ReplaceString` should be identical when arrow is compiled with or without `ARROW_WITH_RE2`.

### What changes are included in this PR?

The right signature + delegating to the implementation that takes `re2::StringPiece`. The conversion should be a no-op when compiled and optimized.

### Are these changes tested?

By existing tests and CI checks.

* Closes: apache#38282

Authored-by: Felipe Oliveira Carvalho <[email protected]>
Signed-off-by: Raúl Cumplido <[email protected]>
  • Loading branch information
felipecrv authored and loicalleyne committed Nov 13, 2023
1 parent c881049 commit df36e43
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cpp/src/arrow/compute/kernels/scalar_string_ascii.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2063,7 +2063,13 @@ struct RegexSubstringReplacer {
regex_find_("(" + options_.pattern + ")", MakeRE2Options<Type>()),
regex_replacement_(options_.pattern, MakeRE2Options<Type>()) {}

Status ReplaceString(re2::StringPiece s, TypedBufferBuilder<uint8_t>* builder) const {
Status ReplaceString(std::string_view s, TypedBufferBuilder<uint8_t>* builder) const {
re2::StringPiece piece(s.data(), s.length());
return ReplaceStringImpl(piece, builder);
}

Status ReplaceStringImpl(re2::StringPiece s,
TypedBufferBuilder<uint8_t>* builder) const {
re2::StringPiece replacement(options_.replacement);

// If s is empty, then it's essentially global
Expand Down

0 comments on commit df36e43

Please sign in to comment.