MCPcopy Create free account
hub / github.com/apache/datafusion / keep_only_maxrows

Function keep_only_maxrows

datafusion-cli/src/print_format.rs:92–107  ·  view source on GitHub ↗
(s: &str, maxrows: usize)

Source from the content-addressed store, hash-verified

90}
91
92fn keep_only_maxrows(s: &str, maxrows: usize) -> String {
93 let lines: Vec<String> = s.lines().map(String::from).collect();
94
95 assert!(lines.len() >= maxrows + 4); // 4 lines for top and bottom border
96
97 let last_line = &lines[lines.len() - 1]; // bottom border line
98
99 let spaces = last_line.len().saturating_sub(4);
100 let dotted_line = format!("| .{}|", " ".repeat(spaces));
101
102 let mut result = lines[0..(maxrows + 3)].to_vec(); // Keep top border and `maxrows` lines
103 result.extend(vec![dotted_line; 3]); // Append ... lines
104 result.push(last_line.clone());
105
106 result.join("\n")
107}
108
109fn format_batches_with_maxrows<W: std::io::Write>(
110 writer: &mut W,

Callers 1

Calls 8

collectMethod · 0.80
to_vecMethod · 0.80
mapMethod · 0.45
lenMethod · 0.45
extendMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…