Skip to content

Commit

Permalink
Revert "apacheGH-43728:[Python] ChunkedArray fails gracefully on non-…
Browse files Browse the repository at this point in the history
…cpu devices"

This reverts commit 1fcdb1f.
  • Loading branch information
danepitkin committed Aug 23, 2024
1 parent 6867577 commit 8f695f7
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 48 deletions.
12 changes: 0 additions & 12 deletions cpp/src/arrow/chunked_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,16 @@ ChunkedArray::ChunkedArray(ArrayVector chunks, std::shared_ptr<DataType> 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)
<< "cannot construct ChunkedArray from empty vector and omitted 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());
}
}

Expand Down Expand Up @@ -99,9 +93,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;
Expand Down Expand Up @@ -157,9 +148,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;
Expand Down
11 changes: 0 additions & 11 deletions cpp/src/arrow/chunked_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include "arrow/chunk_resolver.h"
#include "arrow/compare.h"
#include "arrow/device.h"
#include "arrow/result.h"
#include "arrow/status.h"
#include "arrow/type_fwd.h"
Expand Down Expand Up @@ -183,21 +182,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<DataType> type_;
int64_t length_;
int64_t null_count_;
DeviceAllocationType device_type_;

private:
template <typename T, typename V>
Expand Down
2 changes: 0 additions & 2 deletions python/pyarrow/includes/libarrow.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion python/pyarrow/lib.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,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):
Expand Down
22 changes: 0 additions & 22 deletions python/pyarrow/table.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 8f695f7

Please sign in to comment.