line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Riak::Fast; |
2
|
|
|
|
|
|
|
|
3
|
22
|
|
|
22
|
|
774
|
use Mouse; |
|
22
|
|
|
|
|
28418
|
|
|
22
|
|
|
|
|
217
|
|
4
|
|
|
|
|
|
|
|
5
|
22
|
|
|
22
|
|
49887
|
use JSON::XS qw/decode_json/; |
|
22
|
|
|
|
|
150444
|
|
|
22
|
|
|
|
|
1601
|
|
6
|
22
|
|
|
22
|
|
2818
|
use URI; |
|
22
|
|
|
|
|
13888
|
|
|
22
|
|
|
|
|
556
|
|
7
|
|
|
|
|
|
|
|
8
|
22
|
|
|
22
|
|
12510
|
use Data::Riak::Fast::Result; |
|
22
|
|
|
|
|
78
|
|
|
22
|
|
|
|
|
722
|
|
9
|
22
|
|
|
22
|
|
13790
|
use Data::Riak::Fast::ResultSet; |
|
22
|
|
|
|
|
50
|
|
|
22
|
|
|
|
|
889
|
|
10
|
22
|
|
|
22
|
|
14505
|
use Data::Riak::Fast::Bucket; |
|
22
|
|
|
|
|
66
|
|
|
22
|
|
|
|
|
918
|
|
11
|
22
|
|
|
22
|
|
143
|
use Data::Riak::Fast::MapReduce; |
|
22
|
|
|
|
|
44
|
|
|
22
|
|
|
|
|
487
|
|
12
|
|
|
|
|
|
|
|
13
|
22
|
|
|
22
|
|
2785
|
use Data::Riak::Fast::HTTP; |
|
22
|
|
|
|
|
49
|
|
|
22
|
|
|
|
|
13936
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has transport => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'Data::Riak::Fast::HTTP', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
handles => { |
22
|
|
|
|
|
|
|
'ping' => 'ping', |
23
|
|
|
|
|
|
|
'base_uri' => 'base_uri', |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub send_request { |
28
|
0
|
|
|
0
|
0
|
|
my ($self, $request) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my ($response, $uri) = $self->transport->send($request); |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if ($response->is_error) { |
33
|
0
|
|
|
|
|
|
die $response; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my @parts = @{ $response->parts }; |
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
return unless @parts; |
39
|
0
|
0
|
|
|
|
|
return Data::Riak::Fast::ResultSet->new( |
40
|
|
|
|
|
|
|
{ |
41
|
|
|
|
|
|
|
results => [ |
42
|
|
|
|
|
|
|
map { |
43
|
0
|
|
|
|
|
|
Data::Riak::Fast::Result->new( |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
riak => $self, |
46
|
|
|
|
|
|
|
http_message => $_, |
47
|
|
|
|
|
|
|
location => ( |
48
|
|
|
|
|
|
|
$_->header('location') |
49
|
|
|
|
|
|
|
? URI->new( $_->header('location') ) |
50
|
|
|
|
|
|
|
: $uri |
51
|
|
|
|
|
|
|
) |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} @parts |
55
|
|
|
|
|
|
|
], |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _buckets { |
61
|
0
|
|
|
0
|
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return decode_json( |
64
|
|
|
|
|
|
|
$self->send_request({ |
65
|
|
|
|
|
|
|
method => 'GET', |
66
|
|
|
|
|
|
|
uri => '/buckets', |
67
|
|
|
|
|
|
|
query => { buckets => 'true' } |
68
|
|
|
|
|
|
|
})->first->value |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub bucket { |
73
|
0
|
|
|
0
|
0
|
|
my ($self, $bucket_name) = @_; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return Data::Riak::Fast::Bucket->new({ |
76
|
|
|
|
|
|
|
riak => $self, |
77
|
|
|
|
|
|
|
name => $bucket_name, |
78
|
|
|
|
|
|
|
}); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub resolve_link { |
82
|
0
|
|
|
0
|
0
|
|
my ($self, $link) = @_; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$self->bucket( $link->bucket )->get( $link->key ); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub linkwalk { |
88
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
0
|
|
|
|
my $object = $args->{object} || die 'You must have an object to linkwalk'; |
91
|
0
|
|
0
|
|
|
|
my $bucket = $args->{bucket} || die 'You must have a bucket for the original object to linkwalk'; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $request_str = "buckets/$bucket/keys/$object/"; |
94
|
0
|
|
|
|
|
|
my $params = $args->{params}; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
foreach my $depth (@$params) { |
97
|
0
|
0
|
|
|
|
|
if(scalar @{$depth} == 2) { |
|
0
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
unshift @{$depth}, $bucket; |
|
0
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
|
my ($buck, $tag, $keep) = @{$depth}; |
|
0
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$request_str .= "$buck,$tag,$keep/"; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
return $self->send_request({ |
105
|
|
|
|
|
|
|
method => 'GET', |
106
|
|
|
|
|
|
|
uri => $request_str |
107
|
|
|
|
|
|
|
}); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub stats { |
111
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
return decode_json( |
114
|
|
|
|
|
|
|
$self->send_request({ |
115
|
|
|
|
|
|
|
method => 'GET', |
116
|
|
|
|
|
|
|
uri => '/stats', |
117
|
|
|
|
|
|
|
})->first->value |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
122
|
22
|
|
|
22
|
|
130
|
no Mouse; |
|
22
|
|
|
|
|
48
|
|
|
22
|
|
|
|
|
178
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
__END__ |