Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ include = [
"NOTICE.txt",
]
edition = "2024"
rust-version = "1.85"
rust-version = "1.88"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change of this PR


[workspace.dependencies]
arrow = { version = "59.0.0", path = "./arrow", default-features = false }
Expand Down
29 changes: 4 additions & 25 deletions arrow-array/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,40 +413,19 @@ native_type_float_op!(
f16::from_bits(-1 as _),
f16::from_bits(i16::MAX as _)
);
// from_bits is not yet stable as const fn, see https://github.com/rust-lang/rust/issues/72447
native_type_float_op!(
f32,
0.,
1.,
unsafe {
// Need to allow in clippy because
// current MSRV (Minimum Supported Rust Version) is `1.85.0` but this item is stable since `1.87.0`
#[allow(unnecessary_transmutes)]
std::mem::transmute(-1_i32)
},
unsafe {
// Need to allow in clippy because
// current MSRV (Minimum Supported Rust Version) is `1.85.0` but this item is stable since `1.87.0`
#[allow(unnecessary_transmutes)]
std::mem::transmute(i32::MAX)
}
f32::from_bits(-1_i32 as _),
f32::from_bits(i32::MAX as _)
);
native_type_float_op!(
f64,
0.,
1.,
unsafe {
// Need to allow in clippy because
// current MSRV (Minimum Supported Rust Version) is `1.85.0` but this item is stable since `1.87.0`
#[allow(unnecessary_transmutes)]
std::mem::transmute(-1_i64)
},
unsafe {
// Need to allow in clippy because
// current MSRV (Minimum Supported Rust Version) is `1.85.0` but this item is stable since `1.87.0`
#[allow(unnecessary_transmutes)]
std::mem::transmute(i64::MAX)
}
f64::from_bits(-1_i64 as _),
f64::from_bits(i64::MAX as _)
);

#[cfg(test)]
Expand Down
18 changes: 9 additions & 9 deletions arrow-array/src/array/byte_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ impl<T: ByteArrayType> GenericByteArray<T> {
// Verify that each pair of offsets is a valid slices of values
T::validate(&offsets, &values)?;

if let Some(n) = nulls.as_ref() {
if n.len() != len {
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for {}{}Array, expected {len} got {}",
T::Offset::PREFIX,
T::PREFIX,
n.len(),
)));
}
if let Some(n) = nulls.as_ref()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating MSRV requires updating clippy as well

&& n.len() != len
{
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for {}{}Array, expected {len} got {}",
T::Offset::PREFIX,
T::PREFIX,
n.len(),
)));
}

Ok(Self {
Expand Down
18 changes: 9 additions & 9 deletions arrow-array/src/array/byte_view_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {

T::validate(&views, &buffers)?;

if let Some(n) = nulls.as_ref() {
if n.len() != views.len() {
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for {}ViewArray, expected {} got {}",
T::PREFIX,
views.len(),
n.len(),
)));
}
if let Some(n) = nulls.as_ref()
&& n.len() != views.len()
{
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for {}ViewArray, expected {} got {}",
T::PREFIX,
views.len(),
n.len(),
)));
}

Ok(Self {
Expand Down
16 changes: 8 additions & 8 deletions arrow-array/src/array/fixed_size_binary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ impl FixedSizeBinaryArray {

let len = match values.len().checked_div(value_size) {
Some(len) => {
if let Some(n) = nulls.as_ref() {
if n.len() != len {
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for FixedSizeBinaryArray, expected {} got {}",
len,
n.len(),
)));
}
if let Some(n) = nulls.as_ref()
&& n.len() != len
{
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for FixedSizeBinaryArray, expected {} got {}",
len,
n.len(),
)));
}

