Skip to main content

InProgressByteViewArray

Struct InProgressByteViewArray 

Source
pub(crate) struct InProgressByteViewArray<B: ByteViewType> {
    source: Option<Source>,
    batch_size: usize,
    views: Vec<u128>,
    nulls: NullBufferBuilder,
    current: Option<Vec<u8>>,
    completed: Vec<Buffer>,
    buffer_source: BufferSource,
    _phantom: PhantomData<B>,
    completed_buffers_size: usize,
    size_of_completed_buffers_from_current_source: usize,
    last_indexed_source: Option<Weak<dyn Array>>,
    last_indexed_starting_buffer: u32,
}
Expand description

InProgressArray for StringViewArray and BinaryViewArray

This structure buffers the views and data buffers as they are copied from the source array, and then produces a new array when finish is called. It also handles “garbage collection” by copying strings to a new buffer when the source buffer is sparse (i.e. uses at least 2x more than the memory it needs).

Fields§

§source: Option<Source>

The source array and information

§batch_size: usize

the target batch size (and thus size for views allocation)

§views: Vec<u128>

The in progress views (guaranteed to be valid)

§nulls: NullBufferBuilder

In progress nulls

§current: Option<Vec<u8>>

current buffer

§completed: Vec<Buffer>

completed buffers (corresponding to content of views)

§buffer_source: BufferSource

Allocates new buffers of increasing size as needed

§_phantom: PhantomData<B>

Phantom so we can use the same struct for both StringViewArray and BinaryViewArray

§completed_buffers_size: usize

The size in bytes the [Buffer]s in Self::completed is taking

§size_of_completed_buffers_from_current_source: usize

The size in bytes from Self::source that it is being used in Self::completed

§last_indexed_source: Option<Weak<dyn Array>>

Weak identity of the last indexed source. Repeated indexed copies from this source reuse the data-buffer references already in completed. Keeping only a weak reference avoids retaining its views and null bitmap.

§last_indexed_starting_buffer: u32

Position in completed where last_indexed_source’s buffers begin.

Implementations§

Source§

impl<B: ByteViewType> InProgressByteViewArray<B>

Source

pub(crate) fn new(batch_size: usize) -> Self

Source

fn ensure_capacity(&mut self)

Allocate space for output views and nulls if needed

This is done on write (when we know it is necessary) rather than eagerly to avoid allocations that are not used.

Source

fn finish_current(&mut self)

Finishes in progress buffer, if any

Source

unsafe fn append_views_by_filter( &mut self, views: &[u128], filter: &FilterPredicate, )

§Safety

filter.filter_len() must not exceed views.len().

Source

fn append_nulls_by_filter( &mut self, filter: &FilterPredicate, source_nulls: Option<&NullBuffer>, )

Source

unsafe fn append_views_and_update_buffer_index( &mut self, views: &[u128], buffers: &[Buffer], is_reused: bool, )

Append views to self.views, updating the buffer index if necessary

§Safety

B::validate must succeed for views and buffers.

Note: this function performs no unsafe operations itself, but it assumes views are valid views for self.views and buffers for self.buffers

Source

unsafe fn append_views_and_copy_strings( &mut self, views: &[u128], view_buffer_size: usize, buffers: &[Buffer], )

Append views to self.views, copying data from the buffers into self.buffers and updating the buffer index as necessary.

§Arguments
  • views - the views to append
  • view_buffer_size - the total number of bytes pointed to by all views (used to allocate new buffers if needed)
  • buffers - the buffers the views point to
§Safety

B::validate must succeed for views and buffers.

Source

unsafe fn append_views_and_copy_strings_inner( &mut self, views: &[u128], dst_buffer: Vec<u8>, buffers: &[Buffer], )

Append views to self.views, copying data from the buffers into dst_buffer, which is then set as self.current

§Panics:

If self.current is Some

§Safety

B::validate must succeed for views and buffers.

See append_views_and_copy_strings for more details

Source

unsafe fn append_indexed_views_and_copy_strings( &mut self, src_views: &[u128], indices: &[u32], src_buffers: &[Buffer], selected_bytes: usize, )

