MCPcopy Create free account
hub / github.com/apache/arrow-rs / print_long_array

Function print_long_array

arrow-array/src/array/mod.rs:1046–1080  ·  view source on GitHub ↗

Helper function for printing potentially long arrays.

(array: &A, f: &mut std::fmt::Formatter, print_item: F)

Source from the content-addressed store, hash-verified

1044
1045/// Helper function for printing potentially long arrays.
1046fn print_long_array<A, F>(array: &A, f: &mut std::fmt::Formatter, print_item: F) -> std::fmt::Result
1047where
1048 A: Array,
1049 F: Fn(&A, usize, &mut std::fmt::Formatter) -> std::fmt::Result,
1050{
1051 let head = std::cmp::min(10, array.len());
1052
1053 for i in 0..head {
1054 if array.is_null(i) {
1055 writeln!(f, " null,")?;
1056 } else {
1057 write!(f, " ")?;
1058 print_item(array, i, f)?;
1059 writeln!(f, ",")?;
1060 }
1061 }
1062 if array.len() > 10 {
1063 if array.len() > 20 {
1064 writeln!(f, " ...{} elements...,", array.len() - 20)?;
1065 }
1066
1067 let tail = std::cmp::max(head, array.len() - 10);
1068
1069 for i in tail..array.len() {
1070 if array.is_null(i) {
1071 writeln!(f, " null,")?;
1072 } else {
1073 write!(f, " ")?;
1074 print_item(array, i, f)?;
1075 writeln!(f, ",")?;
1076 }
1077 }
1078 }
1079 Ok(())
1080}
1081
1082#[cfg(test)]
1083mod tests {

Callers 10

fmtMethod · 0.85
fmtMethod · 0.85
fmtMethod · 0.85
fmtMethod · 0.85
fmtMethod · 0.85
fmtMethod · 0.85
fmtMethod · 0.85
fmtMethod · 0.85
fmtMethod · 0.85
fmtMethod · 0.85

Calls 4

minFunction · 0.85
maxFunction · 0.85
lenMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected