tustvold commented on code in PR #6966:
URL: https://github.com/apache/arrow-rs/pull/6966#discussion_r1911956371
##########
arrow-data/src/data.rs:
##########
@@ -1930,17 +1967,32 @@ impl ArrayDataBuilder {
/// to allow for [slice](std::slice) based APIs. See
[`BufferSpec::FixedWidth`].
///
/// As this alignment is architecture specific, and not guaranteed by all
arrow implementations,
- /// this method is provided to automatically copy buffers to a new
correctly aligned allocation
+ /// this flag is provided to automatically copy buffers to a new correctly
aligned allocation
/// when necessary, making it useful when interacting with buffers
produced by other systems,
/// e.g. IPC or FFI.
///
- /// This is unlike `[Self::build`] which will instead return an error on
encountering
+ /// If this flag is not enabled, `[Self::build`] return an error on
encountering
/// insufficiently aligned buffers.
- pub fn build_aligned(self) -> Result<ArrayData, ArrowError> {
- let mut data = unsafe { self.build_impl() };
- data.align_buffers();
- data.validate_data()?;
- Ok(data)
+ pub fn with_align_buffers(mut self, align_buffers: bool) -> Self {
+ self.align_buffers = align_buffers;
+ self
+ }
+
+ /// Skips validation of the data.
+ ///
+ /// If this flag is enabled, `[Self::build`] will skip validation of the
+ /// data
+ ///
+ /// If this flag is not enabled, `[Self::build`] will validate that all
+ /// buffers are valid and will return an error if any data is invalid.
+ /// Validation can be expensive.
+ ///
+ /// # Safety
+ /// If validation is skipped, the buffers must form a valid Array array,
+ /// otherwise undefined behavior will result
+ pub unsafe fn with_skip_validation(mut self, skip_validation: bool) ->
Self {
Review Comment:
```suggestion
pub unsafe fn skip_validation(mut self, skip_validation: bool) -> Self {
```
For consistency with the other APIs on this builder
##########
arrow-data/src/data.rs:
##########
@@ -1930,17 +1967,32 @@ impl ArrayDataBuilder {
/// to allow for [slice](std::slice) based APIs. See
[`BufferSpec::FixedWidth`].
///
/// As this alignment is architecture specific, and not guaranteed by all
arrow implementations,
- /// this method is provided to automatically copy buffers to a new
correctly aligned allocation
+ /// this flag is provided to automatically copy buffers to a new correctly
aligned allocation
/// when necessary, making it useful when interacting with buffers
produced by other systems,
/// e.g. IPC or FFI.
///
- /// This is unlike `[Self::build`] which will instead return an error on
encountering
+ /// If this flag is not enabled, `[Self::build`] return an error on
encountering
/// insufficiently aligned buffers.
- pub fn build_aligned(self) -> Result<ArrayData, ArrowError> {
- let mut data = unsafe { self.build_impl() };
- data.align_buffers();
- data.validate_data()?;
- Ok(data)
+ pub fn with_align_buffers(mut self, align_buffers: bool) -> Self {
Review Comment:
```suggestion
pub fn align_buffers(mut self, align_buffers: bool) -> Self {
```
For consistency with the other APIs on this builder
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]