Skip to content

Commit

Permalink
mod: separate unsafe and safe APIs for unvalidated array ops
Browse files Browse the repository at this point in the history
  • Loading branch information
totoroyyb committed Jan 5, 2025
1 parent d8fb46e commit d2a5087
Show file tree
Hide file tree
Showing 3 changed files with 592 additions and 298 deletions.
15 changes: 15 additions & 0 deletions arrow-data/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,21 @@ impl ArrayDataBuilder {
data
}

/// Creates an array data, without any validation,
/// but aligning buffers.
///
/// # Safety
///
/// The same caveats as [`ArrayData::new_unchecked`] apply.
pub unsafe fn build_aligned_unchecked(self) -> ArrayData {
let mut data = self.build_impl();
data.align_buffers();
// Provide a force_validate mode
#[cfg(feature = "force_validate")]
data.validate_data().unwrap();
data
}

/// Same as [`Self::build_unchecked`] but ignoring `force_validate` feature flag
unsafe fn build_impl(self) -> ArrayData {
let nulls = self
Expand Down
Loading

0 comments on commit d2a5087

Please sign in to comment.