Struct arrow::buffer::Buffer[][src]

pub struct Buffer { /* fields omitted */ }
Expand description

Buffer represents a contiguous memory region that can be shared with other buffers and across thread boundaries.

Implementations

Auxiliary method to create a new Buffer

Initializes a Buffer from a slice of items.

Creates a buffer from an existing memory region (must already be byte-aligned), this Buffer will free this piece of memory when dropped.

Arguments

  • ptr - Pointer to raw parts
  • len - Length of raw parts in bytes
  • capacity - Total allocated memory for the pointer ptr, in bytes

Safety

This function is unsafe as there is no guarantee that the given pointer is valid for len bytes. If the ptr and capacity come from a Buffer, then this is guaranteed.

Creates a buffer from an existing memory region (must already be byte-aligned), this Buffer does not free this piece of memory when dropped.

Arguments

  • ptr - Pointer to raw parts
  • len - Length of raw parts in bytes
  • data - An ffi::FFI_ArrowArray with the data

Safety

This function is unsafe as there is no guarantee that the given pointer is valid for len bytes and that the foreign deallocator frees the region.

Returns the number of bytes in the buffer

Returns the capacity of this buffer. For exernally owned buffers, this returns zero

Returns whether the buffer is empty.

Returns the byte slice stored in this buffer

Returns a new Buffer that is a slice of this buffer starting at offset. Doing so allows the same memory region to be shared between buffers.

Panics

Panics iff offset is larger than len.

Returns a pointer to the start of this buffer.

Note that this should be used cautiously, and the returned pointer should not be stored anywhere, to avoid dangling pointers.

View buffer as typed slice.

Safety

ArrowNativeType is public so that it can be used as a trait bound for other public components, such as the ToByteSlice trait. However, this means that it can be implemented by user defined types, which it is not intended for.

Also typed_data::<bool> is unsafe as 0x00 and 0x01 are the only valid values for bool in Rust. However, bool arrays in Arrow are bit-packed which breaks this condition. View buffer as typed slice.

Returns a slice of this buffer starting at a certain bit offset. If the offset is byte-aligned the returned buffer is a shallow clone, otherwise a new buffer is allocated and filled with a copy of the bits in the range.

Returns a BitChunks instance which can be used to iterate over this buffers bits in larger chunks and starting at arbitrary bit offsets. Note that both offset and length are measured in bits.

Returns the number of 1-bits in this buffer.

Returns the number of 1-bits in this buffer, starting from offset with length bits inspected. Note that both offset and length are measured in bits.

Creates a Buffer from an Iterator with a trusted (upper) length. Prefer this to collect whenever possible, as it is ~60% faster.

Example

let v = vec![1u32];
let iter = v.iter().map(|x| x * 2);
let buffer = unsafe { Buffer::from_trusted_len_iter(iter) };
assert_eq!(buffer.len(), 4) // u32 has 4 bytes

Safety

This method assumes that the iterator’s size is correct and is undefined behavior to use it on an iterator that reports an incorrect length.

Creates a Buffer from an Iterator with a trusted (upper) length or errors if any of the items of the iterator is an error. Prefer this to collect whenever possible, as it is ~60% faster.

Safety

This method assumes that the iterator’s size is correct and is undefined behavior to use it on an iterator that reports an incorrect length.

Trait Implementations

The resulting type after applying the & operator.

Performs the & operation. Read more

The resulting type after applying the | operator.

Performs the | operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Creating a Buffer instance by copying the memory from a AsRef<[u8]> into a newly allocated memory region.

Performs the conversion.

Creates a value from an iterator. Read more

Creating a Buffer instance by storing the boolean values into the buffer

Creates a value from an iterator. Read more

The resulting type after applying the ! operator.

Performs the unary ! operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.