/
Field.pm
59 lines (44 loc) · 958 Bytes
/
Field.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package App::RecordStream::Aggregator::MapReduce::Field;
our $VERSION = "4.0.3";
use strict;
use warnings;
use App::RecordStream::Aggregator::MapReduce;
use App::RecordStream::DomainLanguage::Valuation::KeySpec;
use base 'App::RecordStream::Aggregator::MapReduce';
sub new
{
my $class = shift;
my $field = shift;
return new_from_valuation($class, App::RecordStream::DomainLanguage::Valuation::KeySpec->new($field));
}
sub new_from_valuation
{
my $class = shift;
my $valuation = shift;
my $this =
{
'valuation' => $valuation,
};
bless $this, $class;
return $this;
}
sub map
{
my ($this, $record) = @_;
if(!defined($this->{'valuation'}))
{
# oopsie, consider missing/undef fields not to count and return the empty cookie
return undef;
}
return $this->map_field($this->{'valuation'}->evaluate_record($record));
}
sub map_field
{
my ($this, $value) = @_;
return $value;
}
sub argct
{
return 1;
}
1;