Change ->filter_zeroed_rows into ->zero_rows.

This commit is contained in:
Brian Fraser
2012-01-10 16:28:32 -03:00
parent f173069109
commit 6d47e958c7
3 changed files with 20 additions and 22 deletions

View File

@@ -48,7 +48,7 @@ sub new {
device_regex => qr/.+/, device_regex => qr/.+/,
block_size => 512, block_size => 512,
out_fh => \*STDOUT, out_fh => \*STDOUT,
filter_zeroed_rows => $o->get('zero-rows') ? undef : 1, zero_rows => $o->get('zero-rows') ? 1 : undef,
sample_time => $o->get('sample-time') || 0, sample_time => $o->get('sample-time') || 0,
interactive => 0, interactive => 0,
@@ -122,14 +122,14 @@ sub set_first_ts {
$self->{_ts}->{first} = $val || 0; $self->{_ts}->{first} = $val || 0;
} }
sub filter_zeroed_rows { sub zero_rows {
my ($self) = @_; my ($self) = @_;
return $self->{filter_zeroed_rows}; return $self->{zero_rows};
} }
sub set_filter_zeroed_rows { sub set_zero_rows {
my ($self, $new_val) = @_; my ($self, $new_val) = @_;
$self->{filter_zeroed_rows} = $new_val; $self->{zero_rows} = $new_val;
} }
sub sample_time { sub sample_time {
@@ -861,7 +861,7 @@ sub print_header {
sub print_rows { sub print_rows {
my ($self, $format, $cols, $stat) = @_; my ($self, $format, $cols, $stat) = @_;
if ( $self->filter_zeroed_rows() ) { if ( ! $self->zero_rows() ) {
# Conundrum: What is "zero"? # Conundrum: What is "zero"?
# Is 0.000001 zero? How about 0.1? # Is 0.000001 zero? How about 0.1?
# Here the answer is "it looks like zero after formatting"; # Here the answer is "it looks like zero after formatting";

View File

@@ -296,7 +296,7 @@ sub help {
my $device_re = $args{options}->{OptionParser}->get('devices'); my $device_re = $args{options}->{OptionParser}->get('devices');
my $interval = $obj->sample_time() || '(none)'; my $interval = $obj->sample_time() || '(none)';
my $disp_int = $args{options}->{OptionParser}->get('redisplay-interval'); my $disp_int = $args{options}->{OptionParser}->get('redisplay-interval');
my $inact_disk = $obj->filter_zeroed_rows() ? 'yes' : 'no'; my $inact_disk = $obj->zero_rows() ? 'no' : 'yes';
for my $re ( $column_re, $device_re ) { for my $re ( $column_re, $device_re ) {
$re ||= '(none)'; $re ||= '(none)';
@@ -368,10 +368,8 @@ sub hide_inactive_disks {
my (%args) = @_; my (%args) = @_;
my $new_val = get_blocking_input("Filter inactive rows? (Leave blank for 'No') "); my $new_val = get_blocking_input("Filter inactive rows? (Leave blank for 'No') ");
# Eeep. In OptionParser, "true" means show; in Diskstats, "true" means hide.
# Thus !$new_val for OptionParser
$args{options}->{OptionParser}->set('zero-rows', !$new_val); $args{options}->{OptionParser}->set('zero-rows', !$new_val);
$args{options}->{current_group_by_obj}->set_filter_zeroed_rows($new_val); $args{options}->{current_group_by_obj}->set_zero_rows(!$new_val);
return; return;
} }

View File

@@ -46,7 +46,7 @@ for my $attr (
[ device_regex => qr/!!!/ ], [ device_regex => qr/!!!/ ],
[ block_size => 215 ], [ block_size => 215 ],
[ out_fh => \*STDERR ], [ out_fh => \*STDERR ],
[ filter_zeroed_rows => 1 ], [ zero_rows => 1 ],
[ sample_time => 1 ], [ sample_time => 1 ],
[ interactive => 1 ], [ interactive => 1 ],
) { ) {
@@ -221,7 +221,7 @@ is_deeply(
"...And clears the internal duplicate-checking list" "...And clears the internal duplicate-checking list"
); );
$obj->set_filter_zeroed_rows(1); $obj->set_zero_rows(0);
my $print_output = output( my $print_output = output(
sub { sub {
$obj->print_rows( $obj->print_rows(
@@ -231,12 +231,12 @@ my $print_output = output(
); );
} }
); );
$obj->set_filter_zeroed_rows(0); $obj->set_zero_rows(1);
is( is(
$print_output, $print_output,
"", "",
"->filter_zeroed_rows works" "->zero_rows works"
); );
for my $method ( qw( delta_against delta_against_ts group_by ) ) { for my $method ( qw( delta_against delta_against_ts group_by ) ) {
@@ -291,7 +291,7 @@ for my $test (
method => "group_by_sample", method => "group_by_sample",
results_file_prefix => "sample", results_file_prefix => "sample",
}) { }) {
my $obj = $test->{class}->new(OptionParser => $o, filter_zeroed_rows => 0); my $obj = $test->{class}->new(OptionParser => $o, zero_rows => 1);
my $method = $test->{method}; my $method = $test->{method};
my $prefix = $test->{results_file_prefix}; my $prefix = $test->{results_file_prefix};