line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ArangoDB2::Index; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
86
|
use strict; |
|
21
|
|
|
|
|
24
|
|
|
21
|
|
|
|
|
647
|
|
4
|
21
|
|
|
21
|
|
88
|
use warnings; |
|
21
|
|
|
|
|
23
|
|
|
21
|
|
|
|
|
591
|
|
5
|
|
|
|
|
|
|
|
6
|
21
|
|
|
|
|
1442
|
use base qw( |
7
|
|
|
|
|
|
|
ArangoDB2::Base |
8
|
21
|
|
|
21
|
|
101
|
); |
|
21
|
|
|
|
|
49
|
|
9
|
|
|
|
|
|
|
|
10
|
21
|
|
|
21
|
|
110
|
use Data::Dumper; |
|
21
|
|
|
|
|
22
|
|
|
21
|
|
|
|
|
962
|
|
11
|
21
|
|
|
21
|
|
91
|
use JSON::XS; |
|
21
|
|
|
|
|
31
|
|
|
21
|
|
|
|
|
13615
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# parameters that can be set when creating index or |
14
|
|
|
|
|
|
|
# are returned when creating/getting index |
15
|
|
|
|
|
|
|
our @PARAMS = qw( |
16
|
|
|
|
|
|
|
byteSize constraint fields geoJson id ignoreNull |
17
|
|
|
|
|
|
|
isNewlyCreated minLength size type unique |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $JSON = JSON::XS->new->utf8; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# byteSize |
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# get/set byteSize |
27
|
0
|
|
|
0
|
1
|
|
sub byteSize { shift->_get_set('byteSize', @_) } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# constraint |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
# get/set constraint value |
32
|
0
|
|
|
0
|
1
|
|
sub constraint { shift->_get_set_bool('constraint', @_) } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# create |
35
|
|
|
|
|
|
|
# |
36
|
|
|
|
|
|
|
# POST /_api/index |
37
|
|
|
|
|
|
|
sub create |
38
|
|
|
|
|
|
|
{ |
39
|
0
|
|
|
0
|
1
|
|
my($self, $index, $args) = @_; |
40
|
|
|
|
|
|
|
# require index |
41
|
0
|
0
|
|
|
|
|
die "Invalid Args" |
42
|
|
|
|
|
|
|
unless ref $index eq 'HASH'; |
43
|
|
|
|
|
|
|
# process args |
44
|
0
|
|
|
|
|
|
$args = $self->_build_args($args, \@PARAMS); |
45
|
|
|
|
|
|
|
# set collection name |
46
|
0
|
|
|
|
|
|
$args->{collection} = $self->collection->name; |
47
|
|
|
|
|
|
|
# make request |
48
|
0
|
0
|
|
|
|
|
my $res = $self->arango->http->post( |
49
|
|
|
|
|
|
|
$self->api_path('index'), |
50
|
|
|
|
|
|
|
$args, |
51
|
|
|
|
|
|
|
$JSON->encode($index), |
52
|
|
|
|
|
|
|
) or return; |
53
|
|
|
|
|
|
|
# get name from id |
54
|
0
|
0
|
|
|
|
|
my($name) = $res->{id} =~ m{/(\d+)$} |
55
|
|
|
|
|
|
|
or return; |
56
|
0
|
|
|
|
|
|
$self->{name} = $name; |
57
|
|
|
|
|
|
|
# copy response data to instance |
58
|
0
|
|
|
|
|
|
$self->_build_self($res, \@PARAMS); |
59
|
|
|
|
|
|
|
# register |
60
|
0
|
|
|
|
|
|
$self->collection->indexes->{$name} = $self; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# delete |
66
|
|
|
|
|
|
|
# |
67
|
|
|
|
|
|
|
# DELETE /_api/index/{index-handle} |
68
|
|
|
|
|
|
|
sub delete |
69
|
|
|
|
|
|
|
{ |
70
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
71
|
|
|
|
|
|
|
# make request |
72
|
0
|
0
|
|
|
|
|
my $res = $self->arango->http->delete( |
73
|
|
|
|
|
|
|
$self->api_path('index', $self->id), |
74
|
|
|
|
|
|
|
) or return; |
75
|
|
|
|
|
|
|
# remove from register |
76
|
0
|
|
|
|
|
|
delete $self->collection->indexes->{$self->name}; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return $res; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# fields |
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
# get/set fields |
84
|
0
|
|
|
0
|
1
|
|
sub fields { shift->_get_set('fields', @_) } |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# geoJson |
87
|
|
|
|
|
|
|
# |
88
|
|
|
|
|
|
|
# get/set geoJson value |
89
|
0
|
|
|
0
|
1
|
|
sub geoJson { shift->_get_set_bool('geoJson', @_) } |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# get |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# GET /_api/index/{index-handle} |
94
|
|
|
|
|
|
|
sub get |
95
|
|
|
|
|
|
|
{ |
96
|
0
|
|
|
0
|
1
|
|
my($self, $args) = @_; |
97
|
|
|
|
|
|
|
# process args |
98
|
0
|
|
|
|
|
|
$args = $self->_build_args($args, ['name']); |
99
|
|
|
|
|
|
|
# use either id or name |
100
|
0
|
0
|
|
|
|
|
my $id = $self->id |
101
|
|
|
|
|
|
|
? $self->id |
102
|
|
|
|
|
|
|
: join('/', $self->collection->name, delete $args->{name}); |
103
|
|
|
|
|
|
|
# make request |
104
|
0
|
0
|
|
|
|
|
my $res = $self->arango->http->get( |
105
|
|
|
|
|
|
|
$self->api_path('index', $id), |
106
|
|
|
|
|
|
|
) or return; |
107
|
|
|
|
|
|
|
# get name from id |
108
|
0
|
0
|
|
|
|
|
my($name) = $res->{id} =~ m{/(\d+)$} |
109
|
|
|
|
|
|
|
or return; |
110
|
0
|
|
|
|
|
|
$self->{name} = $name; |
111
|
|
|
|
|
|
|
# copy response data to instance |
112
|
0
|
|
|
|
|
|
$self->_build_self($res, \@PARAMS); |
113
|
|
|
|
|
|
|
# register |
114
|
0
|
|
|
|
|
|
$self->collection->indexes->{$name} = $self; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return $self; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# ignoreNull |
120
|
|
|
|
|
|
|
# |
121
|
|
|
|
|
|
|
# get/set ignoreNull value |
122
|
0
|
|
|
0
|
1
|
|
sub ignoreNull { shift->_get_set_bool('ignoreNull', @_) } |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# isNewlyCreated |
125
|
|
|
|
|
|
|
# |
126
|
|
|
|
|
|
|
# get isNewlyCreated value |
127
|
0
|
|
|
0
|
1
|
|
sub isNewlyCreated { $_[0]->{isNewlyCreated} } |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# list |
130
|
|
|
|
|
|
|
# |
131
|
|
|
|
|
|
|
# GET /_api/index |
132
|
|
|
|
|
|
|
sub list |
133
|
|
|
|
|
|
|
{ |
134
|
0
|
|
|
0
|
1
|
|
my($self, $args) = @_; |
135
|
|
|
|
|
|
|
# set default args |
136
|
0
|
|
0
|
|
|
|
$args ||= {}; |
137
|
|
|
|
|
|
|
# require valid args |
138
|
0
|
0
|
|
|
|
|
die 'Invalid Args' |
139
|
|
|
|
|
|
|
unless ref $args eq 'HASH'; |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
0
|
|
|
|
$args->{collection} ||= $self->collection->name; |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
return $self->arango->http->get( |
144
|
|
|
|
|
|
|
$self->api_path('index'), |
145
|
|
|
|
|
|
|
$args |
146
|
|
|
|
|
|
|
); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# minLength |
150
|
|
|
|
|
|
|
# |
151
|
|
|
|
|
|
|
# get/set minLength |
152
|
0
|
|
|
0
|
1
|
|
sub minLength { shift->_get_set('minLength', @_) } |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# size |
155
|
|
|
|
|
|
|
# |
156
|
|
|
|
|
|
|
# get/set size |
157
|
0
|
|
|
0
|
1
|
|
sub size { shift->_get_set('size', @_) } |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# type |
160
|
|
|
|
|
|
|
# |
161
|
|
|
|
|
|
|
# get/set type |
162
|
0
|
|
|
0
|
1
|
|
sub type { shift->_get_set('type', @_) } |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# unique |
165
|
|
|
|
|
|
|
# |
166
|
|
|
|
|
|
|
# get/set unique value |
167
|
0
|
|
|
0
|
1
|
|
sub unique { shift->_get_set_bool('unique', @_) } |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
__END__ |