| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package ArangoDB; |
|
2
|
8
|
|
|
8
|
|
831231
|
use strict; |
|
|
8
|
|
|
|
|
22
|
|
|
|
8
|
|
|
|
|
1440
|
|
|
3
|
8
|
|
|
8
|
|
69
|
use warnings; |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
326
|
|
|
4
|
8
|
|
|
8
|
|
8204
|
use utf8; |
|
|
8
|
|
|
|
|
88
|
|
|
|
8
|
|
|
|
|
42
|
|
|
5
|
8
|
|
|
8
|
|
442
|
use 5.008001; |
|
|
8
|
|
|
|
|
29
|
|
|
|
8
|
|
|
|
|
394
|
|
|
6
|
8
|
|
|
8
|
|
47
|
use Carp qw(croak); |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
453
|
|
|
7
|
8
|
|
|
8
|
|
4380
|
use ArangoDB::Connection; |
|
|
8
|
|
|
|
|
159
|
|
|
|
8
|
|
|
|
|
283
|
|
|
8
|
8
|
|
|
8
|
|
7802
|
use ArangoDB::Collection; |
|
|
8
|
|
|
|
|
34
|
|
|
|
8
|
|
|
|
|
430
|
|
|
9
|
8
|
|
|
8
|
|
96
|
use ArangoDB::Document; |
|
|
8
|
|
|
|
|
21
|
|
|
|
8
|
|
|
|
|
184
|
|
|
10
|
8
|
|
|
8
|
|
7008
|
use ArangoDB::Statement; |
|
|
8
|
|
|
|
|
32
|
|
|
|
8
|
|
|
|
|
280
|
|
|
11
|
8
|
|
|
8
|
|
53
|
use ArangoDB::Constants qw(:api); |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
1922
|
|
|
12
|
|
|
|
|
|
|
use overload '&{}' => sub { |
|
13
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
14
|
0
|
|
|
0
|
|
0
|
return sub { $self->collection( $_[0] ) }; |
|
|
0
|
|
|
|
|
0
|
|
|
15
|
|
|
|
|
|
|
}, |
|
16
|
8
|
|
|
8
|
|
49
|
fallback => 1; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
55
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
|
19
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
|
22
|
16
|
|
|
16
|
1
|
8873
|
my ( $class, $options ) = @_; |
|
23
|
16
|
|
|
|
|
68
|
my $self = bless { connection => ArangoDB::Connection->new($options), }, $class; |
|
24
|
6
|
|
|
|
|
76
|
return $self; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub collection { |
|
28
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $name ) = @_; |
|
29
|
0
|
|
0
|
|
|
0
|
return $self->find($name) || $self->create($name); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub create { |
|
33
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $name, $_options ) = @_; |
|
34
|
0
|
0
|
|
|
|
0
|
my $params = { ( waitForSync => 0, isSystem => 0 ), %{ $_options || {} } }; |
|
|
0
|
|
|
|
|
0
|
|
|
35
|
0
|
|
|
|
|
0
|
$params->{name} = $name; |
|
36
|
0
|
|
|
|
|
0
|
my $coll; |
|
37
|
0
|
|
|
|
|
0
|
eval { |
|
38
|
0
|
|
|
|
|
0
|
my $res = $self->{connection}->http_post( API_COLLECTION, $params ); |
|
39
|
0
|
|
|
|
|
0
|
$coll = ArangoDB::Collection->new( $self, $res ); |
|
40
|
|
|
|
|
|
|
}; |
|
41
|
0
|
0
|
|
|
|
0
|
if ($@) { |
|
42
|
0
|
|
|
|
|
0
|
$self->_server_error_handler( $@, "Failed to create collection($name)" ); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
0
|
|
|
|
|
0
|
return $coll; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub find { |
|
48
|
1
|
|
|
1
|
1
|
1144
|
my ( $self, $name ) = @_; |
|
49
|
1
|
|
|
|
|
4
|
my $api = API_COLLECTION . '/' . $name; |
|
50
|
1
|
|
|
|
|
2
|
my $collection = eval { |
|
51
|
1
|
|
|
|
|
51
|
my $res = $self->{connection}->http_get($api); |
|
52
|
0
|
|
|
|
|
0
|
ArangoDB::Collection->new( $self, $res ); |
|
53
|
|
|
|
|
|
|
}; |
|
54
|
1
|
50
|
|
|
|
6
|
if ($@) { |
|
55
|
1
|
|
|
|
|
11
|
$self->_server_error_handler( $@, "Failed to get collection: $name", 1 ); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
0
|
|
|
|
|
0
|
return $collection; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub collections { |
|
61
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
62
|
0
|
|
|
|
|
0
|
my @colls; |
|
63
|
0
|
|
|
|
|
0
|
eval { |
|
64
|
0
|
|
|
|
|
0
|
my $res = $self->{connection}->http_get(API_COLLECTION); |
|
65
|
0
|
|
|
|
|
0
|
@colls = map { ArangoDB::Collection->new( $self, $_ ) } @{ $res->{collections} }; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
66
|
|
|
|
|
|
|
}; |
|
67
|
0
|
0
|
|
|
|
0
|
if ($@) { |
|
68
|
0
|
|
|
|
|
0
|
$self->_server_error_handler( $@, 'Failed to get collections' ); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
0
|
|
|
|
|
0
|
return \@colls; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub query { |
|
74
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $query ) = @_; |
|
75
|
0
|
|
|
|
|
0
|
return ArangoDB::Statement->new( $self->{connection}, $query ); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub document { |
|
79
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $doc ) = @_; |
|
80
|
0
|
|
0
|
|
|
0
|
$doc = $doc || q{}; |
|
81
|
0
|
|
|
|
|
0
|
my $api = API_DOCUMENT . '/' . $doc; |
|
82
|
0
|
|
|
|
|
0
|
my $res = eval { $self->{connection}->http_get($api) }; |
|
|
0
|
|
|
|
|
0
|
|
|
83
|
0
|
0
|
|
|
|
0
|
if ($@) { |
|
84
|
0
|
|
|
|
|
0
|
$self->_server_error_handler( $@, "Failed to get the document($doc) in the collection(%s)" ); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
0
|
|
|
|
|
0
|
return ArangoDB::Document->new( $self->{connection}, $res ); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub edge { |
|
90
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $edge ) = @_; |
|
91
|
0
|
|
0
|
|
|
0
|
$edge = $edge || q{}; |
|
92
|
0
|
|
|
|
|
0
|
my $api = API_EDGE . '/' . $edge; |
|
93
|
0
|
|
|
|
|
0
|
my $res = eval { $self->{connection}->http_get($api) }; |
|
|
0
|
|
|
|
|
0
|
|
|
94
|
0
|
0
|
|
|
|
0
|
if ($@) { |
|
95
|
0
|
|
|
|
|
0
|
$self->_server_error_handler( $@, "Failed to get the edge($edge) in the collection(%s)" ); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
0
|
|
|
|
|
0
|
return ArangoDB::Edge->new( $self->{connection}, $res ); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub index { |
|
101
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $index_id ) = @_; |
|
102
|
0
|
0
|
|
|
|
0
|
$index_id = defined $index_id ? $index_id : q{}; |
|
103
|
0
|
|
|
|
|
0
|
my $api = API_INDEX . '/' . $index_id; |
|
104
|
0
|
|
|
|
|
0
|
my $index = eval { |
|
105
|
0
|
|
|
|
|
0
|
my $res = $self->{connection}->http_get($api); |
|
106
|
0
|
|
|
|
|
0
|
$self->_get_index_instance($res); |
|
107
|
|
|
|
|
|
|
}; |
|
108
|
0
|
0
|
|
|
|
0
|
if ($@) { |
|
109
|
0
|
|
|
|
|
0
|
$self->_server_error_handler( $@, 'Failed to get the index($index_id) on the collection(%s)' ); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
0
|
|
|
|
|
0
|
return $index; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub _server_error_handler { |
|
115
|
1
|
|
|
1
|
|
5
|
my ( $self, $error, $message, $ignore_404 ) = @_; |
|
116
|
1
|
50
|
33
|
|
|
7
|
if ( ref($error) && $error->isa('ArangoDB::ServerException') ) { |
|
117
|
0
|
0
|
0
|
|
|
0
|
return if $ignore_404 && $error->code == 404; |
|
118
|
0
|
|
0
|
|
|
0
|
$message .= ':' . ( $error->detail->{errorMessage} || q{} ); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
1
|
|
|
|
|
228
|
croak $message; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
BEGIN { |
|
124
|
8
|
|
|
8
|
|
15069
|
*_get_index_instance = \&ArangoDB::Collection::_get_index_instance; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |
|
128
|
|
|
|
|
|
|
__END__ |