/
Concatenate.pm
83 lines (61 loc) · 1.53 KB
/
Concatenate.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package App::RecordStream::Aggregator::Concatenate;
our $VERSION = "4.0.22";
use strict;
use warnings;
use App::RecordStream::Aggregator::MapReduce::Field;
use App::RecordStream::Aggregator;
use App::RecordStream::DomainLanguage::Registry;
use base 'App::RecordStream::Aggregator::MapReduce::Field';
sub new
{
my $class = shift;
my $delim = shift;
my $field = shift;
my $this = $class->SUPER::new($field);
$this->{'delim'} = $delim;
return $this;
}
sub new_from_valuation
{
my $class = shift;
my $delim = shift;
my $valuation = shift;
my $this = $class->SUPER::new_from_valuation($valuation);
$this->{'delim'} = $delim;
return $this;
}
sub map_field
{
my ($this, $value) = @_;
return [$value];
}
sub reduce
{
my ($this, $cookie, $cookie2) = @_;
return [@$cookie, @$cookie2];
}
sub squish
{
my ($this, $cookie) = @_;
return join($this->{'delim'}, @$cookie);
}
sub long_usage
{
return <<EOF;
Usage: concat,<delimiter>,<field>
Concatenate values from specified field.
EOF
}
sub short_usage
{
return "concatenate values from provided field";
}
sub argct
{
return 2;
}
App::RecordStream::Aggregator->register_implementation('concatenate', __PACKAGE__);
App::RecordStream::Aggregator->register_implementation('concat', __PACKAGE__);
App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'concatenate', 'SCALAR', 'VALUATION');
App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'concat', 'SCALAR', 'VALUATION');
1;