§Safety

Every value in indices must be less than src_views.len(), and every selected non-inline view must reference a valid range in src_buffers. selected_bytes must equal the total length of the selected non-inline values, and every selected value must fit within i32::MAX bytes.

Source

unsafe fn append_indexed_views_and_copy_strings_with_max_buffer_size( &mut self, src_views: &[u128], indices: &[u32], src_buffers: &[Buffer], selected_bytes: usize, max_buffer_size: usize, )

Copies indexed views, capping max_buffer_size at i32::MAX.

§Safety

Every value in indices must be less than src_views.len(), and every selected non-inline view must reference a valid range in src_buffers. selected_bytes must equal the total length of the selected non-inline values, and every selected value must fit within max_buffer_size.

Source

unsafe fn append_indexed_views_and_copy_strings_split( &mut self, src_views: &[u128], indices: &[u32], src_buffers: &[Buffer], selected_bytes: usize, max_buffer_size: usize, dst_buffer: Vec<u8>, )

Copies indexed views into bounded output buffers.

§Safety

Every value in indices must be less than src_views.len(), every selected non-inline view must reference a valid range in src_buffers, every selected value must fit within max_buffer_size, max_buffer_size must be at most i32::MAX, and selected_bytes must equal their total length.

Trait Implementations§

Source§

impl<B: ByteViewType> Debug for InProgressByteViewArray<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B: ByteViewType> InProgressArray for InProgressByteViewArray<B>

Source§

unsafe fn copy_rows_by_indices( &mut self, source: &ArrayRef, indices: &UInt32Array, ) -> Result<(), ArrowError>

§Safety

indices must not contain nulls, and every value must be less than source.len().

Source§

fn supports_dense_indexed_copy(&self) -> bool

Returns true if this implementation supports dense indexed copying.
Source§

fn set_source(&mut self, source: Option<ArrayRef>)

Set the source array. Read more
Source§

fn copy_rows(&mut self, offset: usize, len: usize) -> Result<(), ArrowError>

Copy rows from the current source array into the in-progress array Read more
Source§

fn copy_rows_by_filter( &mut self, filter: &FilterPredicate, ) -> Result<(), ArrowError>

Copy rows selected by filter from the current source array. Read more
Source§

fn copy_rows_by_filter_from( &mut self, source: ArrayRef, filter: &FilterPredicate, ) -> Result<(), ArrowError>

Copy rows selected by a FilterPredicate from source. Read more
Source§

fn finish(&mut self) -> Result<ArrayRef, ArrowError>

Finish the currently in-progress array and return it as an ArrayRef
Source§

fn size(&self) -> usize

Get the number of bytes this array is using
Source§

fn copy_rows_by_selection( &mut self, selection: FilterSelection<'_>, ) -> Result<(), ArrowError>

Copy rows described by a FilterSelection from the current source array. Read more

Auto Trait Implementations§

§

impl<B> !Freeze for InProgressByteViewArray<B>

§

impl<B> !RefUnwindSafe for InProgressByteViewArray<B>

§

impl<B> !UnwindSafe for InProgressByteViewArray<B>

§

impl<B> Forget for InProgressByteViewArray<B>

§

impl<B> Move for InProgressByteViewArray<B>

§

impl<B> Send for InProgressByteViewArray<B>
where Arc<dyn Array>: Send, RawVecInner: Send, MutableBuffer: Send, Buffer: Send, Weak<dyn Array>: Send,

§

impl<B> Sync for InProgressByteViewArray<B>
where Arc<dyn Array>: Sync, RawVecInner: Sync, MutableBuffer: Sync, Buffer: Sync, Weak<dyn Array>: Sync,

§

impl<B> Unpin for InProgressByteViewArray<B>
where B: Unpin, Arc<dyn Array>: Unpin, *const u8 is !null: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, Box<dyn MemoryReservation>: Unpin, Arc<Bytes>: Unpin, *const u8: Unpin, *const ArcInner<dyn Array> is !null: Unpin,

§

impl<B> UnsafeUnpin for InProgressByteViewArray<B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.