len
Expand Down
32 changes: 16 additions & 16 deletions arrow-array/src/array/fixed_size_list_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl FixedSizeListArray {

Self::try_new_with_length(field, size, values, nulls, len)
} else {
if values.len() % s != 0 {
if !values.len().is_multiple_of(s) {
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of values buffer for FixedSizeListArray, \
expected a multiple of {s} got {}",
Expand All @@ -186,15 +186,15 @@ impl FixedSizeListArray {
let len = values.len() / s;

// Check that the null buffer length is correct (if it exists).
if let Some(null_buffer) = &nulls {
if s * null_buffer.len() != values.len() {
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of values buffer for FixedSizeListArray, \
if let Some(null_buffer) = &nulls
&& s * null_buffer.len() != values.len()
{
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of values buffer for FixedSizeListArray, \
expected {} got {}",
s * null_buffer.len(),
values.len(),
)));
}
s * null_buffer.len(),
values.len(),
)));
}

Self::try_new_with_length(field, size, values, nulls, len)
Expand Down Expand Up @@ -227,13 +227,13 @@ impl FixedSizeListArray {
ArrowError::InvalidArgumentError(format!("Size cannot be negative, got {size}"))
})?;

if let Some(null_buffer) = &nulls {
if null_buffer.len() != len {
return Err(ArrowError::InvalidArgumentError(format!(
"Invalid null buffer for FixedSizeListArray, expected {len} found {}",
null_buffer.len()
)));
}
if let Some(null_buffer) = &nulls
&& null_buffer.len() != len
{
return Err(ArrowError::InvalidArgumentError(format!(
"Invalid null buffer for FixedSizeListArray, expected {len} found {}",
null_buffer.len()
)));
}

if s == 0 && !values.is_empty() {
Expand Down
16 changes: 8 additions & 8 deletions arrow-array/src/array/list_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ impl<OffsetSize: OffsetSizeTrait> GenericListArray<OffsetSize> {
)));
}

if let Some(n) = nulls.as_ref() {
if n.len() != len {
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for {}ListArray, expected {len} got {}",
OffsetSize::PREFIX,
n.len(),
)));
}
if let Some(n) = nulls.as_ref()
&& n.len() != len
{
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for {}ListArray, expected {len} got {}",
OffsetSize::PREFIX,
n.len(),
)));
}
if !field.is_nullable() && values.is_nullable() {
return Err(ArrowError::InvalidArgumentError(format!(
Expand Down
16 changes: 8 additions & 8 deletions arrow-array/src/array/list_view_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ impl<OffsetSize: OffsetSizeTrait> GenericListViewArray<OffsetSize> {
nulls: Option<NullBuffer>,
) -> Result<Self, ArrowError> {
let len = offsets.len();
if let Some(n) = nulls.as_ref() {
if n.len() != len {
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for {}ListViewArray, expected {len} got {}",
OffsetSize::PREFIX,
n.len(),
)));
}
if let Some(n) = nulls.as_ref()
&& n.len() != len
{
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for {}ListViewArray, expected {len} got {}",
OffsetSize::PREFIX,
n.len(),
)));
}
if len != sizes.len() {
return Err(ArrowError::InvalidArgumentError(format!(
Expand Down
14 changes: 7 additions & 7 deletions arrow-array/src/array/map_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ impl MapArray {
)));
}

if let Some(n) = nulls.as_ref() {
if n.len() != len {
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for MapArray, expected {len} got {}",
n.len(),
)));
}
if let Some(n) = nulls.as_ref()
&& n.len() != len
{
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for MapArray, expected {len} got {}",
n.len(),
)));
}
if field.is_nullable() || entries.null_count() != 0 {
return Err(ArrowError::InvalidArgumentError(
Expand Down
16 changes: 8 additions & 8 deletions arrow-array/src/array/primitive_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,14 +655,14 @@ impl<T: ArrowPrimitiveType> PrimitiveArray<T> {
values: ScalarBuffer<T::Native>,
nulls: Option<NullBuffer>,
) -> Result<Self, ArrowError> {
if let Some(n) = nulls.as_ref() {
if n.len() != values.len() {
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for PrimitiveArray, expected {} got {}",
values.len(),
n.len(),
)));
}
if let Some(n) = nulls.as_ref()
&& n.len() != values.len()
{
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect length of null buffer for PrimitiveArray, expected {} got {}",
values.len(),
n.len(),
)));
}

