Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-39159 [C++]: Try to make Buffer::device_type_ non-optional #39150

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions cpp/src/arrow/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ class ARROW_EXPORT Buffer {

Buffer(const uint8_t* data, int64_t size, std::shared_ptr<MemoryManager> mm,
std::shared_ptr<Buffer> parent = NULLPTR,
std::optional<DeviceAllocationType> device_type = std::nullopt)
std::optional<DeviceAllocationType> device_type_override = std::nullopt)
: is_mutable_(false),
data_(data),
size_(size),
capacity_(size),
parent_(std::move(parent)) {
// SetMemoryManager will also set device_type_
SetMemoryManager(std::move(mm));
// if a device type is specified, use that instead. for example:
// CUDA_HOST. The CudaMemoryManager will set device_type_ to CUDA,
// but you can specify CUDA_HOST as the device type to override it.
if (device_type != std::nullopt) {
device_type_ = device_type;
// If a device type is specified, use that instead. Example of when this can be
// useful: the CudaMemoryManager can set device_type_ to kCUDA, but you can specify
// device_type_override=kCUDA_HOST as the device type to override it.
if (device_type_override != std::nullopt) {
device_type_ = *device_type_override;
}
}

Expand Down Expand Up @@ -296,7 +296,7 @@ class ARROW_EXPORT Buffer {

const std::shared_ptr<MemoryManager>& memory_manager() const { return memory_manager_; }

std::optional<DeviceAllocationType> device_type() const { return device_type_; }
DeviceAllocationType device_type() const { return device_type_; }

std::shared_ptr<Buffer> parent() const { return parent_; }

Expand Down Expand Up @@ -354,7 +354,7 @@ class ARROW_EXPORT Buffer {
const uint8_t* data_;
int64_t size_;
int64_t capacity_;
std::optional<DeviceAllocationType> device_type_;
DeviceAllocationType device_type_;

// null by default, but may be set
std::shared_ptr<Buffer> parent_;
Expand Down
Loading