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.23";
4              
5 8     8   46 use strict;
  8         713  
  8         197  
6 8     8   39 use warnings;
  8         18  
  8         837  
7              
8 8     8   1010 use App::RecordStream::Aggregator::MapReduce;
  8         17  
  8         147  
9 8     8   992 use App::RecordStream::DomainLanguage::Valuation::KeySpec;
  8         17  
  8         151  
10              
11 8     8   37 use base 'App::RecordStream::Aggregator::MapReduce';
  8         17  
  8         1652  
12              
13             sub new
14             {
15 5     5 0 1153 my $class = shift;
16 5         18 my @fields = @_;
17              
18 5         16 return new_from_valuation($class, map { App::RecordStream::DomainLanguage::Valuation::KeySpec->new($_) } @fields);
  10         47  
19             }
20              
21             sub new_from_valuation
22             {
23 13     13 0 29 my $class = shift;
24 13         40 my @valuations = @_;
25              
26 13         49 my $this =
27             {
28             'valuations' => \@valuations,
29             };
30 13         30 bless $this, $class;
31              
32 13         49 return $this;
33             }
34              
35             sub map
36             {
37 85     85 0 168 my ($this, $record) = @_;
38              
39 85         148 return $this->map_fields(map { $_->evaluate_record($record) } @{$this->{'valuations'}});
  170         541  
  85         209  
40             }
41              
42             sub map_fields
43             {
44 0     0 0   die "FieldSet subclass does not implement map_fields\n";
45             }
46              
47             1;