« blib/lib/App/RecordStream/Operation/normalizetime.pm
↑ Summary
blib/lib/App/RecordStream/Aggregator/PercentileMap.pm »
| 1 | package App::RecordStream::Operation::substream; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use base qw(App::RecordStream::Operation); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use App::RecordStream::Executor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | sub init { | ||||||||||||||||||||||||||||
| 10 | 6 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | 6 | my $args = shift; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 6 | my $begin; | |||||||||||||||||||||||||||
| 14 | my $end; | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 6 | my $spec = { | |||||||||||||||||||||||||||
| 17 | "begin|b=s" => \$begin, | ||||||||||||||||||||||||||||
| 18 | "end|e=s" => \$end, | ||||||||||||||||||||||||||||
| 19 | }; | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 6 | $this->parse_options($args, $spec); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 5 | ▶ | $this->{'BEGIN_EXECUTOR'} = App::RecordStream::Executor->new($begin) if defined $begin; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 5 | ▶ | $this->{'END_EXECUTOR'} = App::RecordStream::Executor->new($end) if defined $end; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub accept_record { | ||||||||||||||||||||||||||||
| 28 | 33 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
accept_record: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 33 | my $record = shift; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 33 | ▶ | if ( ! $this->{'IN_SUBSTREAM'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 8 | my $executor = $this->{'BEGIN_EXECUTOR'}; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 8 | ▶ | if ( (! defined $executor) || $executor->execute_code($record) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $executor or $executor->execute_code($record)
MC/DC100%2/2
not defined $executor or $executor->execute_code($record)
not defined $executor
$executor->execute_code($record)
Truth table100%3/3
not(A) or B
A= not defined $executorB= $executor->execute_code($record)
| |||||||||||||||||||||||||||||
| 35 | 5 | $this->{'IN_SUBSTREAM'} = 1; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 33 | ▶ | if ( $this->{'IN_SUBSTREAM'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 30 | my $executor = $this->{'END_EXECUTOR'}; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 30 | $this->push_record($record); | |||||||||||||||||||||||||||
| 43 | 30 | $this->{'SEEN_RECORD'} = 1; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 30 | ▶ | if ( (defined $executor) && $executor->execute_code($record) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $executor and $executor->execute_code($record)
MC/DC100%2/2
defined $executor and $executor->execute_code($record)
defined $executor
$executor->execute_code($record)
Truth table100%3/3
A and B
A= defined $executorB= $executor->execute_code($record)
| |||||||||||||||||||||||||||||
| 46 | 3 | $this->{'IN_SUBSTREAM'} = 0; | |||||||||||||||||||||||||||
| 47 | 3 | return 0; # terminate early to avoid reading the rest of the stream | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 30 | return 1; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub stream_done { | ||||||||||||||||||||||||||||
| 55 | 5 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
stream_done: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 5 | ▶ | $this->_set_exit_value(1) unless ( $this->{'SEEN_RECORD'} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub add_help_types { | ||||||||||||||||||||||||||||
| 60 | 6 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_help_types: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 6 | $this->use_help_type('snippet'); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub usage { | ||||||||||||||||||||||||||||
| 65 | 1 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
usage: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 1 | my $options = [ | |||||||||||||||||||||||||||
| 68 | ['begin|b SNIP ', 'Begins outputting records when this snippet becomes true. If omitted, output starts from beginning of the stream.'], | ||||||||||||||||||||||||||||
| 69 | ['end|e SNIP', 'Stops outputting records after this snippet becomes true. If omitted, outputs to the end of the stream.'], | ||||||||||||||||||||||||||||
| 70 | ]; | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 1 | my $args_string = $this->options_string($options); | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 1 | return <<USAGE; | |||||||||||||||||||||||||||
| 75 | Usage: recs-substream <args> [<files>] | ||||||||||||||||||||||||||||
| 76 | __FORMAT_TEXT__ | ||||||||||||||||||||||||||||
| 77 | Filters to a range of records delimited from when the begin snippet becomes true to when the end snippet becomes true, ie. [begin, end]. Compare to Perl's inclusive, bistable ".." range operator. | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | See --help-snippet for details on snippets. | ||||||||||||||||||||||||||||
| 80 | __FORMAT_TEXT__ | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | Arguments: | ||||||||||||||||||||||||||||
| 83 | $args_string | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | Examples: | ||||||||||||||||||||||||||||
| 86 | Filter to a specific minute: | ||||||||||||||||||||||||||||
| 87 | recs-substream -b '{{EndTime}} =~ /Thu, 07 Nov 2013 22:42/' -e 'not {{EndTime}} =~ /Thu, 07 Nov 2013 22:42/' | ||||||||||||||||||||||||||||
| 88 | Truncate past a specific date: | ||||||||||||||||||||||||||||
| 89 | recs-substream -e '{{EndTime}} =~ /Thu, 07 Nov/' | ||||||||||||||||||||||||||||
| 90 | USAGE | ||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 2 | 1; | |||||||||||||||||||||||||||