MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / fmt_text_constant_rows

Function fmt_text_constant_rows

src/expr/src/explain/text.rs:1462–1493  ·  view source on GitHub ↗
(
    f: &mut fmt::Formatter<'_>,
    mut rows: I,
    ctx: &mut Indent,
    redacted: bool,
)

Source from the content-addressed store, hash-verified

1460}
1461
1462pub fn fmt_text_constant_rows<'a, I>(
1463 f: &mut fmt::Formatter<'_>,
1464 mut rows: I,
1465 ctx: &mut Indent,
1466 redacted: bool,
1467) -> fmt::Result
1468where
1469 I: Iterator<Item = (&'a Row, &'a Diff)>,
1470{
1471 let mut row_count = Diff::ZERO;
1472 let mut first_rows = Vec::with_capacity(20);
1473 for _ in 0..20 {
1474 if let Some((row, diff)) = rows.next() {
1475 row_count += diff.abs();
1476 first_rows.push((row, diff));
1477 }
1478 }
1479 let rest_of_row_count = rows.map(|(_, diff)| diff.abs()).sum::<Diff>();
1480 if !rest_of_row_count.is_zero() {
1481 writeln!(
1482 f,
1483 "{}total_rows (diffs absed): {}",
1484 ctx,
1485 row_count + rest_of_row_count
1486 )?;
1487 writeln!(f, "{}first_rows:", ctx)?;
1488 ctx.indented(move |ctx| write_first_rows(f, &first_rows, ctx, redacted))?;
1489 } else {
1490 write_first_rows(f, &first_rows, ctx, redacted)?;
1491 }
1492 Ok(())
1493}
1494
1495fn write_first_rows(
1496 f: &mut fmt::Formatter<'_>,

Callers 4

fmt_verbose_textMethod · 0.85
fmt_verbose_syntaxMethod · 0.85
fmt_raw_syntaxMethod · 0.85
fmt_verbose_textMethod · 0.85

Calls 6

write_first_rowsFunction · 0.85
indentedMethod · 0.80
nextMethod · 0.45
pushMethod · 0.45
mapMethod · 0.45
is_zeroMethod · 0.45

Tested by

no test coverage detected