« blib/lib/App/RecordStream/Test/DistinctCountHelper.pm
↑ Summary
blib/lib/App/RecordStream/Aggregator/Internal/Constant.pm »
| 1 | package App::RecordStream::Operation::multiplex; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use base qw(App::RecordStream::Operation); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use App::RecordStream::Clumper::Options; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use App::RecordStream::Operation::multiplex::BaseClumperCallback; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub init { | ||||||||||||||||||||||||||||
| 12 | 5 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 5 | my $args = shift; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 5 | my $clumper_options = App::RecordStream::Clumper::Options->new(); | |||||||||||||||||||||||||||
| 16 | 5 | my $line_key = undef; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 5 | my $spec = { | |||||||||||||||||||||||||||
| 19 | $clumper_options->main_options(), | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # other options | ||||||||||||||||||||||||||||
| 22 | "line-key|L=s" => \$line_key, | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # help | ||||||||||||||||||||||||||||
| 25 | $clumper_options->help_options(), | ||||||||||||||||||||||||||||
| 26 | }; | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 5 | $this->parse_options($args, $spec); | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 4 | my ($script, @args) = @$args; | |||||||||||||||||||||||||||
| 31 | 4 | @$args = (); | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # check help first | ||||||||||||||||||||||||||||
| 34 | 4 | ▶ | $clumper_options->check_options(App::RecordStream::Operation::multiplex::BaseClumperCallback->new($script, \@args, $line_key, sub { return $this->push_record($_[0]); }, sub { return $this->push_line($_[0]); })); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 4 | $this->{'CLUMPER_OPTIONS'} = $clumper_options; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | sub accept_record { | ||||||||||||||||||||||||||||
| 40 | 32 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
accept_record: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 32 | my $record = shift; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 32 | $this->{'CLUMPER_OPTIONS'}->accept_record($record); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | sub stream_done { | ||||||||||||||||||||||||||||
| 47 | 4 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
stream_done: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 4 | $this->{'CLUMPER_OPTIONS'}->stream_done(); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub print_usage { | ||||||||||||||||||||||||||||
| 53 | 1 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
print_usage: called CC=3 SCAR=13.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 1 | my $message = shift; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | ▶ | if ( $message && UNIVERSAL::isa($message, 'CODE') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$message and UNIVERSAL::isa($message, "CODE")
MC/DC0%0/2
$message and UNIVERSAL::isa($message, "CODE")
$message
UNIVERSAL::isa($message, "CODE")
Truth table33%1/3
A and B
A= $messageB= UNIVERSAL::isa($message, "CODE")
| |||||||||||||||||||||||||||||
| 57 | 0 | $message->(); | |||||||||||||||||||||||||||
| 58 | 0 | exit 1; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 1 | $this->SUPER::print_usage($message); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub add_help_types { | ||||||||||||||||||||||||||||
| 65 | 5 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_help_types: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | 5 | $this->use_help_type('keyspecs'); | |||||||||||||||||||||||||||
| 67 | 5 | $this->use_help_type('keygroups'); | |||||||||||||||||||||||||||
| 68 | 5 | $this->use_help_type('keys'); | |||||||||||||||||||||||||||
| 69 | 5 | $this->use_help_type('domainlanguage'); | |||||||||||||||||||||||||||
| 70 | 5 | $this->use_help_type('clumping'); | |||||||||||||||||||||||||||
| 71 | $this->add_help_type( | ||||||||||||||||||||||||||||
| 72 | 'more', | ||||||||||||||||||||||||||||
| 73 | 1 | ▶ | sub { $this->more_help() }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 74 | 5 | 'Larger help documentation' | |||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | sub usage { | ||||||||||||||||||||||||||||
| 79 | 2 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
usage: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 2 | my $options = [ | |||||||||||||||||||||||||||
| 82 | App::RecordStream::Clumper::Options->main_usage(), | ||||||||||||||||||||||||||||
| 83 | [ 'line-key|-L <key>', 'Use the value of this key as line input for the nested operation (rather than the entire record). Use with recs-from* scripts generally.'], | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | App::RecordStream::Clumper::Options->help_usage(), | ||||||||||||||||||||||||||||
| 86 | ]; | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 2 | my $args_string = $this->options_string($options); | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | return <<USAGE | ||||||||||||||||||||||||||||
| 91 | Usage: recs-multiplex <args> -- <other recs operation> | ||||||||||||||||||||||||||||
| 92 | __FORMAT_TEXT__ | ||||||||||||||||||||||||||||
| 93 | Take records, grouped together by --keys, and run an operation for each | ||||||||||||||||||||||||||||
| 94 | group. | ||||||||||||||||||||||||||||
| 95 | __FORMAT_TEXT__ | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | Arguments: | ||||||||||||||||||||||||||||
| 98 | $args_string | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | Examples: | ||||||||||||||||||||||||||||
| 101 | Separate out a stream of text by PID into separate invocations of recs-frommultire. | ||||||||||||||||||||||||||||
| 102 | recs-fromre '^(.*PID=([0-9]*).*)\$' -f line,pid | recs-multiplex -L line -k pid -- recs-frommultire ... | ||||||||||||||||||||||||||||
| 103 | Tag lines with counts by thread | ||||||||||||||||||||||||||||
| 104 | recs-multiplex -k thread -- recs-eval '{{nbr}} = ++\$nbr' | ||||||||||||||||||||||||||||
| 105 | USAGE | ||||||||||||||||||||||||||||
| 106 | 2 | } | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | sub more_help { | ||||||||||||||||||||||||||||
| 109 | 1 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
more_help: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 110 | 1 | my $usage = $this->usage() . <<USAGE; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | Cubing: | ||||||||||||||||||||||||||||
| 113 | __FORMAT_TEXT__ | ||||||||||||||||||||||||||||
| 114 | Instead of added one entry for each input record, we add 2 ** (number of key | ||||||||||||||||||||||||||||
| 115 | fields), with every possible combination of fields replaced with the default | ||||||||||||||||||||||||||||
| 116 | of "ALL". This is not meant to be used with --adjacent or --size. If our | ||||||||||||||||||||||||||||
| 117 | key fields were x and y then we'd get output for {x = 1, y = 2}, {x = 1, y = | ||||||||||||||||||||||||||||
| 118 | ALL}, {x = ALL, y = 2} and {x = ALL, y = ALL}. | ||||||||||||||||||||||||||||
| 119 | __FORMAT_TEXT__ | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Domain Lanuage Integration: | ||||||||||||||||||||||||||||
| 122 | USAGE | ||||||||||||||||||||||||||||
| 123 | 1 | $usage .= App::RecordStream::DomainLanguage::short_usage() . <<USAGE; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | __FORMAT_TEXT__ | ||||||||||||||||||||||||||||
| 126 | Keys may be specified using the recs domain language. --dlkey requires an | ||||||||||||||||||||||||||||
| 127 | option of the format '<name>=<domain language code>'. --dlkey requires the | ||||||||||||||||||||||||||||
| 128 | code evaluate as a valuation. | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | See --help-domainlanguage for a more complete description of its workings | ||||||||||||||||||||||||||||
| 131 | and a list of available functions. | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | See the examples in the recs-collate help for a more gentle introduction. | ||||||||||||||||||||||||||||
| 134 | __FORMAT_TEXT__ | ||||||||||||||||||||||||||||
| 135 | USAGE | ||||||||||||||||||||||||||||
| 136 | 1 | print $this->format_usage($usage); | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 2 | 1; | |||||||||||||||||||||||||||