From d701c68050d931c3067a0ecb5f099a39dfc08166 Mon Sep 17 00:00:00 2001 From: Dane Pitkin Date: Fri, 23 Aug 2024 14:41:38 +0000 Subject: [PATCH] Revert "GH-43728:[Python] ChunkedArray fails gracefully on non-cpu devices" This reverts commit 1fcdb1f790f9d34b4d63e33f8a162b0346bc2ab5. --- cpp/src/arrow/chunked_array.cc | 12 ------------ cpp/src/arrow/chunked_array.h | 10 ---------- python/pyarrow/includes/libarrow.pxd | 2 -- python/pyarrow/lib.pxd | 1 - python/pyarrow/table.pxi | 22 ---------------------- 5 files changed, 47 deletions(-) diff --git a/cpp/src/arrow/chunked_array.cc b/cpp/src/arrow/chunked_array.cc index a30ece2f5e43f..dd6aa51534fcb 100644 --- a/cpp/src/arrow/chunked_array.cc +++ b/cpp/src/arrow/chunked_array.cc @@ -49,7 +49,6 @@ ChunkedArray::ChunkedArray(ArrayVector chunks, std::shared_ptr type) type_(std::move(type)), length_(0), null_count_(0), - device_type_(DeviceAllocationType::kCPU), chunk_resolver_{chunks_} { if (type_ == nullptr) { ARROW_CHECK_GT(chunks_.size(), 0) @@ -57,14 +56,9 @@ ChunkedArray::ChunkedArray(ArrayVector chunks, std::shared_ptr type) type_ = chunks_[0]->type(); } - if (chunks_.size() > 0) { - device_type_ = chunks[0]->device_type(); - } - for (const auto& chunk : chunks_) { length_ += chunk->length(); null_count_ += chunk->null_count(); - DCHECK_EQ(device_type_, chunk->device_type()); } } @@ -112,9 +106,6 @@ bool ChunkedArray::Equals(const ChunkedArray& other, const EqualOptions& opts) c if (null_count_ != other.null_count()) { return false; } - if (device_type_ != other.device_type()) { - return false; - } // We cannot toggle check_metadata here yet, so we don't check it if (!type_->Equals(*other.type_, /*check_metadata=*/false)) { return false; @@ -170,9 +161,6 @@ bool ChunkedArray::ApproxEquals(const ChunkedArray& other, if (null_count_ != other.null_count()) { return false; } - if (device_type_ != other.device_type()) { - return false; - } // We cannot toggle check_metadata here yet, so we don't check it if (!type_->Equals(*other.type_, /*check_metadata=*/false)) { return false; diff --git a/cpp/src/arrow/chunked_array.h b/cpp/src/arrow/chunked_array.h index 8c9647271c5eb..a561b9b3ce21d 100644 --- a/cpp/src/arrow/chunked_array.h +++ b/cpp/src/arrow/chunked_array.h @@ -191,21 +191,11 @@ class ARROW_EXPORT ChunkedArray { /// \return Status Status ValidateFull() const; - /// \brief Return the device_type that this chunked array's data is allocated - /// on. - /// - /// This just delegates to calling device_type on the underlying ArrayData - /// object which backs this Array. - /// - /// \return DeviceAllocationType - DeviceAllocationType device_type() const { return device_type_; } - protected: ArrayVector chunks_; std::shared_ptr type_; int64_t length_; int64_t null_count_; - DeviceAllocationType device_type_; private: template diff --git a/python/pyarrow/includes/libarrow.pxd b/python/pyarrow/includes/libarrow.pxd index 8d6455c0c44c0..c2346750a196f 100644 --- a/python/pyarrow/includes/libarrow.pxd +++ b/python/pyarrow/includes/libarrow.pxd @@ -983,8 +983,6 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil: CResult[vector[shared_ptr[CChunkedArray]]] Flatten(CMemoryPool* pool) - CDeviceAllocationType device_type() - CStatus Validate() const CStatus ValidateFull() const diff --git a/python/pyarrow/lib.pxd b/python/pyarrow/lib.pxd index 8694c2230c156..5c3d981c3adc7 100644 --- a/python/pyarrow/lib.pxd +++ b/python/pyarrow/lib.pxd @@ -513,7 +513,6 @@ cdef class ChunkedArray(_PandasConvertible): cdef void init(self, const shared_ptr[CChunkedArray]& chunked_array) cdef getitem(self, int64_t i) - cdef void _assert_cpu(self) except * cdef class _Tabular(_PandasConvertible): diff --git a/python/pyarrow/table.pxi b/python/pyarrow/table.pxi index 6f680fe1016d4..6d34c71c9df40 100644 --- a/python/pyarrow/table.pxi +++ b/python/pyarrow/table.pxi @@ -1407,28 +1407,6 @@ cdef class ChunkedArray(_PandasConvertible): self.init(c_chunked_array) return self - @property - def device_type(self): - """ - The device type where the chunks in the ChunkedArray reside. - - Returns - ------- - DeviceAllocationType - """ - return _wrap_device_allocation_type(self.sp_chunked_array.get().device_type()) - - @property - def is_cpu(self): - """ - Whether the ChunkedArrays's chunks are CPU-accessible. - """ - return self.device_type == DeviceAllocationType.CPU - - cdef void _assert_cpu(self) except *: - if self.sp_chunked_array.get().device_type() != CDeviceAllocationType_kCPU: - raise NotImplementedError("Implemented only for data on CPU device") - def chunked_array(arrays, type=None): """