| 91 | } |
| 92 | |
| 93 | fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter) -> fmt::Result { |
| 94 | match t { |
| 95 | DisplayFormatType::Default | DisplayFormatType::Verbose => { |
| 96 | let partition_sizes: Vec<_> = |
| 97 | self.partitions.iter().map(|b| b.len()).collect(); |
| 98 | |
| 99 | let output_ordering = self |
| 100 | .sort_information |
| 101 | .first() |
| 102 | .map(|output_ordering| format!(", output_ordering={output_ordering}")) |
| 103 | .unwrap_or_default(); |
| 104 | |
| 105 | let eq_properties = self.eq_properties(); |
| 106 | let constraints = eq_properties.constraints(); |
| 107 | let constraints = if constraints.is_empty() { |
| 108 | String::new() |
| 109 | } else { |
| 110 | format!(", {constraints}") |
| 111 | }; |
| 112 | |
| 113 | let limit = self |
| 114 | .fetch |
| 115 | .map_or(String::new(), |limit| format!(", fetch={limit}")); |
| 116 | if self.show_sizes { |
| 117 | write!( |
| 118 | f, |
| 119 | "partitions={}, partition_sizes={partition_sizes:?}{limit}{output_ordering}{constraints}", |
| 120 | partition_sizes.len(), |
| 121 | ) |
| 122 | } else { |
| 123 | write!( |
| 124 | f, |
| 125 | "partitions={}{limit}{output_ordering}{constraints}", |
| 126 | partition_sizes.len(), |
| 127 | ) |
| 128 | } |
| 129 | } |
| 130 | DisplayFormatType::TreeRender => { |
| 131 | let total_rows = self.partitions.iter().map(|b| b.len()).sum::<usize>(); |
| 132 | let total_bytes: usize = self |
| 133 | .partitions |
| 134 | .iter() |
| 135 | .flatten() |
| 136 | .map(|batch| batch.get_array_memory_size()) |
| 137 | .sum(); |
| 138 | writeln!(f, "format=memory")?; |
| 139 | writeln!(f, "rows={total_rows}")?; |
| 140 | writeln!(f, "bytes={total_bytes}")?; |
| 141 | Ok(()) |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /// If possible, redistribute batches across partitions according to their size. |
| 147 | /// |