Skip to content

Commit 37c40fb

Browse files
authored
GH-48093: [C++][FlightRPC] Replace boost::algorithm with alternatives (#48688)
### Rationale for this change Replaces `boost::algorithm::join` with Arrow's internal `arrow::internal::JoinStrings` to remove the boost dependency. Both functions have equivalent behavior: they join a vector of strings with a delimiter. ### What changes are included in this PR? Replaced `boost::algorithm::join(*create_params, ",")` with `arrow::internal::JoinStrings(*create_params, ",")` (line 112) at `cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_statement_get_type_info.cc`. From `boost/algorithm/string/join.hpp`: ```cpp template< typename SequenceSequenceT, typename Range1T> inline typename range_value<SequenceSequenceT>::type join(const SequenceSequenceT& Input, const Range1T& Separator) { // Define working types typedef typename range_value<SequenceSequenceT>::type ResultT; typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT; // Parse input InputIteratorT itBegin=::boost::begin(Input); InputIteratorT itEnd=::boost::end(Input); // Construct container to hold the result ResultT Result; // Append first element if(itBegin!=itEnd) { detail::insert(Result, ::boost::end(Result), *itBegin); ++itBegin; } for(;itBegin!=itEnd; ++itBegin) { // Add separator detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); // Add element detail::insert(Result, ::boost::end(Result), *itBegin); } return Result; } ``` From `cpp/src/arrow/util/string.cc:126-148`: ```cpp template <typename StringLike> static std::string JoinStringLikes(const std::vector<StringLike>& strings, std::string_view delimiter) { if (strings.size() == 0) { return ""; } std::string out = std::string(strings.front()); for (size_t i = 1; i < strings.size(); ++i) { out.append(delimiter.begin(), delimiter.end()); out.append(strings[i].begin(), strings[i].end()); } return out; } std::string JoinStrings(const std::vector<std::string>& strings, std::string_view delimiter) { return JoinStringLikes(strings, delimiter); } ``` ### Are these changes tested? Yes. Existing test cases should verify the change. ### Are there any user-facing changes? No. * GitHub Issue: #48093 Authored-by: Hyukjin Kwon <[email protected]> Signed-off-by: David Li <[email protected]>
1 parent 1b0a220 commit 37c40fb

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_statement_get_type_info.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
#include "arrow/flight/sql/odbc/odbc_impl/flight_sql_statement_get_type_info.h"
1919

20-
#include <boost/algorithm/string/join.hpp>
2120
#include "arrow/flight/sql/odbc/odbc_impl/flight_sql_connection.h"
2221
#include "arrow/flight/sql/odbc/odbc_impl/flight_sql_get_type_info_reader.h"
2322
#include "arrow/flight/sql/odbc/odbc_impl/platform.h"
2423
#include "arrow/flight/sql/odbc/odbc_impl/util.h"
24+
#include "arrow/util/string.h"
2525

2626
namespace arrow::flight::sql::odbc {
2727

@@ -109,8 +109,7 @@ Result<std::shared_ptr<RecordBatch>> TransformInner(
109109

110110
const auto& create_params = reader.GetCreateParams();
111111
if (create_params && !create_params->empty()) {
112-
// GH-48093 TODO: replace boost-algorithm with alternatives
113-
data.create_params = boost::algorithm::join(*create_params, ",");
112+
data.create_params = arrow::internal::JoinStrings(*create_params, ",");
114113
} else {
115114
data.create_params = nullopt;
116115
}

0 commit comments

Comments
 (0)