|
12 | 12 | // See the License for the specific language governing permissions and |
13 | 13 | // limitations under the License. |
14 | 14 |
|
| 15 | +use std::fmt; |
15 | 16 | use std::sync::Arc; |
16 | 17 |
|
17 | 18 | use bumpalo::Bump; |
@@ -45,6 +46,29 @@ pub struct PartitionedPayload { |
45 | 46 | unsafe impl Send for PartitionedPayload {} |
46 | 47 | unsafe impl Sync for PartitionedPayload {} |
47 | 48 |
|
| 49 | +struct PartitionDebugSnapshot<'a> { |
| 50 | + index: usize, |
| 51 | + rows: usize, |
| 52 | + pages: usize, |
| 53 | + payload: Option<&'a Payload>, |
| 54 | +} |
| 55 | + |
| 56 | +impl fmt::Debug for PartitionDebugSnapshot<'_> { |
| 57 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 58 | + let mut debug = f.debug_struct("Partition"); |
| 59 | + debug |
| 60 | + .field("index", &self.index) |
| 61 | + .field("rows", &self.rows) |
| 62 | + .field("pages", &self.pages); |
| 63 | + |
| 64 | + if let Some(payload) = self.payload { |
| 65 | + debug.field("payload", payload); |
| 66 | + } |
| 67 | + |
| 68 | + debug.finish() |
| 69 | + } |
| 70 | +} |
| 71 | + |
48 | 72 | impl PartitionedPayload { |
49 | 73 | pub fn new( |
50 | 74 | group_types: Vec<DataType>, |
@@ -269,6 +293,47 @@ impl PartitionedPayload { |
269 | 293 | } |
270 | 294 | } |
271 | 295 |
|
| 296 | +impl fmt::Debug for PartitionedPayload { |
| 297 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 298 | + let partitions: Vec<PartitionDebugSnapshot<'_>> = self |
| 299 | + .payloads |
| 300 | + .iter() |
| 301 | + .enumerate() |
| 302 | + .map(|(index, payload)| PartitionDebugSnapshot { |
| 303 | + index, |
| 304 | + rows: payload.len(), |
| 305 | + pages: payload.pages.len(), |
| 306 | + payload: if f.alternate() { Some(payload) } else { None }, |
| 307 | + }) |
| 308 | + .collect(); |
| 309 | + |
| 310 | + let group_types: Vec<String> = self.group_types.iter().map(|ty| ty.to_string()).collect(); |
| 311 | + let aggregate_functions: Vec<String> = self |
| 312 | + .aggrs |
| 313 | + .iter() |
| 314 | + .map(|func| func.name().to_string()) |
| 315 | + .collect(); |
| 316 | + let arena_strong_counts: Vec<usize> = self |
| 317 | + .arenas |
| 318 | + .iter() |
| 319 | + .map(|arena| Arc::strong_count(arena)) |
| 320 | + .collect(); |
| 321 | + |
| 322 | + let mut debug = f.debug_struct("PartitionedPayload"); |
| 323 | + debug |
| 324 | + .field("partition_count", &self.partition_count) |
| 325 | + .field("mask", &self.mask_v) |
| 326 | + .field("shift", &self.shift_v) |
| 327 | + .field("total_rows", &self.len()) |
| 328 | + .field("group_types", &group_types) |
| 329 | + .field("aggregate_functions", &aggregate_functions) |
| 330 | + .field("partitions", &partitions) |
| 331 | + .field("arena_strong_counts", &arena_strong_counts); |
| 332 | + |
| 333 | + debug.finish() |
| 334 | + } |
| 335 | +} |
| 336 | + |
272 | 337 | #[inline] |
273 | 338 | fn shift(radix_bits: u64) -> u64 { |
274 | 339 | 48 - radix_bits |
|
0 commit comments