| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/../../cpp/../python/../cpp/api/memory.html#slicing | [Back] [Original] |
EXPERIMENTAL: Abstract interface for hardware devices.
This object represents a device with access to some memory spaces. When handling a Buffer or raw memory address, it allows deciding in which context the raw memory address should be interpreted (e.g. CPU-accessible memory, or embedded memory on some particular GPU).
Subclassed by arrow::CPUDevice, arrow::cuda::CudaDevice
Public Functions
A shorthand for this devices type.
The returned value is different for each device class, but is the same for all instances of a given class. It can be used as a replacement for RTTI.
A human-readable description of the device.
The returned value should be detailed enough to distinguish between different instances, where necessary.
Whether this instance points to the same device as another one.
A device ID to identify this device if there are multiple of this type.
If there is no device_id equivalent (such as for the main CPU device on non-numa systems) returns -1.
Whether this device is the main CPU device.
This shorthand method is very useful when deciding whether a memory address is CPU-accessible.
Return a MemoryManager instance tied to this device.
The returned instance uses default parameters for this device types MemoryManager implementation. Some devices also allow constructing MemoryManager instances with non-default parameters.
Return the DeviceAllocationType of this device.
Create a new device stream.
This should create the appropriate stream type for the device, derived from Device::Stream to allow for stream ordered events and memory allocations.
Wrap an existing device stream alongside a release function.
device_stream a pointer to the stream to wrap
release_fn a function to call during destruction, nullptr or a no-op function can be passed to indicate ownership is maintained externally
EXPERIMENTAL: An opaque wrapper for Device-specific streams.
In essence this is just a wrapper around a void* to represent the standard concept of a stream/queue on a device. Derived classes should be trivially constructible from its device-specific counterparts.
Subclassed by arrow::cuda::CudaDevice::Stream
EXPERIMENTAL: An object that provides event/stream sync primitives.
Subclassed by arrow::cuda::CudaDevice::SyncEvent
Public Functions
A shorthand for this devices type.
The returned value is different for each device class, but is the same for all instances of a given class. It can be used as a replacement for RTTI.
A human-readable description of the device.
The returned value should be detailed enough to distinguish between different instances, where necessary.
Whether this instance points to the same device as another one.
Return the DeviceAllocationType of this device.
Return a MemoryManager instance tied to this device.
The returned instance uses default parameters for this device types MemoryManager implementation. Some devices also allow constructing MemoryManager instances with non-default parameters.
Public Static Functions
Create a MemoryManager.
The returned MemoryManager will use the given MemoryPool for allocations.
Return the default CPU MemoryManager instance.
The returned singleton instance uses the default MemoryPool. This function is a faster spelling of CPUDevice::Instance()->default_memory_manager().
EXPERIMENTAL: An object that provides memory management primitives.
A MemoryManager is always tied to a particular Device instance. It can also have additional parameters (such as a MemoryPool to allocate CPU memory).
Subclassed by arrow::CPUMemoryManager, arrow::cuda::CudaMemoryManager
Public Functions
The device this MemoryManager is tied to.
Whether this MemoryManager is tied to the main CPU device.
This shorthand method is very useful when deciding whether a memory address is CPU-accessible.
Create a RandomAccessFile to read a particular buffer.
The given buffer must be tied to this MemoryManager.
See also the Buffer::GetReader shorthand.
Create a OutputStream to write to a particular buffer.
The given buffer must be mutable and tied to this MemoryManager. The returned stream object writes into the buffers underlying memory (but it wont resize it).
See also the Buffer::GetWriter shorthand.
Allocate a (mutable) Buffer.
The buffer will be allocated in the devices memory.
Create a new SyncEvent.
This version should construct the appropriate event for the device and provide the unique_ptr with the correct deleter for the event type. If the device does not require or work with any synchronization, it is allowed for it to return a nullptr.
Wrap an event into a SyncEvent.
sync_event passed in sync_event (should be a pointer to the appropriate type)
release_sync_event destructor to free sync_event. nullptr may be passed to indicate that no destruction/freeing is necessary
Public Static Functions
Copy a Buffer to a destination MemoryManager.
See also the Buffer::Copy shorthand.
Copy a non-owned Buffer to a destination MemoryManager.
This is useful for cases where the source memory area is externally managed (its lifetime not tied to the source Buffer), otherwise please use CopyBuffer().
Make a no-copy Buffer view in a destination MemoryManager.
See also the Buffer::View shorthand.
Copy a slice of a buffer into a CPU pointer.
Public Functions
Create a RandomAccessFile to read a particular buffer.
The given buffer must be tied to this MemoryManager.
See also the Buffer::GetReader shorthand.
Create a OutputStream to write to a particular buffer.
The given buffer must be mutable and tied to this MemoryManager. The returned stream object writes into the buffers underlying memory (but it wont resize it).
See also the Buffer::GetWriter shorthand.
Allocate a (mutable) Buffer.
The buffer will be allocated in the devices memory.
Return the MemoryPool associated with this MemoryManager.
Object containing a pointer to a piece of contiguous memory with a particular size.
Buffers have two related notions of length: size and capacity. Size is the number of bytes that might have valid data. Capacity is the number of bytes that were allocated for the buffer in total.
The Buffer base class does not own its memory, but subclasses often do.
The following invariant is always true: Size <= Capacity
Subclassed by arrow::MutableBuffer, arrow::cuda::CudaBuffer
Public Functions
Construct from buffer and size without copying memory.
Note
The passed memory must be kept alive through some other means
data [in] a memory buffer
size [in] buffer size
Construct from string_view without copying memory.
Note
The memory viewed by data must not be deallocated in the lifetime of the Buffer; temporary rvalue strings must be stored in an lvalue somewhere
data [in] a string_view object
An offset into data that is owned by another buffer, but we want to be able to retain a valid pointer to it even after other shared_ptrs to the parent buffer have been destroyed.
This method makes no assertions about alignment or padding of the buffer but in general we expected buffers to be aligned and padded to 64 bytes. In the future we might add utility methods to help determine if a buffer satisfies this contract.
Construct a new std::string with a hexadecimal representation of the buffer.
std::string
Return true if both buffers are the same size and contain the same bytes up to the number of compared bytes.
Return true if both buffers are the same size and contain the same bytes.
Copy a section of the buffer into a new Buffer.
Zero bytes in padding, i.e. bytes between size_ and capacity_.
Copy buffer contents into a new std::string.
Note
Can throw std::bad_alloc if buffer is large
std::string
View buffer contents as a std::string_view.
std::string_view
Return a pointer to the buffers data.
The buffer has to be a CPU buffer (is_cpu() is true). Otherwise, an assertion may be thrown or a null pointer may be returned.
To get the buffers data address regardless of its device, call address().
Return a pointer to the buffers data cast to a specific type.
The buffer has to be a CPU buffer (is_cpu() is true). Otherwise, an assertion may be thrown or a null pointer may be returned.
Return a writable pointer to the buffers data.
The buffer has to be a mutable CPU buffer (is_cpu() and is_mutable() are true). Otherwise, an assertion may be thrown or a null pointer may be returned.
To get the buffers mutable data address regardless of its device, call mutable_address().
Return a writable pointer to the buffers data cast to a specific type.
The buffer has to be a mutable CPU buffer (is_cpu() and is_mutable() are true). Otherwise, an assertion may be thrown or a null pointer may be returned.
Return the buffers mutable data as a span.
Return the device address of the buffers data.
Return a writable device address to the buffers data.
The buffer has to be a mutable buffer (is_mutable() is true). Otherwise, an assertion may be thrown or 0 may be returned.
Return the buffers size in bytes.
Return the buffers capacity (number of allocated bytes)
Whether the buffer is directly CPU-accessible.
If this function returns true, you can read directly from the buffers data() pointer. Otherwise, youll have to View() or Copy() it.
Whether the buffer is mutable.
If this function returns true, you are allowed to modify buffer contents using the pointer returned by mutable_data() or mutable_address().
Public Static Functions
Construct an immutable buffer that takes ownership of the contents of an std::string (without copying it).
data [in] a string to own
a new Buffer instance
Construct an immutable buffer that takes ownership of the contents of an std::vector (without copying it).
Only vectors of TrivialType objects (integers, floating point numbers, ) can be wrapped by this function.
vec [in] a vector to own
a new Buffer instance
Create buffer referencing typed memory with some length without copying.
data [in] the typed memory as C array
length [in] the number of values in the array
a new shared_ptr<Buffer>
Create buffer referencing std::vector with some length without copying.
data [in] the vector to be referenced. If this vector is changed, the buffer may become invalid
a new shared_ptr<Buffer>
Get a RandomAccessFile for reading a buffer.
The returned file object reads from this buffers underlying memory.
Get a OutputStream for writing to a buffer.
The buffer must be mutable. The returned stream object writes into the buffers underlying memory (but it wont resize it).
Copy buffer.
The buffer contents will be copied into a new buffer allocated by the given MemoryManager. This function supports cross-device copies.
Copy a non-owned buffer.
This is useful for cases where the source memory area is externally managed (its lifetime not tied to the source Buffer), otherwise please use Copy().
View buffer.
Return a Buffer that reflects this buffer, seen potentially from another device, without making an explicit copy of the contents. The underlying mechanism is typically implemented by the kernel or device driver, and may involve lazy caching of parts of the buffer contents on the destination devices memory.
If a non-copy view is unsupported for the buffer on the given device, nullptr is returned. An error can be returned if some low-level operation fails (such as an out-of-memory condition).
View or copy buffer.
Try to view buffer contents on the given MemoryManagers device, but fall back to copying if a no-copy view isnt supported.
A Buffer whose contents can be mutated.
May or may not own its data.
Subclassed by arrow::ResizableBuffer, arrow::cuda::CudaHostBuffer
Public Static Functions
Create buffer referencing typed memory with some length.
data [in] the typed memory as C array
length [in] the number of values in the array
a new shared_ptr<Buffer>
A mutable buffer that can be resized.
Public Functions
Change buffer reported size to indicated size, allocating memory if necessary.
This will ensure that the capacity of the buffer is a multiple of 64 bytes as defined in Layout.md. Consider using ZeroPadding afterwards, to conform to the Arrow layout specification.
new_size The new size for the buffer.
shrink_to_fit Whether to shrink the capacity if new size < current size
Warning
This class is exposed solely as a building block for arrow::ArraySpan.
For any other purpose, please use arrow::Buffer.
Return the process-wide default memory pool.
Return a process-wide memory pool based on jemalloc.
May return NotImplemented if jemalloc is not available.
Return a process-wide memory pool based on mimalloc.
May return NotImplemented if mimalloc is not available.
Return a process-wide memory pool based on the system allocator.
Base class for memory allocation on the CPU.
Besides tracking the number of allocated bytes, the allocator also should take care of the required 64-byte alignment.
Subclassed by arrow::CappedMemoryPool, arrow::LoggingMemoryPool, arrow::ProxyMemoryPool, arrow::stl::STLMemoryPool< Allocator >
Public Functions
Allocate a new memory region of at least size bytes.
The allocated region shall be 64-byte aligned.
Allocate a new memory region of at least size bytes aligned to alignment.
Resize an already allocated memory section.
As by default most default allocators on a platform dont support aligned reallocation, this function can involve a copy of the underlying data.
Free an allocated region.
buffer Pointer to the start of the allocated memory region
size Allocated size located at buffer. An allocator implementation may use this for tracking the amount of allocated bytes as well as for faster deallocation if supported by its backend.
alignment The alignment of the allocation. Defaults to 64 bytes.
Return unused memory to the OS.
Only applies to allocators that hold onto unused memory. This will be best effort, a memory pool may not implement this feature or may be unable to fulfill the request due to fragmentation.
Print statistics.
Print allocation statistics on stderr. The output format is implementation-specific. Not all memory pools implement this method.
The number of bytes that were allocated and not yet freed through this allocator.
Return peak memory allocation in this memory pool.
Maximum bytes allocated. If not known (or not implemented), returns -1
The number of bytes that were allocated.
The number of allocations or reallocations that were requested.
The name of the backend used by this MemoryPool (e.g. system or jemalloc).
Public Static Functions
EXPERIMENTAL. Create a new instance of the default MemoryPool.
Public Functions
Allocate a new memory region of at least size bytes aligned to alignment.
Resize an already allocated memory section.
As by default most default allocators on a platform dont support aligned reallocation, this function can involve a copy of the underlying data.
Free an allocated region.
buffer Pointer to the start of the allocated memory region
size Allocated size located at buffer. An allocator implementation may use this for tracking the amount of allocated bytes as well as for faster deallocation if supported by its backend.
alignment The alignment of the allocation. Defaults to 64 bytes.
Return unused memory to the OS.
Only applies to allocators that hold onto unused memory. This will be best effort, a memory pool may not implement this feature or may be unable to fulfill the request due to fragmentation.
Print statistics.
Print allocation statistics on stderr. The output format is implementation-specific. Not all memory pools implement this method.
The number of bytes that were allocated and not yet freed through this allocator.
Return peak memory allocation in this memory pool.
Maximum bytes allocated. If not known (or not implemented), returns -1
The number of bytes that were allocated.
The number of allocations or reallocations that were requested.
The name of the backend used by this MemoryPool (e.g. system or jemalloc).
Allocate a new memory region of at least size bytes.
The allocated region shall be 64-byte aligned.
Allocate a new memory region of at least size bytes aligned to alignment.
Free an allocated region.
buffer Pointer to the start of the allocated memory region
size Allocated size located at buffer. An allocator implementation may use this for tracking the amount of allocated bytes as well as for faster deallocation if supported by its backend.
alignment The alignment of the allocation. Defaults to 64 bytes.
Resize an already allocated memory section.
As by default most default allocators on a platform dont support aligned reallocation, this function can involve a copy of the underlying data.
Derived class for memory allocation.
Tracks the number of bytes and maximum memory allocated through its direct calls. Actual allocation is delegated to MemoryPool class.
Public Functions
Allocate a new memory region of at least size bytes aligned to alignment.
Resize an already allocated memory section.
As by default most default allocators on a platform dont support aligned reallocation, this function can involve a copy of the underlying data.
Free an allocated region.
buffer Pointer to the start of the allocated memory region
size Allocated size located at buffer. An allocator implementation may use this for tracking the amount of allocated bytes as well as for faster deallocation if supported by its backend.
alignment The alignment of the allocation. Defaults to 64 bytes.
Return unused memory to the OS.
Only applies to allocators that hold onto unused memory. This will be best effort, a memory pool may not implement this feature or may be unable to fulfill the request due to fragmentation.
Print statistics.
Print allocation statistics on stderr. The output format is implementation-specific. Not all memory pools implement this method.
The number of bytes that were allocated and not yet freed through this allocator.
Return peak memory allocation in this memory pool.
Maximum bytes allocated. If not known (or not implemented), returns -1
The number of bytes that were allocated.
The number of allocations or reallocations that were requested.
The name of the backend used by this MemoryPool (e.g. system or jemalloc).
Allocate a new memory region of at least size bytes.
The allocated region shall be 64-byte aligned.
Allocate a new memory region of at least size bytes aligned to alignment.
Free an allocated region.
buffer Pointer to the start of the allocated memory region
size Allocated size located at buffer. An allocator implementation may use this for tracking the amount of allocated bytes as well as for faster deallocation if supported by its backend.
alignment The alignment of the allocation. Defaults to 64 bytes.
Resize an already allocated memory section.
As by default most default allocators on a platform dont support aligned reallocation, this function can involve a copy of the underlying data.
Return the names of the backends supported by this Arrow build.
These functions allocate a buffer from a particular memory pool.
Allocate a fixed size mutable buffer from a memory pool, zero its padding.
size [in] size of buffer to allocate
pool [in] a memory pool
Allocate a resizeable buffer from a memory pool, zero its padding.
size [in] size of buffer to allocate
pool [in] a memory pool
Allocate a bitmap buffer from a memory pool no guarantee on values is provided.
length [in] size in bits of bitmap to allocate
pool [in] memory pool to allocate memory from
Allocate a zero-initialized bitmap buffer from a memory pool.
length [in] size in bits of bitmap to allocate
pool [in] memory pool to allocate memory from
Concatenate multiple buffers into a single buffer.
buffers [in] to be concatenated
pool [in] memory pool to allocate the new buffer from
Construct a view on a buffer at the given offset and length.
This function cannot fail and does not check for errors (except in debug builds)
Construct a view on a buffer at the given offset, up to the buffers end.
This function cannot fail and does not check for errors (except in debug builds)
Input-checking version of SliceBuffer.
An Invalid Status is returned if the requested slice falls out of bounds.
Input-checking version of SliceBuffer.
An Invalid Status is returned if the requested slice falls out of bounds. Note that unlike SliceBuffer, length isnt clamped to the available buffer size.
Like SliceBuffer, but construct a mutable buffer slice.
If the parent buffer is not mutable, behavior is undefined (it may abort in debug builds).
Like SliceBuffer, but construct a mutable buffer slice.
If the parent buffer is not mutable, behavior is undefined (it may abort in debug builds).
Input-checking version of SliceMutableBuffer.
An Invalid Status is returned if the requested slice falls out of bounds.
Input-checking version of SliceMutableBuffer.
An Invalid Status is returned if the requested slice falls out of bounds. Note that unlike SliceBuffer, length isnt clamped to the available buffer size.
A class for incrementally building a contiguous chunk of in-memory data.
Public Functions
Constructs new Builder that will start using the provided buffer until Finish/Reset are called.
The buffer is not resized.
Resize the buffer to the nearest multiple of 64 bytes.
new_capacity the new capacity of the builder. Will be rounded up to a multiple of 64 bytes for padding
shrink_to_fit if new capacity is smaller than the existing, reallocate internal buffer. Set to false to avoid reallocations when shrinking the builder.
Ensure that builder can accommodate the additional number of bytes without the need to perform allocations.
additional_bytes [in] number of additional bytes to make space for
Append the given data to the buffer.
The buffer is automatically expanded if necessary.
Append the given data to the buffer.
The buffer is automatically expanded if necessary.
Append copies of a value to the buffer.
The buffer is automatically expanded if necessary.
Return result of builder as a Buffer object.
The builder is reset and can be reused afterwards.
Like Finish, but override the final buffer size.
This is useful after writing data directly into the builder memory without calling the Append methods (basically, when using BufferBuilder mostly for memory allocation).
Set size to a smaller value without modifying builder contents.
For reusable BufferBuilder classes
position [in] must be non-negative and less than or equal to the current length()
Public Static Functions
Return a capacity expanded by the desired growth factor.
A STL allocator delegating allocations to a Arrow MemoryPool.
Public Functions
Construct an allocator from the default MemoryPool.
Construct an allocator from the given MemoryPool.
A MemoryPool implementation delegating allocations to a STL allocator.
Note that STL allocators dont provide a resizing operation, and therefore any buffer resizes will do a full reallocation and copy.
Public Functions
Construct a memory pool from the given allocator.
Allocate a new memory region of at least size bytes aligned to alignment.
Resize an already allocated memory section.
As by default most default allocators on a platform dont support aligned reallocation, this function can involve a copy of the underlying data.
Free an allocated region.
buffer Pointer to the start of the allocated memory region
size Allocated size located at buffer. An allocator implementation may use this for tracking the amount of allocated bytes as well as for faster deallocation if supported by its backend.
alignment The alignment of the allocation. Defaults to 64 bytes.
The number of bytes that were allocated and not yet freed through this allocator.
Return peak memory allocation in this memory pool.
Maximum bytes allocated. If not known (or not implemented), returns -1
The number of bytes that were allocated.
The number of allocations or reallocations that were requested.
The name of the backend used by this MemoryPool (e.g. system or jemalloc).
Allocate a new memory region of at least size bytes.
The allocated region shall be 64-byte aligned.
Allocate a new memory region of at least size bytes aligned to alignment.
Free an allocated region.
buffer Pointer to the start of the allocated memory region
size Allocated size located at buffer. An allocator implementation may use this for tracking the amount of allocated bytes as well as for faster deallocation if supported by its backend.
alignment The alignment of the allocation. Defaults to 64 bytes.
Resize an already allocated memory section.
As by default most default allocators on a platform dont support aligned reallocation, this function can involve a copy of the underlying data.
| Web Proxy Viewer | New URL | Original Page |