File Coverage

blib/lib/App/RecordStream/Aggregator/MapReduce/FieldSet.pm
Criterion Covered Total %
statement 28 29 96.5
branch n/a
condition n/a
subroutine 8 9 88.8
pod 0 4 0.0
total 36 42 85.7


line stmt bran cond sub pod time code
1             package App::RecordStream::Aggregator::MapReduce::FieldSet;
2              
3             our $VERSION = "4.0.25";
4              
5 8     8   45 use strict;
  8         14  
  8         191  
6 8     8   35 use warnings;
  8         17  
  8         172  
7              
8 8     8   1259 use App::RecordStream::Aggregator::MapReduce;
  8         23  
  8         174  
9 8     8   1356 use App::RecordStream::DomainLanguage::Valuation::KeySpec;
  8         20  
  8         178  
10              
11 8     8   55 use base 'App::RecordStream::Aggregator::MapReduce';
  8         17  
  8         1982  
12              
13             sub new
14             {
15 5     5 0 2131 my $class = shift;
16 5         19 my @fields = @_;
17              
18 5         14 return new_from_valuation($class, map { App::RecordStream::DomainLanguage::Valuation::KeySpec->new($_) } @fields);
  10         44  
19             }
20              
21             sub new_from_valuation
22             {
23 13     13 0 24 my $class = shift;
24 13         30 my @valuations = @_;
25              
26 13         34 my $this =
27             {
28             'valuations' => \@valuations,
29             };
30 13         25 bless $this, $class;
31              
32 13         33 return $this;
33             }
34              
35             sub map
36             {
37 85     85 0 132 my ($this, $record) = @_;
38              
39 85         114 return $this->map_fields(map { $_->evaluate_record($record) } @{$this->{'valuations'}});
  170         376  
  85         178  
40             }
41              
42             sub map_fields
43             {
44 0     0 0   die "FieldSet subclass does not implement map_fields\n";
45             }
46              
47             1;