Skip to content

Commit dfbb9f1

Browse files
authored
Migrate arrow-ord to Rust 2024 (#8484)
# Which issue does this PR close? - Contribute to #6827 # Rationale for this change Splitting up #8227. # What changes are included in this PR? Migrate `arrow-ord` to Rust 2024 # Are these changes tested? CI # Are there any user-facing changes? Yes
1 parent 1c81321 commit dfbb9f1

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

arrow-ord/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ authors = { workspace = true }
2525
license = { workspace = true }
2626
keywords = { workspace = true }
2727
include = { workspace = true }
28-
edition = { workspace = true }
28+
edition = "2024"
2929
rust-version = { workspace = true }
3030

3131
[lib]

arrow-ord/src/cmp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
use arrow_array::cast::AsArray;
2727
use arrow_array::types::{ByteArrayType, ByteViewType};
2828
use arrow_array::{
29-
downcast_primitive_array, AnyDictionaryArray, Array, ArrowNativeTypeOp, BooleanArray, Datum,
30-
FixedSizeBinaryArray, GenericByteArray, GenericByteViewArray,
29+
AnyDictionaryArray, Array, ArrowNativeTypeOp, BooleanArray, Datum, FixedSizeBinaryArray,
30+
GenericByteArray, GenericByteViewArray, downcast_primitive_array,
3131
};
3232
use arrow_buffer::bit_util::ceil;
3333
use arrow_buffer::{BooleanBuffer, MutableBuffer, NullBuffer};
@@ -509,7 +509,7 @@ impl ArrayOrd for &BooleanArray {
509509
}
510510

511511
unsafe fn value_unchecked(&self, idx: usize) -> Self::Item {
512-
BooleanArray::value_unchecked(self, idx)
512+
unsafe { BooleanArray::value_unchecked(self, idx) }
513513
}
514514

515515
fn is_eq(l: Self::Item, r: Self::Item) -> bool {
@@ -529,7 +529,7 @@ impl<T: ArrowNativeTypeOp> ArrayOrd for &[T] {
529529
}
530530

531531
unsafe fn value_unchecked(&self, idx: usize) -> Self::Item {
532-
*self.get_unchecked(idx)
532+
unsafe { *self.get_unchecked(idx) }
533533
}
534534

535535
fn is_eq(l: Self::Item, r: Self::Item) -> bool {
@@ -549,7 +549,7 @@ impl<'a, T: ByteArrayType> ArrayOrd for &'a GenericByteArray<T> {
549549
}
550550

551551
unsafe fn value_unchecked(&self, idx: usize) -> Self::Item {
552-
GenericByteArray::value_unchecked(self, idx).as_ref()
552+
unsafe { GenericByteArray::value_unchecked(self, idx).as_ref() }
553553
}
554554

555555
fn is_eq(l: Self::Item, r: Self::Item) -> bool {
@@ -624,7 +624,7 @@ impl<'a> ArrayOrd for &'a FixedSizeBinaryArray {
624624
}
625625

626626
unsafe fn value_unchecked(&self, idx: usize) -> Self::Item {
627-
FixedSizeBinaryArray::value_unchecked(self, idx)
627+
unsafe { FixedSizeBinaryArray::value_unchecked(self, idx) }
628628
}
629629

630630
fn is_eq(l: Self::Item, r: Self::Item) -> bool {

arrow-ord/src/comparison.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use arrow_array::cast::*;
2727

2828
use arrow_array::*;
29-
use arrow_buffer::{bit_util, BooleanBuffer, MutableBuffer, NullBuffer};
29+
use arrow_buffer::{BooleanBuffer, MutableBuffer, NullBuffer, bit_util};
3030
use arrow_schema::ArrowError;
3131

3232
/// Checks if a [`GenericListArray`] contains a value in the [`PrimitiveArray`]
@@ -119,7 +119,7 @@ mod tests {
119119
ListBuilder, PrimitiveDictionaryBuilder, StringBuilder, StringDictionaryBuilder,
120120
};
121121
use arrow_array::types::*;
122-
use arrow_buffer::{i256, ArrowNativeType, Buffer, IntervalDayTime, IntervalMonthDayNano};
122+
use arrow_buffer::{ArrowNativeType, Buffer, IntervalDayTime, IntervalMonthDayNano, i256};
123123
use arrow_data::ArrayData;
124124
use arrow_schema::{DataType, Field};
125125
use half::f16;

arrow-ord/src/ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ pub fn make_comparator(
423423
mod tests {
424424
use super::*;
425425
use arrow_array::builder::{Int32Builder, ListBuilder, MapBuilder, StringBuilder};
426-
use arrow_buffer::{i256, IntervalDayTime, OffsetBuffer};
426+
use arrow_buffer::{IntervalDayTime, OffsetBuffer, i256};
427427
use arrow_schema::{DataType, Field, Fields};
428428
use half::f16;
429429
use std::sync::Arc;

arrow-ord/src/rank.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use arrow_array::cast::AsArray;
2121
use arrow_array::types::*;
2222
use arrow_array::{
23-
downcast_primitive_array, Array, ArrowNativeTypeOp, BooleanArray, GenericByteArray,
23+
Array, ArrowNativeTypeOp, BooleanArray, GenericByteArray, downcast_primitive_array,
2424
};
2525
use arrow_buffer::NullBuffer;
2626
use arrow_schema::{ArrowError, DataType, SortOptions};

arrow-ord/src/sort.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
//! Defines sort kernel for `ArrayRef`
1919
20-
use crate::ord::{make_comparator, DynComparator};
20+
use crate::ord::{DynComparator, make_comparator};
2121
use arrow_array::builder::BufferBuilder;
2222
use arrow_array::cast::*;
2323
use arrow_array::types::*;
@@ -1072,7 +1072,7 @@ mod tests {
10721072
BooleanBuilder, FixedSizeListBuilder, GenericListBuilder, Int64Builder, ListBuilder,
10731073
PrimitiveRunBuilder,
10741074
};
1075-
use arrow_buffer::{i256, NullBuffer};
1075+
use arrow_buffer::{NullBuffer, i256};
10761076
use arrow_schema::Field;
10771077
use half::f16;
10781078
use rand::rngs::StdRng;
@@ -4802,11 +4802,13 @@ mod tests {
48024802
]);
48034803

48044804
assert!(!can_sort_to_indices(struct_array.data_type()));
4805-
assert!(sort_to_indices(&struct_array, None, None)
4806-
.err()
4807-
.unwrap()
4808-
.to_string()
4809-
.contains("Sort not supported for data type"));
4805+
assert!(
4806+
sort_to_indices(&struct_array, None, None)
4807+
.err()
4808+
.unwrap()
4809+
.to_string()
4810+
.contains("Sort not supported for data type")
4811+
);
48104812

48114813
let sort_columns = vec![SortColumn {
48124814
values: Arc::new(struct_array.clone()) as ArrayRef,

0 commit comments

Comments
 (0)