Ok(Self {
Expand Down
34 changes: 16 additions & 18 deletions arrow-array/src/array/struct_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ impl StructArray {
)));
}

if let Some(n) = nulls.as_ref() {
if n.len() != len {
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect number of nulls for StructArray, expected {len} got {}",
n.len(),
)));
}
if let Some(n) = nulls.as_ref()
&& n.len() != len
{
return Err(ArrowError::InvalidArgumentError(format!(
"Incorrect number of nulls for StructArray, expected {len} got {}",
n.len(),
)));
}

for (f, a) in fields.iter().zip(&arrays) {
Expand All @@ -166,17 +166,15 @@ impl StructArray {
)));
}

if !f.is_nullable() {
if let Some(a) = a.logical_nulls() {
if !nulls.as_ref().map(|n| n.contains(&a)).unwrap_or_default()
&& a.null_count() > 0
{
return Err(ArrowError::InvalidArgumentError(format!(
"Found unmasked nulls for non-nullable StructArray field {:?}",
f.name()
)));
}
}
if !f.is_nullable()
&& let Some(a) = a.logical_nulls()
&& !nulls.as_ref().map(|n| n.contains(&a)).unwrap_or_default()
&& a.null_count() > 0
{
return Err(ArrowError::InvalidArgumentError(format!(
"Found unmasked nulls for non-nullable StructArray field {:?}",
f.name()
)));
}
}

Expand Down
54 changes: 26 additions & 28 deletions arrow-array/src/builder/generic_bytes_view_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,36 +359,34 @@ impl<T: ByteViewType + ?Sized> GenericByteViewBuilder<T> {
.max_deduplication_len
.map(|max_length| length <= max_length)
.unwrap_or(true);
if can_deduplicate {
if let Some((mut ht, hasher)) = self.string_tracker.take() {
let hash_val = hasher.hash_one(v);
let hasher_fn = |v: &_| hasher.hash_one(v);

let entry = ht.entry(
hash_val,
|idx| {
let stored_value = self.get_value(*idx);
v == stored_value
},
hasher_fn,
);
match entry {
Entry::Occupied(occupied) => {
// If the string already exists, we will directly use the view
let idx = occupied.get();
self.views_buffer.push(self.views_buffer[*idx]);
self.null_buffer_builder.append_non_null();
self.string_tracker = Some((ht, hasher));
return Ok(());
}
Entry::Vacant(vacant) => {
// o.w. we insert the (string hash -> view index)
// the idx is current length of views_builder, as we are inserting a new view
vacant.insert(self.views_buffer.len());
}
if can_deduplicate && let Some((mut ht, hasher)) = self.string_tracker.take() {
let hash_val = hasher.hash_one(v);
let hasher_fn = |v: &_| hasher.hash_one(v);

let entry = ht.entry(
hash_val,
|idx| {
let stored_value = self.get_value(*idx);
v == stored_value
},
hasher_fn,
);
match entry {
Entry::Occupied(occupied) => {
// If the string already exists, we will directly use the view
let idx = occupied.get();
self.views_buffer.push(self.views_buffer[*idx]);
self.null_buffer_builder.append_non_null();
self.string_tracker = Some((ht, hasher));
return Ok(());
}
Entry::Vacant(vacant) => {
// o.w. we insert the (string hash -> view index)
// the idx is current length of views_builder, as we are inserting a new view
vacant.insert(self.views_buffer.len());
}
self.string_tracker = Some((ht, hasher));
}
self.string_tracker = Some((ht, hasher));
}

let required_cap = self.in_progress.len() + v.len();
Expand Down
Loading
Loading