Skip to content
Open
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
30 changes: 27 additions & 3 deletions vortex-array/src/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,31 @@ impl dyn DynArray + '_ {
write!(f, "{}", if f.alternate() { "[\n" } else { "[" })?;
let sep = if *omit_comma_after_space { "," } else { ", " };
let sep = if f.alternate() { ",\n" } else { sep };
let limit = std::cmp::min(self.len(), f.precision().unwrap_or(DISPLAY_LIMIT));
let limit = self.len().min(f.precision().unwrap_or(DISPLAY_LIMIT));
let is_truncated = self.len() > limit;
write!(
f,
"{}",
(0..limit)
(0..(limit - if is_truncated { 3 } else { 0 }))
.map(|i| self
.scalar_at(i)
.map_or_else(|e| format!("<error: {e}>"), |s| s.to_string()))
.format(sep)
)?;
write!(f, "{}", if f.alternate() { "\n]" } else { "]" })
if is_truncated {
write!(f, "{sep}...{sep}")?;
write!(
f,
"{}",
(self.len() - 3..self.len())
.map(|i| self
.scalar_at(i)
.map_or_else(|e| format!("<error: {e}>"), |s| s.to_string()))
.format(sep)
)?;
}
let closing_brace = if f.alternate() { "\n]" } else { "]" };
write!(f, "{closing_brace}")
}
DisplayOptions::TreeDisplay {
buffers,
Expand Down Expand Up @@ -583,6 +597,7 @@ mod test {
use crate::arrays::BoolArray;
use crate::arrays::ListArray;
use crate::arrays::StructArray;
use crate::display::DISPLAY_LIMIT;
use crate::dtype::FieldNames;
use crate::validity::Validity;

Expand All @@ -596,6 +611,15 @@ mod test {

let x = buffer![1, 2, 3, 4].into_array();
assert_eq!(x.display_values().to_string(), "[1i32, 2i32, 3i32, 4i32]");

let x = crate::arrays::PrimitiveArray::from_iter(
0i32..i32::try_from(DISPLAY_LIMIT).unwrap() + 1,
)
.into_array();
assert_eq!(
x.display_values().to_string(),
"[0i32, 1i32, 2i32, 3i32, 4i32, 5i32, 6i32, 7i32, 8i32, 9i32, 10i32, 11i32, 12i32, ..., 14i32, 15i32, 16i32]"
);
}

#[test]
Expand Down
Loading