Skip to content

Commit

Permalink
ARROW-17693: [C++] Remove string_view backport (#14177)
Browse files Browse the repository at this point in the history
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
pitrou committed Sep 21, 2022
1 parent afd3c40 commit 91ee6da
Show file tree
Hide file tree
Showing 218 changed files with 1,077 additions and 2,627 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ jobs:
ARROW_WITH_SNAPPY: ON
ARROW_WITH_ZLIB: ON
ARROW_WITH_ZSTD: ON
# System Abseil installed by Homebrew uses C++ 17
CMAKE_CXX_STANDARD: 17
GTest_SOURCE: BUNDLED
steps:
- name: Checkout Arrow
uses: actions/checkout@v3
Expand Down
28 changes: 0 additions & 28 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -653,34 +653,6 @@ SOFTWARE.

--------------------------------------------------------------------------------

The file cpp/src/arrow/vendored/string_view.hpp has the following license

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

--------------------------------------------------------------------------------

The files in cpp/src/arrow/vendored/xxhash/ have the following license
(BSD 2-Clause License)

Expand Down
2 changes: 1 addition & 1 deletion c_glib/arrow-glib/compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5121,7 +5121,7 @@ GArrowFunctionOptions *
garrow_function_options_new_raw(
const arrow::compute::FunctionOptions *arrow_options)
{
arrow::util::string_view arrow_type_name(arrow_options->type_name());
std::string_view arrow_type_name(arrow_options->type_name());
if (arrow_type_name == "CastOptions") {
auto arrow_cast_options =
static_cast<const arrow::compute::CastOptions *>(arrow_options);
Expand Down
7 changes: 3 additions & 4 deletions c_glib/arrow-glib/input-stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <arrow/io/interfaces.h>
#include <arrow/io/memory.h>
#include <arrow/ipc/reader.h>
#include <arrow/util/string_view.h>

#include <arrow-glib/buffer.hpp>
#include <arrow-glib/codec.hpp>
Expand All @@ -34,6 +33,7 @@
#include <arrow-glib/tensor.hpp>

#include <mutex>
#include <string_view>

G_BEGIN_DECLS

Expand Down Expand Up @@ -855,7 +855,7 @@ namespace garrow {
}
}

arrow::Result<arrow::util::string_view> Peek(int64_t nbytes) override {
arrow::Result<std::string_view> Peek(int64_t nbytes) override {
if (!G_IS_BUFFERED_INPUT_STREAM(input_stream_)) {
std::string message("[gio-input-stream][peek] "
"not peekable input stream: <");
Expand All @@ -882,8 +882,7 @@ namespace garrow {
if (data_size > static_cast<gsize>(nbytes)) {
data_size = nbytes;
}
return arrow::util::string_view(static_cast<const char *>(data),
data_size);
return std::string_view(static_cast<const char *>(data), data_size);
}

arrow::Status Seek(int64_t position) override {
Expand Down
5 changes: 2 additions & 3 deletions c_glib/arrow-glib/scalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,8 @@ garrow_scalar_parse(GArrowDataType *data_type,
GError **error)
{
const auto arrow_data_type = garrow_data_type_get_raw(data_type);
auto arrow_data =
arrow::util::string_view(reinterpret_cast<const char *>(data),
size);
auto arrow_data = std::string_view(reinterpret_cast<const char *>(data),
size);
auto arrow_scalar_result = arrow::Scalar::Parse(arrow_data_type, arrow_data);
if (garrow::check(error, arrow_scalar_result, "[scalar][parse]")) {
auto arrow_scalar = *arrow_scalar_result;
Expand Down
1 change: 1 addition & 0 deletions ci/docker/debian-11-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ ENV absl_SOURCE=BUNDLED \
CC=gcc \
CXX=g++ \
google_cloud_cpp_storage_SOURCE=BUNDLED \
GTest_SOURCE=BUNDLED \
ORC_SOURCE=BUNDLED \
PATH=/usr/lib/ccache/:$PATH \
Protobuf_SOURCE=BUNDLED \
Expand Down
1 change: 1 addition & 0 deletions ci/scripts/java_jni_macos_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ cmake \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=${install_dir} \
-DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD} \
-DGTest_SOURCE=BUNDLED \
-DPARQUET_BUILD_EXAMPLES=OFF \
-DPARQUET_BUILD_EXECUTABLES=OFF \
-DPARQUET_REQUIRE_ENCRYPTION=OFF \
Expand Down
1 change: 1 addition & 0 deletions ci/scripts/java_jni_manylinux_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ cmake \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=${ARROW_HOME} \
-DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD} \
-DGTest_SOURCE=BUNDLED \
-DORC_SOURCE=BUNDLED \
-DORC_PROTOBUF_EXECUTABLE=${VCPKG_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/tools/protobuf/protoc \
-DPARQUET_BUILD_EXAMPLES=OFF \
Expand Down
3 changes: 1 addition & 2 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1974,9 +1974,8 @@ macro(build_gtest)
set(dummy ">")

set(GTEST_CMAKE_ARGS
${EP_COMMON_TOOLCHAIN}
${EP_COMMON_CMAKE_ARGS}
-DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}=${GTEST_CMAKE_CXX_FLAGS}
-DCMAKE_INSTALL_LIBDIR=lib
Expand Down
2 changes: 1 addition & 1 deletion cpp/examples/arrow/join_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ arrow::Result<std::shared_ptr<arrow::dataset::Dataset>> CreateDataSetFromCSVData
std::shared_ptr<arrow::io::InputStream> input;
std::string csv_data = is_left ? kLeftRelationCsvData : kRightRelationCsvData;
std::cout << csv_data << std::endl;
arrow::util::string_view sv = csv_data;
std::string_view sv = csv_data;
input = std::make_shared<arrow::io::BufferReader>(sv);
auto read_options = arrow::csv::ReadOptions::Defaults();
auto parse_options = arrow::csv::ParseOptions::Defaults();
Expand Down
2 changes: 1 addition & 1 deletion cpp/examples/arrow/rapidjson_row_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class RowBatchBuilder {
for (int64_t i = 0; i < array.length(); ++i) {
if (!array.IsNull(i)) {
rapidjson::Value str_key(field_->name(), rows_[i].GetAllocator());
arrow::util::string_view value_view = array.Value(i);
std::string_view value_view = array.Value(i);
rapidjson::Value value;
value.SetString(value_view.data(),
static_cast<rapidjson::SizeType>(value_view.size()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ struct TestData {
if (i % 2 == 0) return {};
return "Str #" + std::to_string(i);
}
static arrow::util::string_view GetStringView(const int i) {
static std::string_view GetStringView(const int i) {
static std::string string;
string = "StringView #" + std::to_string(i);
return arrow::util::string_view(string);
return std::string_view(string);
}
static const char* GetCharPtr(const int i) {
static std::string string;
Expand Down Expand Up @@ -190,7 +190,7 @@ void WriteParquetFile() {
os.SetMaxRowGroupSize(1000);

for (auto i = 0; i < TestData::num_rows; ++i) {
// Output string using 3 different types: std::string, arrow::util::string_view and
// Output string using 3 different types: std::string, std::string_view and
// const char *.
switch (i % 3) {
case 0:
Expand Down
21 changes: 1 addition & 20 deletions cpp/gdb_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def value(self):

class StdString:
"""
A `std::string` (or possibly `string_view`) value.
A `std::string` (or possibly `std::string_view`) value.
"""

def __init__(self, val):
Expand Down Expand Up @@ -2163,23 +2163,6 @@ def to_string(self):
return f"arrow::Result<{data_type}>({inner})"


class StringViewPrinter:
"""
Pretty-printer for arrow::util::string_view.
"""

def __init__(self, name, val):
self.val = val

def to_string(self):
size = int(self.val['size_'])
if size == 0:
return f"arrow::util::string_view of size 0"
else:
data = bytes_literal(self.val['data_'], size)
return f"arrow::util::string_view of size {size}, {data}"


class FieldPrinter:
"""
Pretty-printer for arrow::Field.
Expand Down Expand Up @@ -2397,8 +2380,6 @@ def to_string(self):
"arrow::SimpleTable": TablePrinter,
"arrow::Status": StatusPrinter,
"arrow::Table": TablePrinter,
"arrow::util::string_view": StringViewPrinter,
"nonstd::sv_lite::basic_string_view": StringViewPrinter,
}


Expand Down
10 changes: 5 additions & 5 deletions cpp/src/arrow/adapters/orc/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <cmath>
#include <string>
#include <string_view>
#include <vector>

#include "arrow/array/builder_base.h"
Expand All @@ -30,7 +31,6 @@
#include "arrow/util/checked_cast.h"
#include "arrow/util/decimal.h"
#include "arrow/util/range.h"
#include "arrow/util/string_view.h"
#include "arrow/visit_data_inline.h"

#include "orc/Exceptions.hh"
Expand Down Expand Up @@ -462,7 +462,7 @@ struct Appender<DataType, liborc::StringVectorBatch> {
running_arrow_offset++;
return Status::OK();
}
Status VisitValue(util::string_view v) {
Status VisitValue(std::string_view v) {
batch->notNull[running_orc_offset] = true;
COffsetType data_length = 0;
batch->data[running_orc_offset] = reinterpret_cast<char*>(
Expand All @@ -486,7 +486,7 @@ struct Appender<Decimal128Type, liborc::Decimal64VectorBatch> {
running_arrow_offset++;
return Status::OK();
}
Status VisitValue(util::string_view v) {
Status VisitValue(std::string_view v) {
batch->notNull[running_orc_offset] = true;
const Decimal128 dec_value(array.GetValue(running_arrow_offset));
batch->values[running_orc_offset] = static_cast<int64_t>(dec_value.low_bits());
Expand All @@ -507,7 +507,7 @@ struct Appender<Decimal128Type, liborc::Decimal128VectorBatch> {
running_arrow_offset++;
return Status::OK();
}
Status VisitValue(util::string_view v) {
Status VisitValue(std::string_view v) {
batch->notNull[running_orc_offset] = true;
const Decimal128 dec_value(array.GetValue(running_arrow_offset));
batch->values[running_orc_offset] =
Expand Down Expand Up @@ -557,7 +557,7 @@ struct FixedSizeBinaryAppender {
running_arrow_offset++;
return Status::OK();
}
Status VisitValue(util::string_view v) {
Status VisitValue(std::string_view v) {
batch->notNull[running_orc_offset] = true;
batch->data[running_orc_offset] = reinterpret_cast<char*>(
const_cast<uint8_t*>(array.GetValue(running_arrow_offset)));
Expand Down
18 changes: 9 additions & 9 deletions cpp/src/arrow/array/array_binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <cstdint>
#include <memory>
#include <string>
#include <string_view>
#include <vector>

#include "arrow/array/array_base.h"
Expand All @@ -32,7 +33,6 @@
#include "arrow/type.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/macros.h"
#include "arrow/util/string_view.h" // IWYU pragma: export
#include "arrow/util/visibility.h"

namespace arrow {
Expand Down Expand Up @@ -67,15 +67,15 @@ class BaseBinaryArray : public FlatArray {
///
/// \param i the value index
/// \return the view over the selected value
util::string_view GetView(int64_t i) const {
std::string_view GetView(int64_t i) const {
// Account for base offset
i += data_->offset;
const offset_type pos = raw_value_offsets_[i];
return util::string_view(reinterpret_cast<const char*>(raw_data_ + pos),
raw_value_offsets_[i + 1] - pos);
return std::string_view(reinterpret_cast<const char*>(raw_data_ + pos),
raw_value_offsets_[i + 1] - pos);
}

std::optional<util::string_view> operator[](int64_t i) const {
std::optional<std::string_view> operator[](int64_t i) const {
return *IteratorType(*this, i);
}

Expand All @@ -84,7 +84,7 @@ class BaseBinaryArray : public FlatArray {
///
/// \param i the value index
/// \return the view over the selected value
util::string_view Value(int64_t i) const { return GetView(i); }
std::string_view Value(int64_t i) const { return GetView(i); }

/// \brief Get binary value as a std::string
///
Expand Down Expand Up @@ -236,11 +236,11 @@ class ARROW_EXPORT FixedSizeBinaryArray : public PrimitiveArray {
const uint8_t* GetValue(int64_t i) const;
const uint8_t* Value(int64_t i) const { return GetValue(i); }

util::string_view GetView(int64_t i) const {
return util::string_view(reinterpret_cast<const char*>(GetValue(i)), byte_width());
std::string_view GetView(int64_t i) const {
return std::string_view(reinterpret_cast<const char*>(GetValue(i)), byte_width());
}

std::optional<util::string_view> operator[](int64_t i) const {
std::optional<std::string_view> operator[](int64_t i) const {
return *IteratorType(*this, i);
}

Expand Down
12 changes: 6 additions & 6 deletions cpp/src/arrow/array/array_binary_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <cstring>
#include <memory>
#include <string>
#include <string_view>
#include <vector>

#include <gmock/gmock-matchers.h>
Expand All @@ -37,7 +38,6 @@
#include "arrow/util/bit_util.h"
#include "arrow/util/bitmap_builders.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/string_view.h"
#include "arrow/visit_data_inline.h"

namespace arrow {
Expand All @@ -63,7 +63,7 @@ void CheckStringArray(const ArrayType& array, const std::vector<std::string>& st
auto view = array.GetView(i);
ASSERT_EQ(value_pos, array.value_offset(i));
ASSERT_EQ(strings[j].size(), view.size());
ASSERT_EQ(util::string_view(strings[j]), view);
ASSERT_EQ(std::string_view(strings[j]), view);
value_pos += static_cast<int32_t>(view.size());
} else {
ASSERT_TRUE(array.IsNull(i));
Expand Down Expand Up @@ -256,7 +256,7 @@ class TestStringArray : public ::testing::Test {
}

Status ValidateFull(int64_t length, std::vector<offset_type> offsets,
util::string_view data, int64_t offset = 0) {
std::string_view data, int64_t offset = 0) {
ArrayType arr(length, Buffer::Wrap(offsets), std::make_shared<Buffer>(data),
/*null_bitmap=*/nullptr, /*null_count=*/0, offset);
return arr.ValidateFull();
Expand Down Expand Up @@ -373,7 +373,7 @@ class TestUTF8Array : public ::testing::Test {
using ArrayType = typename TypeTraits<TypeClass>::ArrayType;

Status ValidateUTF8(int64_t length, std::vector<offset_type> offsets,
util::string_view data, int64_t offset = 0) {
std::string_view data, int64_t offset = 0) {
ArrayType arr(length, Buffer::Wrap(offsets), std::make_shared<Buffer>(data),
/*null_bitmap=*/nullptr, /*null_count=*/0, offset);
return arr.ValidateUTF8();
Expand Down Expand Up @@ -867,12 +867,12 @@ struct BinaryAppender {
return Status::OK();
}

Status VisitValue(util::string_view v) {
Status VisitValue(std::string_view v) {
data.push_back(v);
return Status::OK();
}

std::vector<util::string_view> data;
std::vector<std::string_view> data;
};

template <typename T>
Expand Down
Loading

0 comments on commit 91ee6da

Please sign in to comment.