diff --git a/src/array/binary/fmt.rs b/src/array/binary/fmt.rs index 1d82f2c979e..c068d0d3656 100644 --- a/src/array/binary/fmt.rs +++ b/src/array/binary/fmt.rs @@ -15,7 +15,7 @@ impl Debug for BinaryArray { fn fmt(&self, f: &mut Formatter<'_>) -> Result { let writer = |f: &mut Formatter, index| write_value(self, index, f); - let head = if O::is_large() { + let head = if O::IS_LARGE { "LargeBinaryArray" } else { "BinaryArray" diff --git a/src/array/binary/mod.rs b/src/array/binary/mod.rs index 7a6aec0fd69..5fbe0f0b130 100644 --- a/src/array/binary/mod.rs +++ b/src/array/binary/mod.rs @@ -124,7 +124,7 @@ impl BinaryArray { /// Returns the default [`DataType`], `DataType::Binary` or `DataType::LargeBinary` pub fn default_data_type() -> DataType { - if O::is_large() { + if O::IS_LARGE { DataType::LargeBinary } else { DataType::Binary diff --git a/src/array/list/fmt.rs b/src/array/list/fmt.rs index 868689a3827..e6103ded6cb 100644 --- a/src/array/list/fmt.rs +++ b/src/array/list/fmt.rs @@ -20,7 +20,7 @@ impl Debug for ListArray { fn fmt(&self, f: &mut Formatter<'_>) -> Result { let writer = |f: &mut Formatter, index| write_value(self, index, "None", f); - let head = if O::is_large() { + let head = if O::IS_LARGE { "LargeListArray" } else { "ListArray" diff --git a/src/array/list/mod.rs b/src/array/list/mod.rs index 1470cb2b3be..18662a9ee1a 100644 --- a/src/array/list/mod.rs +++ b/src/array/list/mod.rs @@ -292,7 +292,7 @@ impl ListArray { /// Returns a default [`DataType`]: inner field is named "item" and is nullable pub fn default_datatype(data_type: DataType) -> DataType { let field = Box::new(Field::new("item", data_type, true)); - if O::is_large() { + if O::IS_LARGE { DataType::LargeList(field) } else { DataType::List(field) @@ -310,7 +310,7 @@ impl ListArray { /// # Errors /// Panics iff the logical type is not consistent with this struct. fn try_get_child(data_type: &DataType) -> Result<&Field, ArrowError> { - if O::is_large() { + if O::IS_LARGE { match data_type.to_logical_type() { DataType::LargeList(child) => Ok(child.as_ref()), _ => Err(ArrowError::oos( diff --git a/src/array/list/mutable.rs b/src/array/list/mutable.rs index 47695a7f009..5b4a1e3e6f9 100644 --- a/src/array/list/mutable.rs +++ b/src/array/list/mutable.rs @@ -110,7 +110,7 @@ impl MutableListArray { /// Creates a new [`MutableListArray`] from a [`MutableArray`]. pub fn new_with_field(values: M, name: &str, nullable: bool) -> Self { let field = Box::new(Field::new(name, values.data_type().clone(), nullable)); - let data_type = if O::is_large() { + let data_type = if O::IS_LARGE { DataType::LargeList(field) } else { DataType::List(field) diff --git a/src/array/utf8/fmt.rs b/src/array/utf8/fmt.rs index 3752e2bfbda..6ea28feae12 100644 --- a/src/array/utf8/fmt.rs +++ b/src/array/utf8/fmt.rs @@ -12,7 +12,7 @@ impl Debug for Utf8Array { fn fmt(&self, f: &mut Formatter<'_>) -> Result { let writer = |f: &mut Formatter, index| write_value(self, index, f); - let head = if O::is_large() { + let head = if O::IS_LARGE { "LargeUtf8Array" } else { "Utf8Array" diff --git a/src/array/utf8/mod.rs b/src/array/utf8/mod.rs index 9a756825513..f51f14d0081 100644 --- a/src/array/utf8/mod.rs +++ b/src/array/utf8/mod.rs @@ -142,7 +142,7 @@ impl Utf8Array { /// Returns the default [`DataType`], `DataType::Utf8` or `DataType::LargeUtf8` pub fn default_data_type() -> DataType { - if O::is_large() { + if O::IS_LARGE { DataType::LargeUtf8 } else { DataType::Utf8 diff --git a/src/array/utf8/mutable.rs b/src/array/utf8/mutable.rs index f19e331cfac..b0824702c0c 100644 --- a/src/array/utf8/mutable.rs +++ b/src/array/utf8/mutable.rs @@ -265,7 +265,7 @@ impl MutableArray for MutableUtf8Array { } fn data_type(&self) -> &DataType { - if O::is_large() { + if O::IS_LARGE { &DataType::LargeUtf8 } else { &DataType::Utf8 diff --git a/src/compute/length.rs b/src/compute/length.rs index cd445d8f43b..a8a2a530abc 100644 --- a/src/compute/length.rs +++ b/src/compute/length.rs @@ -35,7 +35,7 @@ where .map(|offset| op(offset[1] - offset[0])) .collect::>(); - let data_type = if O::is_large() { + let data_type = if O::IS_LARGE { DataType::Int64 } else { DataType::Int32 diff --git a/src/scalar/binary.rs b/src/scalar/binary.rs index 7f0d61e025a..7b6c0b98240 100644 --- a/src/scalar/binary.rs +++ b/src/scalar/binary.rs @@ -46,7 +46,7 @@ impl Scalar for BinaryScalar { #[inline] fn data_type(&self) -> &DataType { - if O::is_large() { + if O::IS_LARGE { &DataType::LargeBinary } else { &DataType::Binary diff --git a/src/scalar/utf8.rs b/src/scalar/utf8.rs index 66267127859..3fad8a4a48a 100644 --- a/src/scalar/utf8.rs +++ b/src/scalar/utf8.rs @@ -46,7 +46,7 @@ impl Scalar for Utf8Scalar { #[inline] fn data_type(&self) -> &DataType { - if O::is_large() { + if O::IS_LARGE { &DataType::LargeUtf8 } else { &DataType::Utf8 diff --git a/src/types/offset.rs b/src/types/offset.rs index b4ea9661307..e68bb7ceb6b 100644 --- a/src/types/offset.rs +++ b/src/types/offset.rs @@ -4,19 +4,13 @@ use super::Index; /// as offsets of variable-length Arrow arrays. pub trait Offset: super::private::Sealed + Index { /// Whether it is `i32` (false) or `i64` (true). - fn is_large() -> bool; + const IS_LARGE: bool; } impl Offset for i32 { - #[inline] - fn is_large() -> bool { - false - } + const IS_LARGE: bool = false; } impl Offset for i64 { - #[inline] - fn is_large() -> bool { - true - } + const IS_LARGE: bool = true; } diff --git a/tests/it/compute/length.rs b/tests/it/compute/length.rs index 73d36fc68d3..9bb37576956 100644 --- a/tests/it/compute/length.rs +++ b/tests/it/compute/length.rs @@ -15,7 +15,7 @@ fn length_test_string() { let array = Utf8Array::::from(&input); let result = length(&array).unwrap(); - let data_type = if O::is_large() { + let data_type = if O::IS_LARGE { DataType::Int64 } else { DataType::Int32