This is an automated email from the ASF dual-hosted git repository.

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 6b118bbcca GH-38282 [C++]: Implement ReplaceString with the right type 
signature (#38283)
6b118bbcca is described below

commit 6b118bbcca2139c479814854c8b246552f1ac9a0
Author: Felipe Oliveira Carvalho <[email protected]>
AuthorDate: Mon Oct 16 14:02:18 2023 -0300

    GH-38282 [C++]: Implement ReplaceString with the right type signature 
(#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: #38282
    
    Authored-by: Felipe Oliveira Carvalho <[email protected]>
    Signed-off-by: Raúl Cumplido <[email protected]>
---
 cpp/src/arrow/compute/kernels/scalar_string_ascii.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc 
b/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc
index 90f5d40b98..6764845dfc 100644
--- a/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc
@@ -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

Reply via email to