Skip to content
Closed
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
4 changes: 3 additions & 1 deletion rust/arrow/src/array/array_binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ impl<'a, T: BinaryOffsetSizeTrait> GenericBinaryArray<T> {

impl<OffsetSize: BinaryOffsetSizeTrait> fmt::Debug for GenericBinaryArray<OffsetSize> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}BinaryArray\n[\n", OffsetSize::prefix())?;
let prefix = if OffsetSize::is_large() { "Large" } else { "" };

write!(f, "{}BinaryArray\n[\n", prefix)?;
print_long_array(self, f, |array, index, f| {
fmt::Debug::fmt(&array.value(index), f)
})?;
Expand Down
16 changes: 4 additions & 12 deletions rust/arrow/src/array/array_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,20 @@ use crate::datatypes::{ArrowNativeType, ArrowPrimitiveType, DataType, Field};
/// trait declaring an offset size, relevant for i32 vs i64 array types.
pub trait OffsetSizeTrait: ArrowNativeType + Num + Ord + std::ops::AddAssign {
fn is_large() -> bool;

fn prefix() -> &'static str;
}

impl OffsetSizeTrait for i32 {
#[inline]
fn is_large() -> bool {
false
}

fn prefix() -> &'static str {
""
}
}

impl OffsetSizeTrait for i64 {
#[inline]
fn is_large() -> bool {
true
}

fn prefix() -> &'static str {
"Large"
}
}

pub struct GenericListArray<OffsetSize> {
Expand Down Expand Up @@ -183,7 +173,7 @@ impl<OffsetSize: OffsetSizeTrait> GenericListArray<OffsetSize> {
.collect();

let field = Box::new(Field::new("item", T::DATA_TYPE, true));
let data_type = if OffsetSize::prefix() == "Large" {
let data_type = if OffsetSize::is_large() {
DataType::LargeList(field)
} else {
DataType::List(field)
Expand Down Expand Up @@ -266,7 +256,9 @@ impl<OffsetSize: 'static + OffsetSizeTrait> Array for GenericListArray<OffsetSiz

impl<OffsetSize: OffsetSizeTrait> fmt::Debug for GenericListArray<OffsetSize> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}ListArray\n[\n", OffsetSize::prefix())?;
let prefix = if OffsetSize::is_large() { "Large" } else { "" };

write!(f, "{}ListArray\n[\n", prefix)?;
print_long_array(self, f, |array, index, f| {
fmt::Debug::fmt(&array.value(index), f)
})?;
Expand Down
4 changes: 3 additions & 1 deletion rust/arrow/src/array/array_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ impl<'a, T: StringOffsetSizeTrait> GenericStringArray<T> {

impl<OffsetSize: StringOffsetSizeTrait> fmt::Debug for GenericStringArray<OffsetSize> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}StringArray\n[\n", OffsetSize::prefix())?;
let prefix = if OffsetSize::is_large() { "Large" } else { "" };

write!(f, "{}StringArray\n[\n", prefix)?;
print_long_array(self, f, |array, index, f| {
fmt::Debug::fmt(&array.value(index), f)
})?;
Expand Down