| 1 | package Druid::PostAggregator::Arithmetic; | ||
| 2 | use Moo; | ||
| 3 | |||
| 4 | extends 'Druid::PostAggregator'; | ||
| 5 | |||
| 6 | has fn => (is => 'ro'); | ||
| 7 | has fields => (is => 'ro', default => sub { [] }); | ||
| 8 | has ordering => (is => 'ro', default => 'null'); | ||
| 9 | |||
| 10 | sub type { 'arithmetic' } | ||
| 11 | |||
| 12 | sub build { | ||
| 13 | my $self = shift; | ||
| 14 | |||
| 15 | my $aggregation = { | ||
| 16 | 'type' => $self->type, | ||
| 17 | 'name' => $self->name, | ||
| 18 | 'fn' => $self->fn, | ||
| 19 | 'fields' => [], | ||
| 20 | 'ordering' => $self->ordering, | ||
| 21 | }; | ||
| 22 | |||
| 23 | push @{ $aggregation->{'fields'} }, $_->build | ||
| 24 | for @{ $self->fields }; | ||
| 25 | |||
| 26 | return $aggregation; | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 |