Skip to content

Commit ce3a066

Browse files
committed
refactor: replace arrow::util::span with std::span
1 parent 01ec550 commit ce3a066

31 files changed

+107
-147
lines changed

cpp/src/arrow/array/concatenate.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ class ConcatenateImpl {
424424
out_->buffers.resize(2);
425425

426426
for (const auto& in_data : in_) {
427-
for (const auto& buf : util::span(in_data->buffers).subspan(2)) {
427+
for (const auto& buf : std::span(in_data->buffers).subspan(2)) {
428428
out_->buffers.push_back(buf);
429429
}
430430
}

cpp/src/arrow/array/data.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool DictionaryMayHaveLogicalNulls(const ArrayData& data) {
102102

103103
namespace {
104104

105-
BufferSpan PackVariadicBuffers(util::span<const std::shared_ptr<Buffer>> buffers) {
105+
BufferSpan PackVariadicBuffers(std::span<const std::shared_ptr<Buffer>> buffers) {
106106
return {const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(buffers.data())),
107107
static_cast<int64_t>(buffers.size() * sizeof(std::shared_ptr<Buffer>))};
108108
}
@@ -322,7 +322,7 @@ void ArraySpan::SetMembers(const ArrayData& data) {
322322

323323
if (type_id == Type::STRING_VIEW || type_id == Type::BINARY_VIEW) {
324324
// store the span of data buffers in the third buffer
325-
this->buffers[2] = internal::PackVariadicBuffers(util::span(data.buffers).subspan(2));
325+
this->buffers[2] = internal::PackVariadicBuffers(std::span(data.buffers).subspan(2));
326326
}
327327

328328
if (type_id == Type::DICTIONARY) {
@@ -679,7 +679,7 @@ std::shared_ptr<ArrayData> ArraySpan::ToArrayData() const {
679679
return result;
680680
}
681681

682-
util::span<const std::shared_ptr<Buffer>> ArraySpan::GetVariadicBuffers() const {
682+
std::span<const std::shared_ptr<Buffer>> ArraySpan::GetVariadicBuffers() const {
683683
DCHECK(HasVariadicBuffers());
684684
return {buffers[2].data_as<std::shared_ptr<Buffer>>(),
685685
static_cast<size_t>(buffers[2].size) / sizeof(std::shared_ptr<Buffer>)};

cpp/src/arrow/array/data.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <cassert>
2222
#include <cstdint>
2323
#include <memory>
24+
#include <span>
2425
#include <utility>
2526
#include <vector>
2627

@@ -31,9 +32,7 @@
3132
#include "arrow/type_fwd.h"
3233
#include "arrow/util/bit_util.h"
3334
#include "arrow/util/macros.h"
34-
#include <span>
3535
#include "arrow/util/visibility.h"
36-
3736
namespace arrow {
3837

3938
namespace internal {
@@ -577,11 +576,11 @@ struct ARROW_EXPORT ArraySpan {
577576
/// this array type
578577
/// \return A span<const T> of the requested length
579578
template <typename T>
580-
util::span<const T> GetSpan(int i, int64_t length) const {
579+
std::span<const T> GetSpan(int i, int64_t length) const {
581580
const int64_t buffer_length = buffers[i].size / static_cast<int64_t>(sizeof(T));
582581
assert(i > 0 && length + offset <= buffer_length);
583582
ARROW_UNUSED(buffer_length);
584-
return util::span<const T>(buffers[i].data_as<T>() + this->offset, length);
583+
return std::span<const T>(buffers[i].data_as<T>() + this->offset, length);
585584
}
586585

587586
/// \brief Access a buffer's data as a span
@@ -593,11 +592,11 @@ struct ARROW_EXPORT ArraySpan {
593592
/// this array type
594593
/// \return A span<T> of the requested length
595594
template <typename T>
596-
util::span<T> GetSpan(int i, int64_t length) {
595+
std::span<T> GetSpan(int i, int64_t length) {
597596
const int64_t buffer_length = buffers[i].size / static_cast<int64_t>(sizeof(T));
598597
assert(i > 0 && length + offset <= buffer_length);
599598
ARROW_UNUSED(buffer_length);
600-
return util::span<T>(buffers[i].mutable_data_as<T>() + this->offset, length);
599+
return std::span<T>(buffers[i].mutable_data_as<T>() + this->offset, length);
601600
}
602601

603602
inline bool IsNull(int64_t i) const { return !IsValid(i); }
@@ -709,7 +708,7 @@ struct ARROW_EXPORT ArraySpan {
709708
/// sizeof(shared_ptr<Buffer>).
710709
///
711710
/// \see HasVariadicBuffers
712-
util::span<const std::shared_ptr<Buffer>> GetVariadicBuffers() const;
711+
std::span<const std::shared_ptr<Buffer>> GetVariadicBuffers() const;
713712
bool HasVariadicBuffers() const;
714713

715714
private:

cpp/src/arrow/array/util.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
#include "arrow/array/util.h"
19-
2018
#include <algorithm>
2119
#include <array>
2220
#include <cstdint>
2321
#include <cstring>
2422
#include <limits>
2523
#include <memory>
24+
#include <span>
2625
#include <type_traits>
2726
#include <utility>
2827
#include <vector>
2928

29+
#include "arrow/array/util.h"
3030
#include "arrow/array.h"
3131
#include "arrow/array/builder_base.h"
3232
#include "arrow/array/concatenate.h"
@@ -44,10 +44,8 @@
4444
#include "arrow/util/endian.h"
4545
#include "arrow/util/logging_internal.h"
4646
#include "arrow/util/sort_internal.h"
47-
#include <span>
4847
#include "arrow/visit_data_inline.h"
4948
#include "arrow/visit_type_inline.h"
50-
5149
namespace arrow {
5250

5351
using internal::checked_cast;

cpp/src/arrow/array/validate.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,9 @@ struct ValidateArrayImpl {
650650
HexEncode(data, BinaryViewType::kPrefixSize));
651651
};
652652

653-
util::span views(data.GetValues<BinaryViewType::c_type>(1),
653+
std::span views(data.GetValues<BinaryViewType::c_type>(1),
654654
static_cast<size_t>(data.length));
655-
util::span data_buffers(data.buffers.data() + 2, data.buffers.size() - 2);
655+
std::span data_buffers(data.buffers.data() + 2, data.buffers.size() - 2);
656656

657657
for (size_t i = 0; i < static_cast<size_t>(data.length); ++i) {
658658
if (data.IsNull(i)) continue;
@@ -663,7 +663,7 @@ struct ValidateArrayImpl {
663663
}
664664

665665
if (views[i].is_inline()) {
666-
auto padding_bytes = util::span(views[i].inlined.data).subspan(views[i].size());
666+
auto padding_bytes = std::span(views[i].inlined.data).subspan(views[i].size());
667667
for (auto padding_byte : padding_bytes) {
668668
if (padding_byte != 0) {
669669
return Status::Invalid("View at slot ", i, " was inline with size ",

cpp/src/arrow/buffer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <cstring>
2222
#include <memory>
2323
#include <optional>
24+
#include <span>
2425
#include <string>
2526
#include <string_view>
2627
#include <utility>
@@ -30,7 +31,6 @@
3031
#include "arrow/status.h"
3132
#include "arrow/type_fwd.h"
3233
#include "arrow/util/macros.h"
33-
#include <span>
3434
#include "arrow/util/visibility.h"
3535

3636
namespace arrow {
@@ -236,8 +236,8 @@ class ARROW_EXPORT Buffer {
236236

237237
/// \brief Return the buffer's data as a span
238238
template <typename T>
239-
util::span<const T> span_as() const {
240-
return util::span(data_as<T>(), static_cast<size_t>(size() / sizeof(T)));
239+
std::span<const T> span_as() const {
240+
return std::span(data_as<T>(), static_cast<size_t>(size() / sizeof(T)));
241241
}
242242

243243
/// \brief Return a writable pointer to the buffer's data
@@ -269,8 +269,8 @@ class ARROW_EXPORT Buffer {
269269

270270
/// \brief Return the buffer's mutable data as a span
271271
template <typename T>
272-
util::span<T> mutable_span_as() {
273-
return util::span(mutable_data_as<T>(), static_cast<size_t>(size() / sizeof(T)));
272+
std::span<T> mutable_span_as() {
273+
return std::span(mutable_data_as<T>(), static_cast<size_t>(size() / sizeof(T)));
274274
}
275275

276276
/// \brief Return the device address of the buffer's data

cpp/src/arrow/c/bridge.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ struct ArrayExporter {
603603
});
604604

605605
if (need_variadic_buffer_sizes) {
606-
auto variadic_buffers = util::span(data->buffers).subspan(2);
606+
auto variadic_buffers = std::span(data->buffers).subspan(2);
607607
export_.variadic_buffer_sizes_.resize(variadic_buffers.size());
608608
size_t i = 0;
609609
for (const auto& buf : variadic_buffers) {

cpp/src/arrow/c/bridge_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,8 @@ struct ArrayExportChecker {
592592
ASSERT_EQ(c_export->buffers[i], expected_ptr);
593593
}
594594
if (has_variadic_buffer_sizes) {
595-
auto variadic_buffers = util::span(expected_data.buffers).subspan(2);
596-
auto variadic_buffer_sizes = util::span(
595+
auto variadic_buffers = std::span(expected_data.buffers).subspan(2);
596+
auto variadic_buffer_sizes = std::span(
597597
static_cast<const int64_t*>(c_export->buffers[c_export->n_buffers - 1]),
598598
variadic_buffers.size());
599599
for (auto [buf, size] : Zip(variadic_buffers, variadic_buffer_sizes)) {

cpp/src/arrow/chunk_resolver.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
namespace arrow {
3030

31-
using util::span;
31+
using std::span;
3232

3333
namespace {
3434
template <typename T>

cpp/src/arrow/chunk_resolver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
#include <cassert>
2222
#include <cstdint>
2323
#include <limits>
24+
#include <span>
2425
#include <type_traits>
2526
#include <vector>
2627

2728
#include "arrow/type_fwd.h"
2829
#include "arrow/util/macros.h"
29-
#include <span>
3030

3131
namespace arrow {
3232

@@ -77,7 +77,7 @@ class ARROW_EXPORT ChunkResolver {
7777

7878
public:
7979
explicit ChunkResolver(const ArrayVector& chunks) noexcept;
80-
explicit ChunkResolver(util::span<const Array* const> chunks) noexcept;
80+
explicit ChunkResolver(std::span<const Array* const> chunks) noexcept;
8181
explicit ChunkResolver(const RecordBatchVector& batches) noexcept;
8282

8383
/// \brief Construct a ChunkResolver from a vector of chunks.size() + 1 offsets.

0 commit comments

Comments
 (0)