in automation/tinc/main/ext/explain.pl [1829:1940]
sub get_rows_out
{
my ($node, $ctx, $edge) = @_;
return
unless ($node->{txt} =~ m/(Rows out\:)|(\(cost\=.*\s+rows=.*\s+width\=.*\))/);
my $long = ($edge =~ m/long|med/i);
if ($node->{txt} =~ m/Rows out\:\s+Avg.*\s+rows\s+x\s+.*\s+workers/)
{
if (!$long)
{
# short result
my @foo =
($node->{txt} =~
m/Rows out\:\s+Avg\s+(.*)\s+rows\s+x\s+(.*)\s+workers/);
goto L_get_est unless (2 == scalar(@foo));
# calculate row count as avg x num workers
$node->{rows_out} = $foo[0] * $foo[1];
}
else
{
my @foo =
($node->{txt} =~
m/Rows out\:\s+(Avg.*workers)/);
goto L_get_est unless (1 == scalar(@foo));
# just print the string
$node->{rows_out} = $foo[0];
if ($edge =~ m/med/i)
{
$node->{rows_out} =~ s/Avg\s+//;
$node->{rows_out} =~ s/rows\s+//;
$node->{rows_out} =~ s/\s*workers\s*//;
}
}
}
elsif ($node->{txt} =~ m/Rows out\:\s+.*\s+rows/)
{
my @foo =
($node->{txt} =~
m/Rows out\:\s+(.*)\s+rows/);
goto L_get_est unless (1 == scalar(@foo));
$node->{rows_out} = $foo[0];
}
if (
exists($node->{rows_out}) &&
length($node->{rows_out})
)
{
if (
($node->{rows_out} !~ m/avg/i) &&
($node->{rows_out} =~ m/x/))
{
my @foo = ($node->{rows_out} =~ m/(x.*)$/);
my $tail = $foo[0];
@foo = ($node->{rows_out} =~ m/(.*)\s+x.*/);
my $head = $foo[0];
if (defined($tail) && defined($head))
{
$head = human_num($head);
$node->{rows_out} = $head . " " . $tail;
}
}
elsif ($node->{rows_out} =~ m/^\d+$/)
{
$node->{rows_out} = human_num($node->{rows_out});
}
}
L_get_est:
# add row estimates
if ($long &&
($node->{txt} =~ m/\(cost\=.*\s+rows=.*\s+width\=.*\)/))
{
my @foo = ($node->{txt} =~ m/cost\=.*\s+rows=(\d+)\s+width\=.*/);
if (scalar(@foo))
{
use POSIX;
my $esti = $foo[0];
$esti = human_num($esti);
unless (exists($node->{rows_out}) &&
length($node->{rows_out}))
{
$node->{rows_out} = "";
}
$node->{rows_out} .= " (est $esti)";
}
}
} # end get_rows_out