diff --git a/cpp/src/arrow/array/concatenate.cc b/cpp/src/arrow/array/concatenate.cc index 2b832b977f2..90ae952a2e8 100644 --- a/cpp/src/arrow/array/concatenate.cc +++ b/cpp/src/arrow/array/concatenate.cc @@ -424,7 +424,7 @@ class ConcatenateImpl { out_->buffers.resize(2); for (const auto& in_data : in_) { - for (const auto& buf : util::span(in_data->buffers).subspan(2)) { + for (const auto& buf : std::span(in_data->buffers).subspan(2)) { out_->buffers.push_back(buf); } } diff --git a/cpp/src/arrow/array/data.cc b/cpp/src/arrow/array/data.cc index 1c56a485062..51ba77863b1 100644 --- a/cpp/src/arrow/array/data.cc +++ b/cpp/src/arrow/array/data.cc @@ -102,7 +102,7 @@ bool DictionaryMayHaveLogicalNulls(const ArrayData& data) { namespace { -BufferSpan PackVariadicBuffers(util::span> buffers) { +BufferSpan PackVariadicBuffers(std::span> buffers) { return {const_cast(reinterpret_cast(buffers.data())), static_cast(buffers.size() * sizeof(std::shared_ptr))}; } @@ -322,7 +322,7 @@ void ArraySpan::SetMembers(const ArrayData& data) { if (type_id == Type::STRING_VIEW || type_id == Type::BINARY_VIEW) { // store the span of data buffers in the third buffer - this->buffers[2] = internal::PackVariadicBuffers(util::span(data.buffers).subspan(2)); + this->buffers[2] = internal::PackVariadicBuffers(std::span(data.buffers).subspan(2)); } if (type_id == Type::DICTIONARY) { @@ -679,7 +679,7 @@ std::shared_ptr ArraySpan::ToArrayData() const { return result; } -util::span> ArraySpan::GetVariadicBuffers() const { +std::span> ArraySpan::GetVariadicBuffers() const { DCHECK(HasVariadicBuffers()); return {buffers[2].data_as>(), static_cast(buffers[2].size) / sizeof(std::shared_ptr)}; diff --git a/cpp/src/arrow/array/data.h b/cpp/src/arrow/array/data.h index c6636df9bb3..200d92a54c6 100644 --- a/cpp/src/arrow/array/data.h +++ b/cpp/src/arrow/array/data.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -31,9 +32,7 @@ #include "arrow/type_fwd.h" #include "arrow/util/bit_util.h" #include "arrow/util/macros.h" -#include "arrow/util/span.h" #include "arrow/util/visibility.h" - namespace arrow { namespace internal { @@ -577,11 +576,11 @@ struct ARROW_EXPORT ArraySpan { /// this array type /// \return A span of the requested length template - util::span GetSpan(int i, int64_t length) const { + std::span GetSpan(int i, int64_t length) const { const int64_t buffer_length = buffers[i].size / static_cast(sizeof(T)); assert(i > 0 && length + offset <= buffer_length); ARROW_UNUSED(buffer_length); - return util::span(buffers[i].data_as() + this->offset, length); + return std::span(buffers[i].data_as() + this->offset, length); } /// \brief Access a buffer's data as a span @@ -593,11 +592,11 @@ struct ARROW_EXPORT ArraySpan { /// this array type /// \return A span of the requested length template - util::span GetSpan(int i, int64_t length) { + std::span GetSpan(int i, int64_t length) { const int64_t buffer_length = buffers[i].size / static_cast(sizeof(T)); assert(i > 0 && length + offset <= buffer_length); ARROW_UNUSED(buffer_length); - return util::span(buffers[i].mutable_data_as() + this->offset, length); + return std::span(buffers[i].mutable_data_as() + this->offset, length); } inline bool IsNull(int64_t i) const { return !IsValid(i); } @@ -709,7 +708,7 @@ struct ARROW_EXPORT ArraySpan { /// sizeof(shared_ptr). /// /// \see HasVariadicBuffers - util::span> GetVariadicBuffers() const; + std::span> GetVariadicBuffers() const; bool HasVariadicBuffers() const; private: diff --git a/cpp/src/arrow/array/util.cc b/cpp/src/arrow/array/util.cc index 03d8c32c4e3..5b8b5ed3c86 100644 --- a/cpp/src/arrow/array/util.cc +++ b/cpp/src/arrow/array/util.cc @@ -44,10 +44,8 @@ #include "arrow/util/endian.h" #include "arrow/util/logging_internal.h" #include "arrow/util/sort_internal.h" -#include "arrow/util/span.h" #include "arrow/visit_data_inline.h" #include "arrow/visit_type_inline.h" - namespace arrow { using internal::checked_cast; diff --git a/cpp/src/arrow/array/validate.cc b/cpp/src/arrow/array/validate.cc index bd0d00126d5..fe203539548 100644 --- a/cpp/src/arrow/array/validate.cc +++ b/cpp/src/arrow/array/validate.cc @@ -650,9 +650,9 @@ struct ValidateArrayImpl { HexEncode(data, BinaryViewType::kPrefixSize)); }; - util::span views(data.GetValues(1), + std::span views(data.GetValues(1), static_cast(data.length)); - util::span data_buffers(data.buffers.data() + 2, data.buffers.size() - 2); + std::span data_buffers(data.buffers.data() + 2, data.buffers.size() - 2); for (size_t i = 0; i < static_cast(data.length); ++i) { if (data.IsNull(i)) continue; @@ -663,7 +663,7 @@ struct ValidateArrayImpl { } if (views[i].is_inline()) { - auto padding_bytes = util::span(views[i].inlined.data).subspan(views[i].size()); + auto padding_bytes = std::span(views[i].inlined.data).subspan(views[i].size()); for (auto padding_byte : padding_bytes) { if (padding_byte != 0) { return Status::Invalid("View at slot ", i, " was inline with size ", diff --git a/cpp/src/arrow/buffer.h b/cpp/src/arrow/buffer.h index ce909a3ea18..a2c84120827 100644 --- a/cpp/src/arrow/buffer.h +++ b/cpp/src/arrow/buffer.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -30,7 +31,6 @@ #include "arrow/status.h" #include "arrow/type_fwd.h" #include "arrow/util/macros.h" -#include "arrow/util/span.h" #include "arrow/util/visibility.h" namespace arrow { @@ -236,8 +236,8 @@ class ARROW_EXPORT Buffer { /// \brief Return the buffer's data as a span template - util::span span_as() const { - return util::span(data_as(), static_cast(size() / sizeof(T))); + std::span span_as() const { + return std::span(data_as(), static_cast(size() / sizeof(T))); } /// \brief Return a writable pointer to the buffer's data @@ -269,8 +269,8 @@ class ARROW_EXPORT Buffer { /// \brief Return the buffer's mutable data as a span template - util::span mutable_span_as() { - return util::span(mutable_data_as(), static_cast(size() / sizeof(T))); + std::span mutable_span_as() { + return std::span(mutable_data_as(), static_cast(size() / sizeof(T))); } /// \brief Return the device address of the buffer's data diff --git a/cpp/src/arrow/c/bridge.cc b/cpp/src/arrow/c/bridge.cc index dd25ed299dd..eef4ce0862e 100644 --- a/cpp/src/arrow/c/bridge.cc +++ b/cpp/src/arrow/c/bridge.cc @@ -603,7 +603,7 @@ struct ArrayExporter { }); if (need_variadic_buffer_sizes) { - auto variadic_buffers = util::span(data->buffers).subspan(2); + auto variadic_buffers = std::span(data->buffers).subspan(2); export_.variadic_buffer_sizes_.resize(variadic_buffers.size()); size_t i = 0; for (const auto& buf : variadic_buffers) { diff --git a/cpp/src/arrow/c/bridge_test.cc b/cpp/src/arrow/c/bridge_test.cc index c6a5e01e038..d56f1555d5d 100644 --- a/cpp/src/arrow/c/bridge_test.cc +++ b/cpp/src/arrow/c/bridge_test.cc @@ -592,8 +592,8 @@ struct ArrayExportChecker { ASSERT_EQ(c_export->buffers[i], expected_ptr); } if (has_variadic_buffer_sizes) { - auto variadic_buffers = util::span(expected_data.buffers).subspan(2); - auto variadic_buffer_sizes = util::span( + auto variadic_buffers = std::span(expected_data.buffers).subspan(2); + auto variadic_buffer_sizes = std::span( static_cast(c_export->buffers[c_export->n_buffers - 1]), variadic_buffers.size()); for (auto [buf, size] : Zip(variadic_buffers, variadic_buffer_sizes)) { diff --git a/cpp/src/arrow/chunk_resolver.cc b/cpp/src/arrow/chunk_resolver.cc index 7fc259f38c2..a78548757ed 100644 --- a/cpp/src/arrow/chunk_resolver.cc +++ b/cpp/src/arrow/chunk_resolver.cc @@ -28,8 +28,6 @@ namespace arrow { -using util::span; - namespace { template int64_t GetLength(const T& array) { @@ -44,7 +42,7 @@ int64_t GetLength>( } template -inline std::vector MakeChunksOffsets(span chunks) { +inline std::vector MakeChunksOffsets(std::span chunks) { std::vector offsets(chunks.size() + 1); int64_t offset = 0; std::transform(chunks.begin(), chunks.end(), offsets.begin(), @@ -114,13 +112,13 @@ void ResolveManyInline(uint32_t num_offsets, const int64_t* signed_offsets, } // namespace ChunkResolver::ChunkResolver(const ArrayVector& chunks) noexcept - : offsets_(MakeChunksOffsets(span(chunks))), cached_chunk_(0) {} + : offsets_(MakeChunksOffsets(std::span(chunks))), cached_chunk_(0) {} -ChunkResolver::ChunkResolver(span chunks) noexcept +ChunkResolver::ChunkResolver(std::span chunks) noexcept : offsets_(MakeChunksOffsets(chunks)), cached_chunk_(0) {} ChunkResolver::ChunkResolver(const RecordBatchVector& batches) noexcept - : offsets_(MakeChunksOffsets(span(batches))), cached_chunk_(0) {} + : offsets_(MakeChunksOffsets(std::span(batches))), cached_chunk_(0) {} ChunkResolver::ChunkResolver(ChunkResolver&& other) noexcept : offsets_(std::move(other.offsets_)), diff --git a/cpp/src/arrow/chunk_resolver.h b/cpp/src/arrow/chunk_resolver.h index 3d6458167fa..fbf84876e3d 100644 --- a/cpp/src/arrow/chunk_resolver.h +++ b/cpp/src/arrow/chunk_resolver.h @@ -21,12 +21,12 @@ #include #include #include +#include #include #include #include "arrow/type_fwd.h" #include "arrow/util/macros.h" -#include "arrow/util/span.h" namespace arrow { @@ -77,7 +77,7 @@ class ARROW_EXPORT ChunkResolver { public: explicit ChunkResolver(const ArrayVector& chunks) noexcept; - explicit ChunkResolver(util::span chunks) noexcept; + explicit ChunkResolver(std::span chunks) noexcept; explicit ChunkResolver(const RecordBatchVector& batches) noexcept; /// \brief Construct a ChunkResolver from a vector of chunks.size() + 1 offsets. diff --git a/cpp/src/arrow/compute/kernels/aggregate_pivot.cc b/cpp/src/arrow/compute/kernels/aggregate_pivot.cc index 504c7cdd26d..8b73ecfe554 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_pivot.cc +++ b/cpp/src/arrow/compute/kernels/aggregate_pivot.cc @@ -29,8 +29,6 @@ namespace arrow::compute::internal { namespace { using arrow::internal::VisitSetBitRunsVoid; -using arrow::util::span; - struct PivotImpl : public ScalarAggregator { Status Init(const PivotWiderOptions& options, const std::vector& in_types, ExecContext* ctx) { diff --git a/cpp/src/arrow/compute/kernels/chunked_internal.cc b/cpp/src/arrow/compute/kernels/chunked_internal.cc index bf574fcafd0..b62dc1436c2 100644 --- a/cpp/src/arrow/compute/kernels/chunked_internal.cc +++ b/cpp/src/arrow/compute/kernels/chunked_internal.cc @@ -32,7 +32,7 @@ std::vector GetArrayPointers(const ArrayVector& arrays) { } std::vector ChunkedIndexMapper::GetChunkLengths( - util::span chunks) { + std::span chunks) { std::vector chunk_lengths(chunks.size()); for (int64_t i = 0; i < static_cast(chunks.size()); ++i) { chunk_lengths[i] = chunks[i]->length(); diff --git a/cpp/src/arrow/compute/kernels/chunked_internal.h b/cpp/src/arrow/compute/kernels/chunked_internal.h index 330bd185f25..1c3105f6915 100644 --- a/cpp/src/arrow/compute/kernels/chunked_internal.h +++ b/cpp/src/arrow/compute/kernels/chunked_internal.h @@ -20,15 +20,14 @@ #include #include #include +#include #include #include #include "arrow/array.h" #include "arrow/chunk_resolver.h" #include "arrow/compute/kernels/codegen_internal.h" -#include "arrow/util/span.h" #include "arrow/util/visibility.h" - namespace arrow::compute::internal { // The target chunk in a chunked array. @@ -92,13 +91,13 @@ static_assert(sizeof(uint64_t) == sizeof(CompressedChunkLocation)); class ChunkedArrayResolver { private: ChunkResolver resolver_; - util::span chunks_; + std::span chunks_; std::vector owned_chunks_; public: explicit ChunkedArrayResolver(std::vector&& chunks) : resolver_(chunks), chunks_(chunks), owned_chunks_(std::move(chunks)) {} - explicit ChunkedArrayResolver(util::span chunks) + explicit ChunkedArrayResolver(std::span chunks) : resolver_(chunks), chunks_(chunks) {} ARROW_DEFAULT_MOVE_AND_ASSIGN(ChunkedArrayResolver); @@ -129,8 +128,8 @@ class ARROW_EXPORT ChunkedIndexMapper { public: ChunkedIndexMapper(const std::vector& chunks, uint64_t* indices_begin, uint64_t* indices_end) - : ChunkedIndexMapper(util::span(chunks), indices_begin, indices_end) {} - ChunkedIndexMapper(util::span chunks, uint64_t* indices_begin, + : ChunkedIndexMapper(std::span(chunks), indices_begin, indices_end) {} + ChunkedIndexMapper(std::span chunks, uint64_t* indices_begin, uint64_t* indices_end) : chunk_lengths_(GetChunkLengths(chunks)), indices_begin_(indices_begin), @@ -154,7 +153,7 @@ class ARROW_EXPORT ChunkedIndexMapper { Status PhysicalToLogical(); private: - static std::vector GetChunkLengths(util::span chunks); + static std::vector GetChunkLengths(std::span chunks); static std::vector GetChunkLengths(const RecordBatchVector& chunks); std::vector chunk_lengths_; diff --git a/cpp/src/arrow/compute/kernels/hash_aggregate.cc b/cpp/src/arrow/compute/kernels/hash_aggregate.cc index ed50025ef5f..5ab9ff46d7b 100644 --- a/cpp/src/arrow/compute/kernels/hash_aggregate.cc +++ b/cpp/src/arrow/compute/kernels/hash_aggregate.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -45,15 +46,11 @@ #include "arrow/util/checked_cast.h" #include "arrow/util/int_util_overflow.h" #include "arrow/util/ree_util.h" -#include "arrow/util/span.h" #include "arrow/visit_type_inline.h" - namespace arrow::compute::internal { using ::arrow::internal::checked_cast; using ::arrow::internal::FirstTimeBitmapWriter; -using ::arrow::util::span; - namespace { // ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/compute/kernels/hash_aggregate_numeric.cc b/cpp/src/arrow/compute/kernels/hash_aggregate_numeric.cc index aa231430aa0..652684dd48c 100644 --- a/cpp/src/arrow/compute/kernels/hash_aggregate_numeric.cc +++ b/cpp/src/arrow/compute/kernels/hash_aggregate_numeric.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -32,10 +33,8 @@ #include "arrow/compute/row/grouper.h" #include "arrow/util/checked_cast.h" #include "arrow/util/int128_internal.h" -#include "arrow/util/span.h" #include "arrow/util/tdigest_internal.h" #include "arrow/visit_type_inline.h" - namespace arrow::compute::internal { namespace { diff --git a/cpp/src/arrow/compute/kernels/hash_aggregate_pivot.cc b/cpp/src/arrow/compute/kernels/hash_aggregate_pivot.cc index f60aa367ca2..030a862afc0 100644 --- a/cpp/src/arrow/compute/kernels/hash_aggregate_pivot.cc +++ b/cpp/src/arrow/compute/kernels/hash_aggregate_pivot.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -33,13 +34,10 @@ #include "arrow/util/bit_block_counter.h" #include "arrow/util/checked_cast.h" #include "arrow/util/logging_internal.h" -#include "arrow/util/span.h" #include "arrow/visit_type_inline.h" namespace arrow::compute::internal { -using ::arrow::util::span; - namespace { // ---------------------------------------------------------------------- @@ -57,7 +55,7 @@ struct GroupedPivotAccumulator { return Status::OK(); } - Status Consume(span groups, const std::shared_ptr& keys, + Status Consume(std::span groups, const std::shared_ptr& keys, const ArraySpan& values) { // To dispatch the values into the right (group, key) coordinates, // we first compute a vector of take indices for each output column. @@ -178,8 +176,8 @@ struct GroupedPivotAccumulator { return MergeColumns(std::move(new_columns)); } - Status Consume(span groups, std::optional maybe_key, - const ArraySpan& values) { + Status Consume(std::span groups, + std::optional maybe_key, const ArraySpan& values) { if (!maybe_key.has_value()) { // Nothing to update return Status::OK(); diff --git a/cpp/src/arrow/compute/kernels/pivot_internal.cc b/cpp/src/arrow/compute/kernels/pivot_internal.cc index e9065152d7f..c9ccc7d6076 100644 --- a/cpp/src/arrow/compute/kernels/pivot_internal.cc +++ b/cpp/src/arrow/compute/kernels/pivot_internal.cc @@ -37,8 +37,6 @@ namespace arrow::compute::internal { -using ::arrow::util::span; - struct ConcretePivotWiderKeyMapper : public PivotWiderKeyMapper { Status Init(const DataType& key_type, const PivotWiderOptions* options, ExecContext* ctx) { diff --git a/cpp/src/arrow/compute/kernels/vector_rank.cc b/cpp/src/arrow/compute/kernels/vector_rank.cc index ef7419ea7c5..adac794902d 100644 --- a/cpp/src/arrow/compute/kernels/vector_rank.cc +++ b/cpp/src/arrow/compute/kernels/vector_rank.cc @@ -27,8 +27,6 @@ namespace arrow::compute::internal { -using ::arrow::util::span; - namespace { // ---------------------------------------------------------------------- @@ -103,7 +101,8 @@ Result DoSortAndMarkDuplicate( physical_chunks, order, null_placement)); if (needs_duplicates) { const auto arrays = GetArrayPointers(physical_chunks); - auto value_selector = [resolver = ChunkedArrayResolver(span(arrays))](int64_t index) { + auto value_selector = [resolver = + ChunkedArrayResolver(std::span(arrays))](int64_t index) { return resolver.Resolve(index).Value(); }; MarkDuplicates(sorted, value_selector); diff --git a/cpp/src/arrow/compute/kernels/vector_sort.cc b/cpp/src/arrow/compute/kernels/vector_sort.cc index 41cb0a357a4..7cf60d1c2f2 100644 --- a/cpp/src/arrow/compute/kernels/vector_sort.cc +++ b/cpp/src/arrow/compute/kernels/vector_sort.cc @@ -26,8 +26,6 @@ namespace arrow { using internal::checked_cast; -using util::span; - namespace compute { namespace internal { @@ -177,7 +175,8 @@ class ChunkedArraySorter : public TypeVisitor { template void MergeNonNulls(CompressedChunkLocation* range_begin, CompressedChunkLocation* range_middle, - CompressedChunkLocation* range_end, span arrays, + CompressedChunkLocation* range_end, + std::span arrays, CompressedChunkLocation* temp_indices) { using ArrowType = typename ArrayType::TypeClass; @@ -202,7 +201,8 @@ class ChunkedArraySorter : public TypeVisitor { } template - auto ChunkValue(span arrays, CompressedChunkLocation loc) const { + auto ChunkValue(std::span arrays, + CompressedChunkLocation loc) const { return ResolvedChunk(arrays[loc.chunk_index()], static_cast(loc.index_in_chunk())) .template Value(); diff --git a/cpp/src/arrow/compute/kernels/vector_sort_internal.h b/cpp/src/arrow/compute/kernels/vector_sort_internal.h index 49704ff8069..8744a0a9182 100644 --- a/cpp/src/arrow/compute/kernels/vector_sort_internal.h +++ b/cpp/src/arrow/compute/kernels/vector_sort_internal.h @@ -272,7 +272,7 @@ NullPartitionResult PartitionNullsOnly(uint64_t* indices_begin, uint64_t* indice template ChunkedNullPartitionResult PartitionNullsOnly(CompressedChunkLocation* locations_begin, CompressedChunkLocation* locations_end, - util::span chunks, + std::span chunks, int64_t null_count, NullPlacement null_placement) { if (null_count == 0) { diff --git a/cpp/src/arrow/integration/json_internal.cc b/cpp/src/arrow/integration/json_internal.cc index 4b0fc693931..7ae5a2144bd 100644 --- a/cpp/src/arrow/integration/json_internal.cc +++ b/cpp/src/arrow/integration/json_internal.cc @@ -15,13 +15,12 @@ // specific language governing permissions and limitations // under the License. -#include "arrow/integration/json_internal.h" - #include #include #include #include #include +#include #include #include #include @@ -33,6 +32,7 @@ #include "arrow/array/builder_primitive.h" #include "arrow/array/builder_time.h" #include "arrow/extension_type.h" +#include "arrow/integration/json_internal.h" #include "arrow/ipc/dictionary.h" #include "arrow/record_batch.h" #include "arrow/result.h" @@ -48,12 +48,10 @@ #include "arrow/util/key_value_metadata.h" #include "arrow/util/logging_internal.h" #include "arrow/util/range.h" -#include "arrow/util/span.h" #include "arrow/util/string.h" #include "arrow/util/value_parsing.h" #include "arrow/visit_array_inline.h" #include "arrow/visit_type_inline.h" - using arrow::internal::checked_cast; using arrow::internal::Enumerate; using arrow::internal::ParseValue; @@ -1461,11 +1459,10 @@ class ArrayReader { GetMemberArray(obj_, "VARIADIC_DATA_BUFFERS")); using internal::Zip; - using util::span; BufferVector buffers; buffers.resize(json_variadic_bufs.Size() + 2); - for (auto [json_buf, buf] : Zip(json_variadic_bufs, span{buffers}.subspan(2))) { + for (auto [json_buf, buf] : Zip(json_variadic_bufs, std::span{buffers}.subspan(2))) { ARROW_ASSIGN_OR_RAISE(auto hex_string, GetStringView(json_buf)); ARROW_ASSIGN_OR_RAISE( buf, AllocateBuffer(static_cast(hex_string.size()) / 2, pool_)); @@ -1482,8 +1479,8 @@ class ArrayReader { ARROW_ASSIGN_OR_RAISE( buffers[1], AllocateBuffer(length_ * sizeof(BinaryViewType::c_type), pool_)); - span views{buffers[1]->mutable_data_as(), - static_cast(length_)}; + std::span views{buffers[1]->mutable_data_as(), + static_cast(length_)}; int64_t null_count = 0; for (auto [json_view, out_view, is_valid] : Zip(json_views, views, is_valid_)) { diff --git a/cpp/src/arrow/util/binary_view_util.h b/cpp/src/arrow/util/binary_view_util.h index eb079e2c548..edd585d8a4b 100644 --- a/cpp/src/arrow/util/binary_view_util.h +++ b/cpp/src/arrow/util/binary_view_util.h @@ -17,11 +17,11 @@ #pragma once +#include #include #include #include "arrow/type.h" -#include "arrow/util/span.h" namespace arrow::util { diff --git a/cpp/src/arrow/util/bitmap.h b/cpp/src/arrow/util/bitmap.h index 141d558c3a8..af5c6ecb5a7 100644 --- a/cpp/src/arrow/util/bitmap.h +++ b/cpp/src/arrow/util/bitmap.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -36,10 +37,8 @@ #include "arrow/util/compare.h" #include "arrow/util/endian.h" #include "arrow/util/functional.h" -#include "arrow/util/span.h" #include "arrow/util/string_util.h" #include "arrow/util/visibility.h" - namespace arrow { class BooleanArray; @@ -155,7 +154,7 @@ class ARROW_EXPORT Bitmap : public util::ToStringOstreamable, Bitmap bitmaps[N]; int64_t offsets[N]; int64_t bit_length = BitLength(bitmaps_arg, N); - util::span words[N]; + std::span words[N]; for (size_t i = 0; i < N; ++i) { bitmaps[i] = bitmaps_arg[i]; offsets[i] = bitmaps[i].template word_offset(); @@ -384,7 +383,7 @@ class ARROW_EXPORT Bitmap : public util::ToStringOstreamable, int64_t length() const { return length_; } /// span of all bytes which contain any bit in this Bitmap - util::span bytes() const { + std::span bytes() const { auto byte_offset = offset_ / 8; auto byte_count = bit_util::CeilDiv(offset_ + length_, 8) - byte_offset; return {data_ + byte_offset, static_cast(byte_count)}; @@ -404,7 +403,7 @@ class ARROW_EXPORT Bitmap : public util::ToStringOstreamable, /// \warning The words may contain bytes which lie outside the buffer or are /// uninitialized. template - util::span words() const { + std::span words() const { auto bytes_addr = reinterpret_cast(bytes().data()); auto words_addr = bytes_addr - bytes_addr % sizeof(Word); auto word_byte_count = diff --git a/cpp/src/arrow/util/bitmap_builders.cc b/cpp/src/arrow/util/bitmap_builders.cc index 000dda718d0..0014384d5ce 100644 --- a/cpp/src/arrow/util/bitmap_builders.cc +++ b/cpp/src/arrow/util/bitmap_builders.cc @@ -33,7 +33,7 @@ namespace internal { namespace { -void FillBitsFromBytes(util::span bytes, uint8_t* bits) { +void FillBitsFromBytes(std::span bytes, uint8_t* bits) { for (size_t i = 0; i < bytes.size(); ++i) { if (bytes[i] > 0) { bit_util::SetBit(bits, i); @@ -43,7 +43,7 @@ void FillBitsFromBytes(util::span bytes, uint8_t* bits) { } // namespace -Result> BytesToBits(util::span bytes, +Result> BytesToBits(std::span bytes, MemoryPool* pool) { int64_t bit_length = bit_util::BytesForBits(bytes.size()); diff --git a/cpp/src/arrow/util/bitmap_builders.h b/cpp/src/arrow/util/bitmap_builders.h index 4bf2edfdcbd..b9f98f679d0 100644 --- a/cpp/src/arrow/util/bitmap_builders.h +++ b/cpp/src/arrow/util/bitmap_builders.h @@ -19,13 +19,12 @@ #include #include +#include #include #include "arrow/result.h" #include "arrow/type_fwd.h" -#include "arrow/util/span.h" #include "arrow/util/visibility.h" - namespace arrow { namespace internal { @@ -37,7 +36,7 @@ Result> BitmapAllButOne(MemoryPool* pool, int64_t length /// \brief Convert vector of bytes to bitmap buffer ARROW_EXPORT -Result> BytesToBits(util::span bytes, +Result> BytesToBits(std::span bytes, MemoryPool* pool = default_memory_pool()); } // namespace internal diff --git a/cpp/src/arrow/util/float16_test.cc b/cpp/src/arrow/util/float16_test.cc index 5918381a269..63670a6b33a 100644 --- a/cpp/src/arrow/util/float16_test.cc +++ b/cpp/src/arrow/util/float16_test.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -24,9 +25,7 @@ #include "arrow/testing/gtest_util.h" #include "arrow/util/endian.h" #include "arrow/util/float16.h" -#include "arrow/util/span.h" #include "arrow/util/ubsan.h" - namespace arrow::util { namespace { diff --git a/cpp/src/arrow/util/rle_encoding_test.cc b/cpp/src/arrow/util/rle_encoding_test.cc index b2d4f7df6f1..92eb3af8ea9 100644 --- a/cpp/src/arrow/util/rle_encoding_test.cc +++ b/cpp/src/arrow/util/rle_encoding_test.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -35,8 +36,6 @@ #include "arrow/util/bit_util.h" #include "arrow/util/io_util.h" #include "arrow/util/rle_encoding_internal.h" -#include "arrow/util/span.h" - namespace arrow::util { const int MAX_WIDTH = 32; diff --git a/cpp/src/arrow/util/secure_string.cc b/cpp/src/arrow/util/secure_string.cc index bd52c55f312..d29edf080da 100644 --- a/cpp/src/arrow/util/secure_string.cc +++ b/cpp/src/arrow/util/secure_string.cc @@ -19,6 +19,7 @@ // https://en.cppreference.com/w/c/string/byte/memset #define __STDC_WANT_LIB_EXT1__ 1 #include +#include #include #if defined(ARROW_USE_OPENSSL) @@ -26,15 +27,13 @@ # include #endif +#include "arrow/util/logging.h" +#include "arrow/util/secure_string.h" #include "arrow/util/windows_compatibility.h" + #if defined(_WIN32) # include #endif - -#include "arrow/util/logging.h" -#include "arrow/util/secure_string.h" -#include "arrow/util/span.h" - namespace arrow::util { /// Note: @@ -181,11 +180,11 @@ std::size_t SecureString::length() const { return secret_.length(); } std::size_t SecureString::capacity() const { return secret_.capacity(); } -span SecureString::as_span() { +std::span SecureString::as_span() { return {reinterpret_cast(secret_.data()), secret_.size()}; } -span SecureString::as_span() const { +std::span SecureString::as_span() const { return {reinterpret_cast(secret_.data()), secret_.size()}; } diff --git a/cpp/src/arrow/util/secure_string.h b/cpp/src/arrow/util/secure_string.h index 30088c78d4c..36602c6a92f 100644 --- a/cpp/src/arrow/util/secure_string.h +++ b/cpp/src/arrow/util/secure_string.h @@ -18,9 +18,9 @@ #pragma once #include +#include #include -#include "arrow/util/span.h" #include "arrow/util/visibility.h" namespace arrow::util { @@ -56,8 +56,8 @@ class ARROW_EXPORT SecureString { [[nodiscard]] std::size_t length() const; [[nodiscard]] std::size_t capacity() const; - [[nodiscard]] span as_span(); - [[nodiscard]] span as_span() const; + [[nodiscard]] std::span as_span(); + [[nodiscard]] std::span as_span() const; [[nodiscard]] std::string_view as_view() const; void Dispose(); diff --git a/cpp/src/arrow/util/span.h b/cpp/src/arrow/util/span.h deleted file mode 100644 index abe8e61bebb..00000000000 --- a/cpp/src/arrow/util/span.h +++ /dev/null @@ -1,132 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include -#include - -namespace arrow::util { - -template -class span; - -/// std::span polyfill. -/// -/// Does not support static extents. -template -class span { - static_assert(sizeof(T), - R"( -std::span allows contiguous_iterators instead of just pointers, the enforcement -of which requires T to be a complete type. arrow::util::span does not support -contiguous_iterators, but T is still required to be a complete type to prevent -writing code which would break when it is replaced by std::span.)"); - - public: - using element_type = T; - using value_type = std::remove_cv_t; - using iterator = T*; - using const_iterator = const T*; - - span() = default; - span(const span&) = default; - span& operator=(const span&) = default; - - template >> - // NOLINTNEXTLINE runtime/explicit - constexpr span(span mut) : span{mut.data(), mut.size()} {} - - constexpr span(T* data, size_t count) : data_{data}, size_{count} {} - - constexpr span(T* begin, T* end) - : data_{begin}, size_{static_cast(end - begin)} {} - - template ())), - typename RS = decltype(std::size(std::declval())), - typename E = std::enable_if_t && - std::is_constructible_v>> - // NOLINTNEXTLINE runtime/explicit, non-const reference - constexpr span(R&& range) : data_{std::data(range)}, size_{std::size(range)} {} - - constexpr T* begin() const { return data_; } - constexpr T* end() const { return data_ + size_; } - constexpr T* data() const { return data_; } - - constexpr size_t size() const { return size_; } - constexpr size_t size_bytes() const { return size_ * sizeof(T); } - constexpr bool empty() const { return size_ == 0; } - - constexpr T& operator[](size_t i) { return data_[i]; } - constexpr const T& operator[](size_t i) const { return data_[i]; } - - constexpr span subspan(size_t offset) const { - if (offset > size_) return {data_, data_}; - return {data_ + offset, size_ - offset}; - } - - constexpr span subspan(size_t offset, size_t count) const { - auto out = subspan(offset); - if (count < out.size_) { - out.size_ = count; - } - return out; - } - - constexpr bool operator==(const span& other) const { - if (size_ != other.size_) return false; - - if constexpr (std::is_integral_v) { - if (size_ == 0) { - return true; // memcmp does not handle null pointers, even if size_ == 0 - } - return std::memcmp(data_, other.data_, size_bytes()) == 0; - } else { - T* ptr = data_; - for (const T& e : other) { - if (*ptr++ != e) return false; - } - return true; - } - } - constexpr bool operator!=(const span& other) const { return !(*this == other); } - - private: - T* data_{}; - size_t size_{}; -}; - -template -span(R& range) -> span>; - -template -span(T*, size_t) -> span; - -template -constexpr span as_bytes(span s) { - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -template -constexpr span as_writable_bytes(span s) { - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -} // namespace arrow::util diff --git a/cpp/src/arrow/util/span_test.cc b/cpp/src/arrow/util/span_test.cc deleted file mode 100644 index 01460c2bd03..00000000000 --- a/cpp/src/arrow/util/span_test.cc +++ /dev/null @@ -1,204 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include -#include - -#include - -#include "arrow/testing/gtest_util.h" -#include "arrow/testing/matchers.h" -#include "arrow/util/span.h" - -using testing::ElementsAre; -using testing::ElementsAreArray; -using testing::PrintToString; - -namespace arrow::util { - -template -std::ostream& operator<<(std::ostream& os, const span& span) { - // Inefficient but good enough for testing - os << PrintToString(std::vector(span.begin(), span.end())); - return os; -} - -TEST(Span, Construction) { - // const spans may be constructed from mutable spans - static_assert(std::is_constructible_v, span>); - // ... but mutable spans may be constructed from const spans - static_assert(!std::is_constructible_v, span>); - - int arr[] = {1, 2, 3}; - constexpr int const_arr[] = {7, 8, 9}; - - static_assert(std::is_constructible_v, decltype(arr)&>); - static_assert(!std::is_constructible_v, decltype(const_arr)&>); - - static_assert(std::is_constructible_v, decltype(arr)&>); - static_assert(std::is_constructible_v, decltype(const_arr)&>); - - static_assert(std::is_constructible_v, std::vector&>); - static_assert(!std::is_constructible_v, const std::vector&>); - static_assert(!std::is_constructible_v, std::vector&&>); - - static_assert(std::is_constructible_v, std::vector&>); - static_assert(std::is_constructible_v, const std::vector&>); - // const spans may even be constructed from rvalue ranges - static_assert(std::is_constructible_v, std::vector&&>); - - EXPECT_THAT(span(const_arr), ElementsAreArray(const_arr)); - EXPECT_THAT(span(arr), ElementsAreArray(arr)); - - static_assert(!std::is_constructible_v, decltype(const_arr)&>); - static_assert(!std::is_constructible_v, decltype(const_arr)&>); -} - -TEST(Span, TemplateArgumentDeduction) { - int arr[3]; - const int const_arr[] = {1, 2, 3}; - std::vector vec; - const std::vector const_vec; - static_assert(std::is_same_v>); - static_assert(std::is_same_v>); - static_assert(std::is_same_v>); - static_assert(std::is_same_v>); -} - -TEST(Span, Size) { - int arr[] = {1, 2, 3}; - EXPECT_EQ(span(arr).size(), 3); - EXPECT_EQ(span(arr).size_bytes(), sizeof(int) * 3); - - std::vector vec; - EXPECT_TRUE(span(vec).empty()); - EXPECT_EQ(span(vec).size(), 0); - EXPECT_EQ(span(vec).size_bytes(), 0); - - vec.resize(999); - EXPECT_FALSE(span(vec).empty()); - EXPECT_EQ(span(vec).size(), 999); - EXPECT_EQ(span(vec).size_bytes(), sizeof(int) * 999); -} - -TEST(Span, Equality) { - auto check_eq = [](auto l, auto r) { - ARROW_SCOPED_TRACE("l = ", l, ", r = ", r); - EXPECT_TRUE(l == r); - EXPECT_FALSE(l != r); - }; - auto check_ne = [](auto l, auto r) { - ARROW_SCOPED_TRACE("l = ", l, ", r = ", r); - EXPECT_TRUE(l != r); - EXPECT_FALSE(l == r); - }; - - { - // exercise integral branch with memcmp - check_eq(span(), span()); - - int arr[] = {1, 2, 3}; - check_eq(span(arr), span(arr)); - check_eq(span(arr).subspan(1), span(arr).subspan(1)); - check_ne(span(arr).subspan(1), span(arr).subspan(2)); - - std::vector vec{1, 2, 3}; - check_eq(span(vec), span(arr)); - check_eq(span(vec).subspan(1), span(arr).subspan(1)); - - vec = {2, 3, 4}; - check_ne(span(vec), span(arr)); - check_eq(span(vec).subspan(0, 2), span(arr).subspan(1)); - - // 0-sized - vec = {}; - check_ne(span(vec), span(arr)); - check_eq(span(vec), span(arr).subspan(3)); - } - { - // exercise non-integral branch with for loop - check_eq(span(), span()); - - std::string arr[] = {"a", "b", "c"}; - check_eq(span(arr), span(arr)); - check_eq(span(arr).subspan(1), span(arr).subspan(1)); - - std::vector vec{"a", "b", "c"}; - check_eq(span(vec), span(arr)); - check_eq(span(vec).subspan(1), span(arr).subspan(1)); - - vec = {"b", "c", "d"}; - check_ne(span(vec), span(arr)); - check_eq(span(vec).subspan(0, 2), span(arr).subspan(1)); - - // 0-sized - vec = {}; - check_ne(span(vec), span(arr)); - check_eq(span(vec), span(arr).subspan(3)); - } -} - -TEST(Span, SubSpan) { - int arr[] = {1, 2, 3}; - span s(arr); - - auto ExpectIdentical = [](span l, span r) { - EXPECT_EQ(l.data(), r.data()); - EXPECT_EQ(l.size(), r.size()); - }; - - ExpectIdentical(s.subspan(0), s); - ExpectIdentical(s.subspan(0, s.size()), s); - - for (size_t offset = 0; offset < s.size(); ++offset) { - span expected(arr + offset, s.size() - offset); - ExpectIdentical(s.subspan(offset), expected); - ExpectIdentical(s.subspan(offset, s.size() * 3), expected); - } - EXPECT_TRUE(s.subspan(s.size()).empty()); - EXPECT_TRUE(s.subspan(s.size() * 3).empty()); - - for (size_t length = 0; length < s.size(); ++length) { - span expected(arr, length); - ExpectIdentical(s.subspan(0, length), expected); - } - - ExpectIdentical(s.subspan(1, 1), span(arr + 1, 1)); -} - -TEST(Span, Mutation) { - size_t arr[] = {9, 9, 9, 9, 9}; - - span s(arr); - for (size_t i = 0; i < s.size(); ++i) { - s[i] = i * i; - } - - EXPECT_THAT(arr, ElementsAre(0, 1, 4, 9, 16)); - - auto set = [](span lhs, size_t rhs) { - for (size_t& i : lhs) { - i = rhs; - } - }; - set(span(arr), 0); - set(span(arr).subspan(1), 1); - set(span(arr).subspan(2, 2), 23); - EXPECT_THAT(arr, ElementsAre(0, 1, 23, 23, 1)); -} - -} // namespace arrow::util diff --git a/cpp/src/parquet/column_writer.cc b/cpp/src/parquet/column_writer.cc index 94b67dfa807..f671651b31e 100644 --- a/cpp/src/parquet/column_writer.cc +++ b/cpp/src/parquet/column_writer.cc @@ -1781,7 +1781,7 @@ class TypedColumnWriterImpl : public ColumnWriterImpl, } auto add_levels = [](std::vector& level_histogram, - ::arrow::util::span levels, int16_t max_level) { + std::span levels, int16_t max_level) { if (max_level == 0) { return; } diff --git a/cpp/src/parquet/encoding_test.cc b/cpp/src/parquet/encoding_test.cc index 66a3f7647fa..b7ac32ccfde 100644 --- a/cpp/src/parquet/encoding_test.cc +++ b/cpp/src/parquet/encoding_test.cc @@ -15,15 +15,16 @@ // specific language governing permissions and limitations // under the License. -#include - #include #include #include #include +#include #include #include +#include + #include "arrow/array.h" #include "arrow/array/builder_binary.h" #include "arrow/array/builder_dict.h" @@ -39,18 +40,15 @@ #include "arrow/util/bitmap_writer.h" #include "arrow/util/checked_cast.h" #include "arrow/util/endian.h" -#include "arrow/util/span.h" #include "arrow/util/string.h" #include "parquet/encoding.h" #include "parquet/platform.h" #include "parquet/schema.h" #include "parquet/test_util.h" #include "parquet/types.h" - using arrow::default_memory_pool; using arrow::MemoryPool; using arrow::internal::checked_cast; -using arrow::util::span; namespace bit_util = arrow::bit_util; @@ -1461,7 +1459,8 @@ class TestByteStreamSplitEncoding : public TestEncodingBase { USING_BASE_MEMBERS(); template - void CheckDecode(span encoded_data, span expected_decoded_data, + void CheckDecode(std::span encoded_data, + std::span expected_decoded_data, const ColumnDescriptor* descr = nullptr) { static_assert(sizeof(U) == sizeof(c_type)); static_assert(std::is_same_v == std::is_same_v); @@ -1479,8 +1478,8 @@ class TestByteStreamSplitEncoding : public TestEncodingBase { if constexpr (std::is_same_v) { auto type_length = descr->type_length(); for (int i = 0; i < num_elements; ++i) { - ASSERT_EQ(span(expected_decoded_data[i].ptr, type_length), - span(decoded_data[i].ptr, type_length)); + ASSERT_EQ(std::span(expected_decoded_data[i].ptr, type_length), + std::span(decoded_data[i].ptr, type_length)); } } else { for (int i = 0; i < num_elements; ++i) { @@ -1491,7 +1490,8 @@ class TestByteStreamSplitEncoding : public TestEncodingBase { } template - void CheckEncode(span data, span expected_encoded_data, + void CheckEncode(std::span data, + std::span expected_encoded_data, const ColumnDescriptor* descr = nullptr) { static_assert(sizeof(U) == sizeof(c_type)); static_assert(std::is_same_v == std::is_same_v); @@ -1544,7 +1544,8 @@ void TestByteStreamSplitEncoding::CheckDecode() { const std::vector expected_output{ FLBA{&raw_expected_output[0]}, FLBA{&raw_expected_output[3]}, FLBA{&raw_expected_output[6]}, FLBA{&raw_expected_output[9]}}; - CheckDecode(span{data}, span{expected_output}, FLBAColumnDescriptor(3).get()); + CheckDecode(std::span{data}, std::span{expected_output}, + FLBAColumnDescriptor(3).get()); } // - type_length = 1 { @@ -1553,7 +1554,8 @@ void TestByteStreamSplitEncoding::CheckDecode() { const std::vector expected_output{FLBA{&raw_expected_output[0]}, FLBA{&raw_expected_output[1]}, FLBA{&raw_expected_output[2]}}; - CheckDecode(span{data}, span{expected_output}, FLBAColumnDescriptor(1).get()); + CheckDecode(std::span{data}, std::span{expected_output}, + FLBAColumnDescriptor(1).get()); } } else if constexpr (sizeof(c_type) == 4) { // INT32, FLOAT @@ -1561,14 +1563,14 @@ void TestByteStreamSplitEncoding::CheckDecode() { 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC}; const auto expected_output = ToLittleEndian({0xAA774411U, 0xBB885522U, 0xCC996633U}); - CheckDecode(span{data}, span{expected_output}); + CheckDecode(std::span{data}, std::span{expected_output}); } else { // INT64, DOUBLE const std::vector data{0xDE, 0xC0, 0x37, 0x13, 0x11, 0x22, 0x33, 0x44, 0xAA, 0xBB, 0xCC, 0xDD, 0x55, 0x66, 0x77, 0x88}; const auto expected_output = ToLittleEndian({0x7755CCAA331137DEULL, 0x8866DDBB442213C0ULL}); - CheckDecode(span{data}, span{expected_output}); + CheckDecode(std::span{data}, std::span{expected_output}); } } @@ -1584,7 +1586,8 @@ void TestByteStreamSplitEncoding::CheckEncode() { FLBA{&raw_data[6]}, FLBA{&raw_data[9]}}; const std::vector expected_output{0x11, 0x44, 0x77, 0xAA, 0x22, 0x55, 0x88, 0xBB, 0x33, 0x66, 0x99, 0xCC}; - CheckEncode(span{data}, span{expected_output}, FLBAColumnDescriptor(3).get()); + CheckEncode(std::span{data}, std::span{expected_output}, + FLBAColumnDescriptor(3).get()); } // - type_length = 1 { @@ -1592,14 +1595,15 @@ void TestByteStreamSplitEncoding::CheckEncode() { const std::vector data{FLBA{&raw_data[0]}, FLBA{&raw_data[1]}, FLBA{&raw_data[2]}}; const std::vector expected_output{0x11, 0x22, 0x33}; - CheckEncode(span{data}, span{expected_output}, FLBAColumnDescriptor(1).get()); + CheckEncode(std::span{data}, std::span{expected_output}, + FLBAColumnDescriptor(1).get()); } } else if constexpr (sizeof(c_type) == 4) { // INT32, FLOAT const auto data = ToLittleEndian({0xaabbccddUL, 0x11223344UL}); const std::vector expected_output{0xdd, 0x44, 0xcc, 0x33, 0xbb, 0x22, 0xaa, 0x11}; - CheckEncode(span{data}, span{expected_output}); + CheckEncode(std::span{data}, std::span{expected_output}); } else { // INT64, DOUBLE const auto data = ToLittleEndian( @@ -1608,7 +1612,7 @@ void TestByteStreamSplitEncoding::CheckEncode() { 0x48, 0x08, 0xb8, 0x47, 0x07, 0xb7, 0x46, 0x06, 0xb6, 0x45, 0x05, 0xb5, 0x44, 0x04, 0xb4, 0x43, 0x03, 0xb3, 0x42, 0x02, 0xb2, 0x41, 0x01, 0xb1, }; - CheckEncode(span{data}, span{expected_output}); + CheckEncode(std::span{data}, std::span{expected_output}); } } @@ -2111,7 +2115,7 @@ std::shared_ptr DeltaEncode(std::vector lengths) { return encoder->FlushValues(); } -std::shared_ptr DeltaEncode(::arrow::util::span lengths) { +std::shared_ptr DeltaEncode(std::span lengths) { auto encoder = MakeTypedEncoder(Encoding::DELTA_BINARY_PACKED); encoder->Put(lengths.data(), static_cast(lengths.size())); return encoder->FlushValues(); @@ -2119,8 +2123,8 @@ std::shared_ptr DeltaEncode(::arrow::util::span lengths) std::shared_ptr DeltaEncode(std::shared_ptr<::arrow::Array>& lengths) { auto data = ::arrow::internal::checked_pointer_cast(lengths); - auto span = ::arrow::util::span{data->raw_values(), - static_cast(lengths->length())}; + auto span = std::span{data->raw_values(), + static_cast(lengths->length())}; return DeltaEncode(span); } diff --git a/cpp/src/parquet/encryption/encryption.h b/cpp/src/parquet/encryption/encryption.h index b4634b70473..023a536fd91 100644 --- a/cpp/src/parquet/encryption/encryption.h +++ b/cpp/src/parquet/encryption/encryption.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -95,7 +96,7 @@ class PARQUET_EXPORT KeyAccessDeniedException : public ParquetException { : ParquetException(columnPath.c_str()) {} }; -inline ::arrow::util::span str2span(const std::string& str) { +inline std::span str2span(const std::string& str) { if (str.empty()) { return {}; } diff --git a/cpp/src/parquet/encryption/encryption_internal.cc b/cpp/src/parquet/encryption/encryption_internal.cc index 9400fae0adf..e9fa2f545d6 100644 --- a/cpp/src/parquet/encryption/encryption_internal.cc +++ b/cpp/src/parquet/encryption/encryption_internal.cc @@ -15,25 +15,23 @@ // specific language governing permissions and limitations // under the License. -#include "parquet/encryption/encryption_internal.h" - -#include -#include -#include -#include - #include #include #include #include +#include #include #include #include +#include +#include +#include +#include + +#include "parquet/encryption/encryption_internal.h" #include "parquet/encryption/openssl_internal.h" #include "parquet/exception.h" - -using ::arrow::util::span; using parquet::ParquetException; namespace parquet::encryption { @@ -109,12 +107,13 @@ class AesEncryptor::AesEncryptorImpl : public AesCryptoContext { explicit AesEncryptorImpl(ParquetCipher::type alg_id, int32_t key_len, bool metadata, bool write_length); - int32_t Encrypt(span plaintext, span key, - span aad, span ciphertext); + int32_t Encrypt(std::span plaintext, std::span key, + std::span aad, std::span ciphertext); - int32_t SignedFooterEncrypt(span footer, span key, - span aad, span nonce, - span encrypted_footer); + int32_t SignedFooterEncrypt(std::span footer, + std::span key, std::span aad, + std::span nonce, + std::span encrypted_footer); [[nodiscard]] int32_t CiphertextLength(int64_t plaintext_len) const { if (plaintext_len < 0) { @@ -135,12 +134,12 @@ class AesEncryptor::AesEncryptorImpl : public AesCryptoContext { private: [[nodiscard]] CipherContext MakeCipherContext() const; - int32_t GcmEncrypt(span plaintext, span key, - span nonce, span aad, - span ciphertext); + int32_t GcmEncrypt(std::span plaintext, std::span key, + std::span nonce, std::span aad, + std::span ciphertext); - int32_t CtrEncrypt(span plaintext, span key, - span nonce, span ciphertext); + int32_t CtrEncrypt(std::span plaintext, std::span key, + std::span nonce, std::span ciphertext); }; AesEncryptor::AesEncryptorImpl::AesEncryptorImpl(ParquetCipher::type alg_id, @@ -174,8 +173,9 @@ AesCryptoContext::CipherContext AesEncryptor::AesEncryptorImpl::MakeCipherContex } int32_t AesEncryptor::AesEncryptorImpl::SignedFooterEncrypt( - span footer, span key, span aad, - span nonce, span encrypted_footer) { + std::span footer, std::span key, + std::span aad, std::span nonce, + std::span encrypted_footer) { if (static_cast(key_length_) != key.size()) { std::stringstream ss; ss << "Wrong key length " << key.size() << ". Should be " << key_length_; @@ -196,10 +196,10 @@ int32_t AesEncryptor::AesEncryptorImpl::SignedFooterEncrypt( return GcmEncrypt(footer, key, nonce, aad, encrypted_footer); } -int32_t AesEncryptor::AesEncryptorImpl::Encrypt(span plaintext, - span key, - span aad, - span ciphertext) { +int32_t AesEncryptor::AesEncryptorImpl::Encrypt(std::span plaintext, + std::span key, + std::span aad, + std::span ciphertext) { if (static_cast(key_length_) != key.size()) { std::stringstream ss; ss << "Wrong key length " << key.size() << ". Should be " << key_length_; @@ -225,11 +225,11 @@ int32_t AesEncryptor::AesEncryptorImpl::Encrypt(span plaintext, return CtrEncrypt(plaintext, key, nonce, ciphertext); } -int32_t AesEncryptor::AesEncryptorImpl::GcmEncrypt(span plaintext, - span key, - span nonce, - span aad, - span ciphertext) { +int32_t AesEncryptor::AesEncryptorImpl::GcmEncrypt(std::span plaintext, + std::span key, + std::span nonce, + std::span aad, + std::span ciphertext) { int len; int32_t ciphertext_len; @@ -304,10 +304,10 @@ int32_t AesEncryptor::AesEncryptorImpl::GcmEncrypt(span plaintext return length_buffer_length_ + buffer_size; } -int32_t AesEncryptor::AesEncryptorImpl::CtrEncrypt(span plaintext, - span key, - span nonce, - span ciphertext) { +int32_t AesEncryptor::AesEncryptorImpl::CtrEncrypt(std::span plaintext, + std::span key, + std::span nonce, + std::span ciphertext) { int len; int32_t ciphertext_len; @@ -371,11 +371,11 @@ int32_t AesEncryptor::AesEncryptorImpl::CtrEncrypt(span plaintext AesEncryptor::~AesEncryptor() = default; -int32_t AesEncryptor::SignedFooterEncrypt(span footer, - span key, - span aad, - span nonce, - span encrypted_footer) { +int32_t AesEncryptor::SignedFooterEncrypt(std::span footer, + std::span key, + std::span aad, + std::span nonce, + std::span encrypted_footer) { return impl_->SignedFooterEncrypt(footer, key, aad, nonce, encrypted_footer); } @@ -383,8 +383,9 @@ int32_t AesEncryptor::CiphertextLength(int64_t plaintext_len) const { return impl_->CiphertextLength(plaintext_len); } -int32_t AesEncryptor::Encrypt(span plaintext, span key, - span aad, span ciphertext) { +int32_t AesEncryptor::Encrypt(std::span plaintext, + std::span key, std::span aad, + std::span ciphertext) { return impl_->Encrypt(plaintext, key, aad, ciphertext); } @@ -398,8 +399,8 @@ class AesDecryptor::AesDecryptorImpl : AesCryptoContext { explicit AesDecryptorImpl(ParquetCipher::type alg_id, int32_t key_len, bool metadata, bool contains_length); - int32_t Decrypt(span ciphertext, span key, - span aad, span plaintext); + int32_t Decrypt(std::span ciphertext, std::span key, + std::span aad, std::span plaintext); [[nodiscard]] int32_t PlaintextLength(int32_t ciphertext_len) const { if (ciphertext_len < ciphertext_size_delta_) { @@ -431,17 +432,18 @@ class AesDecryptor::AesDecryptorImpl : AesCryptoContext { /// Get the actual ciphertext length, inclusive of the length buffer length, /// and validate that the provided buffer size is large enough. - [[nodiscard]] int32_t GetCiphertextLength(span ciphertext) const; + [[nodiscard]] int32_t GetCiphertextLength(std::span ciphertext) const; - int32_t GcmDecrypt(span ciphertext, span key, - span aad, span plaintext); + int32_t GcmDecrypt(std::span ciphertext, std::span key, + std::span aad, std::span plaintext); - int32_t CtrDecrypt(span ciphertext, span key, - span plaintext); + int32_t CtrDecrypt(std::span ciphertext, std::span key, + std::span plaintext); }; -int32_t AesDecryptor::Decrypt(span ciphertext, span key, - span aad, span plaintext) { +int32_t AesDecryptor::Decrypt(std::span ciphertext, + std::span key, std::span aad, + std::span plaintext) { return impl_->Decrypt(ciphertext, key, aad, plaintext); } @@ -502,7 +504,7 @@ int32_t AesDecryptor::CiphertextLength(int32_t plaintext_len) const { } int32_t AesDecryptor::AesDecryptorImpl::GetCiphertextLength( - span ciphertext) const { + std::span ciphertext) const { if (length_buffer_length_ > 0) { // Note: length_buffer_length_ must be either 0 or kBufferSizeLength if (ciphertext.size() < static_cast(kBufferSizeLength)) { @@ -547,10 +549,10 @@ int32_t AesDecryptor::AesDecryptorImpl::GetCiphertextLength( } } -int32_t AesDecryptor::AesDecryptorImpl::GcmDecrypt(span ciphertext, - span key, - span aad, - span plaintext) { +int32_t AesDecryptor::AesDecryptorImpl::GcmDecrypt(std::span ciphertext, + std::span key, + std::span aad, + std::span plaintext) { int len; int32_t plaintext_len; @@ -622,9 +624,9 @@ int32_t AesDecryptor::AesDecryptorImpl::GcmDecrypt(span ciphertex return plaintext_len; } -int32_t AesDecryptor::AesDecryptorImpl::CtrDecrypt(span ciphertext, - span key, - span plaintext) { +int32_t AesDecryptor::AesDecryptorImpl::CtrDecrypt(std::span ciphertext, + std::span key, + std::span plaintext) { int len; int32_t plaintext_len; @@ -681,10 +683,10 @@ int32_t AesDecryptor::AesDecryptorImpl::CtrDecrypt(span ciphertex return plaintext_len; } -int32_t AesDecryptor::AesDecryptorImpl::Decrypt(span ciphertext, - span key, - span aad, - span plaintext) { +int32_t AesDecryptor::AesDecryptorImpl::Decrypt(std::span ciphertext, + std::span key, + std::span aad, + std::span plaintext) { if (static_cast(key_length_) != key.size()) { std::stringstream ss; ss << "Wrong key length " << key.size() << ". Should be " << key_length_; diff --git a/cpp/src/parquet/encryption/encryption_internal.h b/cpp/src/parquet/encryption/encryption_internal.h index 06252749565..de256809fa9 100644 --- a/cpp/src/parquet/encryption/encryption_internal.h +++ b/cpp/src/parquet/encryption/encryption_internal.h @@ -18,10 +18,10 @@ #pragma once #include +#include #include #include -#include "arrow/util/span.h" #include "parquet/properties.h" #include "parquet/types.h" @@ -62,17 +62,14 @@ class PARQUET_EXPORT AesEncryptor { /// Encrypts plaintext with the key and aad. Key length is passed only for validation. /// If different from value in constructor, exception will be thrown. - int32_t Encrypt(::arrow::util::span plaintext, - ::arrow::util::span key, - ::arrow::util::span aad, - ::arrow::util::span ciphertext); + int32_t Encrypt(std::span plaintext, std::span key, + std::span aad, std::span ciphertext); /// Encrypts plaintext footer, in order to compute footer signature (tag). - int32_t SignedFooterEncrypt(::arrow::util::span footer, - ::arrow::util::span key, - ::arrow::util::span aad, - ::arrow::util::span nonce, - ::arrow::util::span encrypted_footer); + int32_t SignedFooterEncrypt(std::span footer, + std::span key, std::span aad, + std::span nonce, + std::span encrypted_footer); private: // PIMPL Idiom @@ -107,10 +104,8 @@ class PARQUET_EXPORT AesDecryptor { /// validation. If different from value in constructor, exception will be thrown. /// The caller is responsible for ensuring that the plaintext buffer is at least as /// large as PlaintextLength(ciphertext_len). - int32_t Decrypt(::arrow::util::span ciphertext, - ::arrow::util::span key, - ::arrow::util::span aad, - ::arrow::util::span plaintext); + int32_t Decrypt(std::span ciphertext, std::span key, + std::span aad, std::span plaintext); private: // PIMPL Idiom diff --git a/cpp/src/parquet/encryption/encryption_internal_nossl.cc b/cpp/src/parquet/encryption/encryption_internal_nossl.cc index 2450f8654d6..715806e65e5 100644 --- a/cpp/src/parquet/encryption/encryption_internal_nossl.cc +++ b/cpp/src/parquet/encryption/encryption_internal_nossl.cc @@ -33,11 +33,11 @@ class AesEncryptor::AesEncryptorImpl {}; AesEncryptor::~AesEncryptor() {} -int32_t AesEncryptor::SignedFooterEncrypt(::arrow::util::span footer, - ::arrow::util::span key, - ::arrow::util::span aad, - ::arrow::util::span nonce, - ::arrow::util::span encrypted_footer) { +int32_t AesEncryptor::SignedFooterEncrypt(std::span footer, + std::span key, + std::span aad, + std::span nonce, + std::span encrypted_footer) { ThrowOpenSSLRequiredException(); return -1; } @@ -47,10 +47,10 @@ int32_t AesEncryptor::CiphertextLength(int64_t plaintext_len) const { return -1; } -int32_t AesEncryptor::Encrypt(::arrow::util::span plaintext, - ::arrow::util::span key, - ::arrow::util::span aad, - ::arrow::util::span ciphertext) { +int32_t AesEncryptor::Encrypt(std::span plaintext, + std::span key, + std::span aad, + std::span ciphertext) { ThrowOpenSSLRequiredException(); return -1; } @@ -62,10 +62,10 @@ AesEncryptor::AesEncryptor(ParquetCipher::type alg_id, int32_t key_len, bool met class AesDecryptor::AesDecryptorImpl {}; -int32_t AesDecryptor::Decrypt(::arrow::util::span ciphertext, - ::arrow::util::span key, - ::arrow::util::span aad, - ::arrow::util::span plaintext) { +int32_t AesDecryptor::Decrypt(std::span ciphertext, + std::span key, + std::span aad, + std::span plaintext) { ThrowOpenSSLRequiredException(); return -1; } diff --git a/cpp/src/parquet/encryption/encryption_internal_test.cc b/cpp/src/parquet/encryption/encryption_internal_test.cc index bf6607e3287..1c96f4cb721 100644 --- a/cpp/src/parquet/encryption/encryption_internal_test.cc +++ b/cpp/src/parquet/encryption/encryption_internal_test.cc @@ -97,7 +97,7 @@ class TestAesEncryption : public ::testing::Test { int32_t expected_plaintext_length = decryptor.PlaintextLength(ciphertext_length); std::vector decrypted_text(expected_plaintext_length, '\0'); - ::arrow::util::span truncated_ciphertext(ciphertext.data(), + std::span truncated_ciphertext(ciphertext.data(), ciphertext_length - 1); EXPECT_THROW(decryptor.Decrypt(truncated_ciphertext, str2span(key_), str2span(aad_), decrypted_text), diff --git a/cpp/src/parquet/encryption/internal_file_decryptor.cc b/cpp/src/parquet/encryption/internal_file_decryptor.cc index b90d3158559..e7eed4529b9 100644 --- a/cpp/src/parquet/encryption/internal_file_decryptor.cc +++ b/cpp/src/parquet/encryption/internal_file_decryptor.cc @@ -47,8 +47,8 @@ int32_t Decryptor::CiphertextLength(int32_t plaintext_len) const { return aes_decryptor_->CiphertextLength(plaintext_len); } -int32_t Decryptor::Decrypt(::arrow::util::span ciphertext, - ::arrow::util::span plaintext) { +int32_t Decryptor::Decrypt(std::span ciphertext, + std::span plaintext) { return aes_decryptor_->Decrypt(ciphertext, key_.as_span(), str2span(aad_), plaintext); } diff --git a/cpp/src/parquet/encryption/internal_file_decryptor.h b/cpp/src/parquet/encryption/internal_file_decryptor.h index a365b4df4bf..7a21fa55a66 100644 --- a/cpp/src/parquet/encryption/internal_file_decryptor.h +++ b/cpp/src/parquet/encryption/internal_file_decryptor.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -52,8 +53,8 @@ class PARQUET_EXPORT Decryptor { [[nodiscard]] int32_t PlaintextLength(int32_t ciphertext_len) const; [[nodiscard]] int32_t CiphertextLength(int32_t plaintext_len) const; - int32_t Decrypt(::arrow::util::span ciphertext, - ::arrow::util::span plaintext); + int32_t Decrypt(std::span ciphertext, + std::span plaintext); private: std::unique_ptr aes_decryptor_; diff --git a/cpp/src/parquet/encryption/internal_file_encryptor.cc b/cpp/src/parquet/encryption/internal_file_encryptor.cc index f6fc0849984..ce5620d1e9b 100644 --- a/cpp/src/parquet/encryption/internal_file_encryptor.cc +++ b/cpp/src/parquet/encryption/internal_file_encryptor.cc @@ -37,8 +37,8 @@ int32_t Encryptor::CiphertextLength(int64_t plaintext_len) const { return aes_encryptor_->CiphertextLength(plaintext_len); } -int32_t Encryptor::Encrypt(::arrow::util::span plaintext, - ::arrow::util::span ciphertext) { +int32_t Encryptor::Encrypt(std::span plaintext, + std::span ciphertext) { return aes_encryptor_->Encrypt(plaintext, key_.as_span(), str2span(aad_), ciphertext); } diff --git a/cpp/src/parquet/encryption/internal_file_encryptor.h b/cpp/src/parquet/encryption/internal_file_encryptor.h index ee15fe32de9..b430c5cc139 100644 --- a/cpp/src/parquet/encryption/internal_file_encryptor.h +++ b/cpp/src/parquet/encryption/internal_file_encryptor.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -44,8 +45,8 @@ class PARQUET_EXPORT Encryptor { [[nodiscard]] int32_t CiphertextLength(int64_t plaintext_len) const; - int32_t Encrypt(::arrow::util::span plaintext, - ::arrow::util::span ciphertext); + int32_t Encrypt(std::span plaintext, + std::span ciphertext); bool EncryptColumnMetaData( bool encrypted_footer, diff --git a/cpp/src/parquet/encryption/key_toolkit_internal.cc b/cpp/src/parquet/encryption/key_toolkit_internal.cc index 60a8a52206c..407d4297b2a 100644 --- a/cpp/src/parquet/encryption/key_toolkit_internal.cc +++ b/cpp/src/parquet/encryption/key_toolkit_internal.cc @@ -38,7 +38,7 @@ std::string EncryptKeyLocally(const SecureString& key_bytes, int32_t encrypted_key_len = key_encryptor.CiphertextLength(static_cast(key_bytes.size())); std::string encrypted_key(encrypted_key_len, '\0'); - ::arrow::util::span encrypted_key_span( + std::span encrypted_key_span( reinterpret_cast(&encrypted_key[0]), encrypted_key_len); encrypted_key_len = key_encryptor.Encrypt(key_bytes.as_span(), master_key.as_span(), diff --git a/cpp/src/parquet/geospatial/util_internal.cc b/cpp/src/parquet/geospatial/util_internal.cc index d5c8d662884..9605d627a2a 100644 --- a/cpp/src/parquet/geospatial/util_internal.cc +++ b/cpp/src/parquet/geospatial/util_internal.cc @@ -147,11 +147,11 @@ std::vector WKBGeometryBounder::GeometryTypes() const { } void WKBGeometryBounder::MergeGeometry(std::string_view bytes_wkb) { - MergeGeometry(::arrow::util::span(reinterpret_cast(bytes_wkb.data()), + MergeGeometry(std::span(reinterpret_cast(bytes_wkb.data()), bytes_wkb.size())); } -void WKBGeometryBounder::MergeGeometry(::arrow::util::span bytes_wkb) { +void WKBGeometryBounder::MergeGeometry(std::span bytes_wkb) { WKBBuffer src{bytes_wkb.data(), static_cast(bytes_wkb.size())}; MergeGeometryInternal(&src, /*record_wkb_type=*/true); if (src.size() != 0) { diff --git a/cpp/src/parquet/geospatial/util_internal.h b/cpp/src/parquet/geospatial/util_internal.h index 2de9e1d076f..362ea7ed55f 100644 --- a/cpp/src/parquet/geospatial/util_internal.h +++ b/cpp/src/parquet/geospatial/util_internal.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -94,19 +95,19 @@ struct PARQUET_EXPORT BoundingBox { BoundingBox& operator=(const BoundingBox&) = default; /// \brief Update the X and Y bounds to ensure these bounds contain coord - void UpdateXY(::arrow::util::span coord) { + void UpdateXY(std::span coord) { DCHECK_EQ(coord.size(), 2); UpdateInternal(coord); } /// \brief Update the X, Y, and Z bounds to ensure these bounds contain coord - void UpdateXYZ(::arrow::util::span coord) { + void UpdateXYZ(std::span coord) { DCHECK_EQ(coord.size(), 3); UpdateInternal(coord); } /// \brief Update the X, Y, and M bounds to ensure these bounds contain coord - void UpdateXYM(::arrow::util::span coord) { + void UpdateXYM(std::span coord) { DCHECK_EQ(coord.size(), 3); min[0] = std::min(min[0], coord[0]); min[1] = std::min(min[1], coord[1]); @@ -117,7 +118,7 @@ struct PARQUET_EXPORT BoundingBox { } /// \brief Update the X, Y, Z, and M bounds to ensure these bounds contain coord - void UpdateXYZM(::arrow::util::span coord) { + void UpdateXYZM(std::span coord) { DCHECK_EQ(coord.size(), 4); UpdateInternal(coord); } @@ -190,13 +191,13 @@ class PARQUET_EXPORT WKBGeometryBounder { /// the geometry is added to the internal geometry type list. void MergeGeometry(std::string_view bytes_wkb); - void MergeGeometry(::arrow::util::span bytes_wkb); + void MergeGeometry(std::span bytes_wkb); /// \brief Accumulate the bounds of a previously-calculated BoundingBox void MergeBox(const BoundingBox& box) { box_.Merge(box); } /// \brief Accumulate a previously-calculated list of geometry types - void MergeGeometryTypes(::arrow::util::span geospatial_types) { + void MergeGeometryTypes(std::span geospatial_types) { geospatial_types_.insert(geospatial_types.begin(), geospatial_types.end()); } diff --git a/cpp/src/parquet/metadata.cc b/cpp/src/parquet/metadata.cc index 42dd8e52ee9..0f04df8e4cb 100644 --- a/cpp/src/parquet/metadata.cc +++ b/cpp/src/parquet/metadata.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,6 @@ #include "parquet/size_statistics.h" #include "parquet/statistics.h" #include "parquet/thrift_internal.h" - using ::arrow::util::SecureString; namespace parquet { @@ -809,12 +809,11 @@ class FileMetaData::FileMetaDataImpl { uint32_t serialized_len = metadata_len_; ThriftSerializer serializer; serializer.SerializeToBuffer(metadata_.get(), &serialized_len, &serialized_data); - ::arrow::util::span serialized_data_span(serialized_data, - serialized_len); + std::span serialized_data_span(serialized_data, serialized_len); // encrypt with nonce - ::arrow::util::span nonce(reinterpret_cast(signature), - encryption::kNonceLength); + std::span nonce(reinterpret_cast(signature), + encryption::kNonceLength); auto tag = reinterpret_cast(signature) + encryption::kNonceLength; const SecureString& key = file_decryptor_->GetFooterKey(); @@ -867,8 +866,7 @@ class FileMetaData::FileMetaDataImpl { uint8_t* serialized_data; uint32_t serialized_len; serializer.SerializeToBuffer(metadata_.get(), &serialized_len, &serialized_data); - ::arrow::util::span serialized_data_span(serialized_data, - serialized_len); + std::span serialized_data_span(serialized_data, serialized_len); // encrypt the footer key std::vector encrypted_data(encryptor->CiphertextLength(serialized_len)); @@ -1737,8 +1735,7 @@ class ColumnChunkMetaDataBuilder::ColumnChunkMetaDataBuilderImpl { serializer.SerializeToBuffer(&column_chunk_->meta_data, &serialized_len, &serialized_data); - ::arrow::util::span serialized_data_span(serialized_data, - serialized_len); + std::span serialized_data_span(serialized_data, serialized_len); std::vector encrypted_data(encryptor->CiphertextLength(serialized_len)); int32_t encrypted_len = encryptor->Encrypt(serialized_data_span, encrypted_data); diff --git a/cpp/src/parquet/size_statistics.cc b/cpp/src/parquet/size_statistics.cc index 0b30d7c8bbd..d12a07c3dca 100644 --- a/cpp/src/parquet/size_statistics.cc +++ b/cpp/src/parquet/size_statistics.cc @@ -32,8 +32,8 @@ namespace parquet { namespace { -void MergeLevelHistogram(::arrow::util::span histogram, - ::arrow::util::span other) { +void MergeLevelHistogram(std::span histogram, + std::span other) { ARROW_DCHECK_EQ(histogram.size(), other.size()); std::transform(histogram.begin(), histogram.end(), other.begin(), histogram.begin(), std::plus<>()); @@ -143,8 +143,8 @@ std::ostream& operator<<(std::ostream& os, const SizeStatistics& size_stats) { return os; } -void UpdateLevelHistogram(::arrow::util::span levels, - ::arrow::util::span histogram) { +void UpdateLevelHistogram(std::span levels, + std::span histogram) { const int64_t num_levels = static_cast(levels.size()); DCHECK_GE(histogram.size(), 1); const int16_t max_level = static_cast(histogram.size() - 1); diff --git a/cpp/src/parquet/size_statistics.h b/cpp/src/parquet/size_statistics.h index ec79b8c4f8b..5b41b0596b2 100644 --- a/cpp/src/parquet/size_statistics.h +++ b/cpp/src/parquet/size_statistics.h @@ -20,9 +20,9 @@ #include #include #include +#include #include -#include "arrow/util/span.h" #include "parquet/platform.h" #include "parquet/type_fwd.h" @@ -96,7 +96,6 @@ PARQUET_EXPORT std::ostream& operator<<(std::ostream&, const SizeStatistics&); PARQUET_EXPORT -void UpdateLevelHistogram(::arrow::util::span levels, - ::arrow::util::span histogram); +void UpdateLevelHistogram(std::span levels, std::span histogram); } // namespace parquet diff --git a/cpp/src/parquet/size_statistics_test.cc b/cpp/src/parquet/size_statistics_test.cc index 6e8cec9a130..463d28a934b 100644 --- a/cpp/src/parquet/size_statistics_test.cc +++ b/cpp/src/parquet/size_statistics_test.cc @@ -15,17 +15,16 @@ // specific language governing permissions and limitations // under the License. -#include "gmock/gmock.h" -#include "gtest/gtest.h" - #include #include #include +#include +#include "gmock/gmock.h" +#include "gtest/gtest.h" #include "arrow/buffer.h" #include "arrow/table.h" #include "arrow/testing/gtest_util.h" -#include "arrow/util/span.h" #include "parquet/arrow/reader.h" #include "parquet/arrow/schema.h" #include "parquet/arrow/writer.h" @@ -37,7 +36,6 @@ #include "parquet/test_util.h" #include "parquet/thrift_internal.h" #include "parquet/types.h" - namespace parquet { TEST(SizeStatistics, UpdateLevelHistogram) { diff --git a/cpp/src/parquet/stream_writer.h b/cpp/src/parquet/stream_writer.h index 76265140222..c4a3ccfe2fa 100644 --- a/cpp/src/parquet/stream_writer.h +++ b/cpp/src/parquet/stream_writer.h @@ -22,12 +22,11 @@ #include #include #include +#include #include #include #include -#include "arrow/util/span.h" - #include "parquet/column_writer.h" #include "parquet/file_writer.h" @@ -154,7 +153,7 @@ class PARQUET_EXPORT StreamWriter { StreamWriter& operator<<(::std::string_view v); /// \brief Helper class to write variable length raw data. - using RawDataView = ::arrow::util::span; + using RawDataView = std::span; /// \brief Output operators for variable length raw data. StreamWriter& operator<<(RawDataView v); diff --git a/cpp/src/parquet/thrift_internal.h b/cpp/src/parquet/thrift_internal.h index 1ffe99eb3c9..57f377144e3 100644 --- a/cpp/src/parquet/thrift_internal.h +++ b/cpp/src/parquet/thrift_internal.h @@ -21,14 +21,13 @@ #include #include - #include +#include #include #include #include #include #include - // TCompactProtocol requires some #defines to work right. #define SIGNED_RIGHT_SHIFT_IS 1 #define ARITHMETIC_RIGHT_SHIFT 1 @@ -580,7 +579,7 @@ class ThriftDeserializer { // decrypt auto decrypted_buffer = AllocateBuffer( decryptor->pool(), decryptor->PlaintextLength(static_cast(clen))); - ::arrow::util::span cipher_buf(buf, clen); + std::span cipher_buf(buf, clen); uint32_t decrypted_buffer_len = decryptor->Decrypt(cipher_buf, decrypted_buffer->mutable_span_as()); if (decrypted_buffer_len <= 0) { @@ -690,7 +689,7 @@ class ThriftSerializer { uint32_t out_length, Encryptor* encryptor) { auto cipher_buffer = AllocateBuffer(encryptor->pool(), encryptor->CiphertextLength(out_length)); - ::arrow::util::span out_span(out_buffer, out_length); + std::span out_span(out_buffer, out_length); int32_t cipher_buffer_len = encryptor->Encrypt(out_span, cipher_buffer->mutable_span_as());