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: usizethe target batch size (and thus size for views allocation)
views: Vec<u128>The in progress views (guaranteed to be valid)
nulls: NullBufferBuilderIn progress nulls
current: Option<Vec<u8>>current buffer
completed: Vec<Buffer>completed buffers (corresponding to content of views)
buffer_source: BufferSourceAllocates 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: usizeThe size in bytes the [Buffer]s in Self::completed is taking
size_of_completed_buffers_from_current_source: usizeThe 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: u32Position in completed where last_indexed_source’s buffers begin.
Implementations§
Source§impl<B: ByteViewType> InProgressByteViewArray<B>
impl<B: ByteViewType> InProgressByteViewArray<B>
pub(crate) fn new(batch_size: usize) -> Self
Sourcefn ensure_capacity(&mut self)
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.
Sourcefn finish_current(&mut self)
fn finish_current(&mut self)
Finishes in progress buffer, if any
Sourceunsafe fn append_views_by_filter(
&mut self,
views: &[u128],
filter: &FilterPredicate,
)
unsafe fn append_views_by_filter( &mut self, views: &[u128], filter: &FilterPredicate, )
§Safety
filter.filter_len() must not exceed views.len().
fn append_nulls_by_filter( &mut self, filter: &FilterPredicate, source_nulls: Option<&NullBuffer>, )
Sourceunsafe fn append_views_and_update_buffer_index(
&mut self,
views: &[u128],
buffers: &[Buffer],
is_reused: bool,
)
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
Sourceunsafe fn append_views_and_copy_strings(
&mut self,
views: &[u128],
view_buffer_size: usize,
buffers: &[Buffer],
)
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 appendview_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.
Sourceunsafe fn append_views_and_copy_strings_inner(
&mut self,
views: &[u128],
dst_buffer: Vec<u8>,
buffers: &[Buffer],
)
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
Sourceunsafe fn append_indexed_views_and_copy_strings(
&mut self,
src_views: &[u128],
indices: &[u32],
src_buffers: &[Buffer],
selected_bytes: usize,
)
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.
Sourceunsafe 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,
)
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.
Sourceunsafe 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>,
)
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>
impl<B: ByteViewType> Debug for InProgressByteViewArray<B>
Source§impl<B: ByteViewType> InProgressArray for InProgressByteViewArray<B>
impl<B: ByteViewType> InProgressArray for InProgressByteViewArray<B>
Source§unsafe fn copy_rows_by_indices(
&mut self,
source: &ArrayRef,
indices: &UInt32Array,
) -> Result<(), ArrowError>
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
fn supports_dense_indexed_copy(&self) -> bool
Source§fn set_source(&mut self, source: Option<ArrayRef>)
fn set_source(&mut self, source: Option<ArrayRef>)
Source§fn copy_rows(&mut self, offset: usize, len: usize) -> Result<(), ArrowError>
fn copy_rows(&mut self, offset: usize, len: usize) -> Result<(), ArrowError>
Source§fn copy_rows_by_filter(
&mut self,
filter: &FilterPredicate,
) -> Result<(), ArrowError>
fn copy_rows_by_filter( &mut self, filter: &FilterPredicate, ) -> Result<(), ArrowError>
filter from the current source array. Read moreSource§fn copy_rows_by_filter_from(
&mut self,
source: ArrayRef,
filter: &FilterPredicate,
) -> Result<(), ArrowError>
fn copy_rows_by_filter_from( &mut self, source: ArrayRef, filter: &FilterPredicate, ) -> Result<(), ArrowError>
Source§fn finish(&mut self) -> Result<ArrayRef, ArrowError>
fn finish(&mut self) -> Result<ArrayRef, ArrowError>
ArrayRefSource§fn copy_rows_by_selection(
&mut self,
selection: FilterSelection<'_>,
) -> Result<(), ArrowError>
fn copy_rows_by_selection( &mut self, selection: FilterSelection<'_>, ) -> Result<(), ArrowError>
FilterSelection from the current source array. Read more