Skip to content

Commit

Permalink
chore: cargo doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikkon committed Mar 31, 2024
1 parent a3e53db commit 095a678
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 32 deletions.
18 changes: 10 additions & 8 deletions arrow-array/src/builder/generic_list_view_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,13 +597,13 @@ mod tests {
.as_any_mut()
.downcast_mut::<GenericListViewBuilder<O, Box<dyn ArrayBuilder>>>()
.expect("should be an (Large)ListViewBuilder")
.append(true,3);
.append(true, 3);
builder
.values()
.as_any_mut()
.downcast_mut::<GenericListViewBuilder<O, Box<dyn ArrayBuilder>>>()
.expect("should be an (Large)ListViewBuilder")
.append(false,0);
.append(false, 0);
builder
.values()
.as_any_mut()
Expand All @@ -619,10 +619,10 @@ mod tests {
.as_any_mut()
.downcast_mut::<GenericListViewBuilder<O, Box<dyn ArrayBuilder>>>()
.expect("should be an (Large)ListViewBuilder")
.append(true,1);
builder.append(true,3);
.append(true, 1);
builder.append(true, 3);

builder.append(false,0);
builder.append(false, 0);

builder
.values()
Expand All @@ -649,8 +649,8 @@ mod tests {
.as_any_mut()
.downcast_mut::<GenericListViewBuilder<O, Box<dyn ArrayBuilder>>>()
.expect("should be an (Large)ListViewBuilder")
.append(true,2);
builder.append(true,1);
.append(true, 2);
builder.append(true, 1);

let l1 = builder.finish();
assert_eq!(4, l1.len());
Expand Down Expand Up @@ -688,7 +688,9 @@ mod tests {
}

#[test]
#[should_panic(expected = "Non-nullable field of ListViewArray \\\"item\\\" cannot contain nulls")]
#[should_panic(
expected = "Non-nullable field of ListViewArray \\\"item\\\" cannot contain nulls"
)]
fn test_checks_nullability() {
let field = Arc::new(Field::new("item", DataType::Int32, false));
let mut builder = ListViewBuilder::new(Int32Builder::new()).with_field(field.clone());
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ mod generic_byte_run_builder;
pub use generic_byte_run_builder::*;
mod generic_bytes_view_builder;
pub use generic_bytes_view_builder::*;
mod union_builder;
mod generic_list_view_builder;
mod union_builder;
pub use generic_list_view_builder::*;

pub use union_builder::*;
Expand Down
4 changes: 3 additions & 1 deletion arrow-array/src/builder/struct_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ pub fn make_builder(datatype: &DataType, capacity: usize) -> Box<dyn ArrayBuilde
}
DataType::LargeListView(field) => {
let builder = make_builder(field.data_type(), capacity);
Box::new(LargeListViewBuilder::with_capacity(builder, capacity).with_field(field.clone()))
Box::new(
LargeListViewBuilder::with_capacity(builder, capacity).with_field(field.clone()),
)
}
DataType::Map(field, _) => match field.data_type() {
DataType::Struct(fields) => {
Expand Down
4 changes: 3 additions & 1 deletion arrow-array/src/record_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,9 @@ mod tests {
use std::collections::HashMap;

use super::*;
use crate::{BooleanArray, Int32Array, Int64Array, Int8Array, ListArray, StringArray, StringViewArray};
use crate::{
BooleanArray, Int32Array, Int64Array, Int8Array, ListArray, StringArray, StringViewArray,
};
use arrow_buffer::{Buffer, ToByteSlice};
use arrow_data::{ArrayData, ArrayDataBuilder};
use arrow_schema::Fields;
Expand Down
8 changes: 3 additions & 5 deletions arrow-buffer/src/buffer/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
// specific language governing permissions and limitations
// under the License.

use std::ops::Deref;
use crate::{ArrowNativeType, MutableBuffer, ScalarBuffer};
use std::ops::Deref;

#[derive(Debug, Clone)]
pub struct SizeBuffer<O: ArrowNativeType>(ScalarBuffer<O>);

impl<O: ArrowNativeType> SizeBuffer<O> {

/// Create a new [`SizeBuffer`] containing `len` `0` values
pub fn new_zeroed(len: usize) -> Self {
let len_bytes = len.checked_mul(std::mem::size_of::<O>()).expect("overflow");
Expand Down Expand Up @@ -54,8 +53,8 @@ impl<O: ArrowNativeType> SizeBuffer<O> {
/// assert_eq!(offsets.as_ref(), &[1, 3, 5]);
/// ```
pub fn from_lengths<I>(lengths: I) -> Self
where
I: IntoIterator<Item = usize>,
where
I: IntoIterator<Item = usize>,
{
let iter = lengths.into_iter();
let mut out = Vec::with_capacity(iter.size_hint().0);
Expand Down Expand Up @@ -90,7 +89,6 @@ impl<O: ArrowNativeType> SizeBuffer<O> {
}
}


impl<T: ArrowNativeType> Deref for SizeBuffer<T> {
type Target = [T];

Expand Down
19 changes: 11 additions & 8 deletions arrow-data/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ impl ArrayData {
&self,
values_length: usize,
) -> Result<(), ArrowError> {
let sizes = self.typed_sizes::<T>()?;
let sizes = self.typed_sizes::<T>()?;
if sizes.is_empty() {
return Ok(());
}
Expand Down Expand Up @@ -1702,13 +1702,16 @@ impl DataTypeLayout {
/// Describes a list view type
pub fn new_list_view<T>() -> Self {
Self {
buffers: vec![BufferSpec::FixedWidth {
byte_width: mem::size_of::<T>(),
alignment: mem::align_of::<T>(),
},BufferSpec::FixedWidth {
byte_width: mem::size_of::<T>(),
alignment: mem::align_of::<T>(),
}],
buffers: vec![
BufferSpec::FixedWidth {
byte_width: mem::size_of::<T>(),
alignment: mem::align_of::<T>(),
},
BufferSpec::FixedWidth {
byte_width: mem::size_of::<T>(),
alignment: mem::align_of::<T>(),
},
],
can_contain_null_mask: true,
variadic: true,
}
Expand Down
9 changes: 3 additions & 6 deletions arrow-data/src/equal/list_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
// specific language governing permissions and limitations
// under the License.

use num::Integer;
use arrow_buffer::ArrowNativeType;
use crate::ArrayData;
use crate::data::count_nulls;
use crate::ArrayData;
use arrow_buffer::ArrowNativeType;
use num::Integer;

use super::equal_range;

Expand All @@ -34,7 +34,6 @@ pub(super) fn list_view_equal<T: ArrowNativeType + Integer>(
let lhs_sizes = lhs.buffer::<T>(1);
let rhs_sizes = rhs.buffer::<T>(1);
for i in 0..len {

// compare offsets and sizes
let lhs_pos = lhs_start + i;
let rhs_pos = rhs_start + i;
Expand All @@ -45,14 +44,12 @@ pub(super) fn list_view_equal<T: ArrowNativeType + Integer>(
if lhs_size != rhs_size {
return false;
}

// compare nulls
let lhs_null_count = count_nulls(lhs.nulls(), lhs_offset_start, lhs_size);
let rhs_null_count = count_nulls(rhs.nulls(), rhs_offset_start, lhs_size);
if lhs_null_count != rhs_null_count {
return false;
}

// compare values
if !equal_range(
&lhs.child_data()[0],
Expand Down
4 changes: 2 additions & 2 deletions arrow-data/src/equal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//! depend on dynamic casting of `Array`.

use crate::data::ArrayData;
use crate::equal::list_view::list_view_equal;
use arrow_buffer::i256;
use arrow_schema::{DataType, IntervalUnit};
use half::f16;
Expand All @@ -30,14 +31,14 @@ mod dictionary;
mod fixed_binary;
mod fixed_list;
mod list;
mod list_view;
mod null;
mod primitive;
mod run;
mod structure;
mod union;
mod utils;
mod variable_size;
mod list_view;

// these methods assume the same type, len and null count.
// For this reason, they are not exposed and are instead used
Expand All @@ -53,7 +54,6 @@ use primitive::primitive_equal;
use structure::struct_equal;
use union::union_equal;
use variable_size::variable_sized_equal;
use crate::equal::list_view::list_view_equal;

use self::run::run_equal;

Expand Down

0 comments on commit 095a678

Please sign in to comment.