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.24";
4              
5 8     8   45 use strict;
  8         17  
  8         197  
6 8     8   37 use warnings;
  8         16  
  8         184  
7              
8 8     8   725 use App::RecordStream::Aggregator::MapReduce;
  8         17  
  8         166  
9 8     8   719 use App::RecordStream::DomainLanguage::Valuation::KeySpec;
  8         18  
  8         169  
10              
11 8     8   38 use base 'App::RecordStream::Aggregator::MapReduce';
  8         17  
  8         1767  
12              
13             sub new
14             {
15 5     5 0 2467 my $class = shift;
16 5         19 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 26 my $class = shift;
24 13         40 my @valuations = @_;
25              
26 13         43 my $this =
27             {
28             'valuations' => \@valuations,
29             };
30 13         29 bless $this, $class;
31              
32 13         48 return $this;
33             }
34              
35             sub map
36             {
37 85     85 0 169 my ($this, $record) = @_;
38              
39 85         130 return $this->map_fields(map { $_->evaluate_record($record) } @{$this->{'valuations'}});
  170         433  
  85         204  
40             }
41              
42             sub map_fields
43             {
44 0     0 0   die "FieldSet subclass does not implement map_fields\n";
45             }
46              
47             1;