| 1 | package Data::Riak::MapReduce; | ||
| 2 | { | ||
| 3 | $Data::Riak::MapReduce::VERSION = '2.0'; | ||
| 4 | } | ||
| 5 | # ABSTRACT: A map/reduce query | ||
| 6 | |||
| 7 | 0 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 8 | use Data::Riak::MapReduce::Phase::Link; | ||
| 9 | use Data::Riak::MapReduce::Phase::Map; | ||
| 10 | use Data::Riak::MapReduce::Phase::Reduce; | ||
| 11 | use namespace::autoclean; | ||
| 12 | |||
| 13 | with 'Data::Riak::Role::HasRiak'; | ||
| 14 | |||
| 15 | |||
| 16 | has inputs => ( | ||
| 17 | is => 'ro', | ||
| 18 | isa => 'ArrayRef | Str | HashRef', | ||
| 19 | required => 1 | ||
| 20 | ); | ||
| 21 | |||
| 22 | |||
| 23 | has phases => ( | ||
| 24 | is => 'ro', | ||
| 25 | isa => 'ArrayRef[Data::Riak::MapReduce::Phase]', | ||
| 26 | required => 1 | ||
| 27 | ); | ||
| 28 | |||
| 29 | |||
| 30 | sub mapreduce { | ||
| 31 | my ($self, %options) = @_; | ||
| 32 | |||
| 33 | return $self->riak->send_request({ | ||
| 34 | %options, | ||
| 35 | type => 'MapReduce', | ||
| 36 | data => { | ||
| 37 | inputs => $self->inputs, | ||
| 38 | query => [ map { { $_->phase => $_->pack } } @{ $self->phases } ] | ||
| 39 | }, | ||
| 40 | }); | ||
| 41 | } | ||
| 42 | |||
| 43 | __PACKAGE__->meta->make_immutable; | ||
| 44 | |||
| 45 | 1; | ||
| 46 | |||
| 47 | __END__ | ||