line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: ArangoDB Cursor object |
2
|
|
|
|
|
|
|
package Arango::Tango::Cursor; |
3
|
|
|
|
|
|
|
$Arango::Tango::Cursor::VERSION = '0.018'; |
4
|
5
|
|
|
5
|
|
35
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
163
|
|
5
|
5
|
|
|
5
|
|
27
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
115
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
3076
|
use Data::Dumper; |
|
5
|
|
|
|
|
30961
|
|
|
5
|
|
|
|
|
1915
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _new { |
10
|
0
|
|
|
0
|
|
|
my ($class, %opts) = @_; |
11
|
0
|
|
|
|
|
|
my $self = { arango => $opts{arango}, database => $opts{database} }; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my $ans = $self->{arango}->_api('create_cursor', \%opts); |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
return bless { %$ans, %$self, __current => 0 } => $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub next { |
19
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
0
|
|
|
|
if (!$self->{error} && $self->{__current} == 0) { |
22
|
0
|
|
|
|
|
|
$self->{__current}++; |
23
|
0
|
|
|
|
|
|
return $self->{result}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
if ($self->{hasMore}) { |
27
|
0
|
|
|
|
|
|
my $ans = $self->{arango}->_api('cursor_next', { database => $self->{database}, id => $self->{id} }); |
28
|
0
|
0
|
|
|
|
|
if (!$ans->{error}) { |
29
|
0
|
|
|
|
|
|
$self->{hasMore} = $ans->{hasMore}; |
30
|
0
|
|
|
|
|
|
return $ans->{result}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return undef; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub finish { |
38
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
39
|
0
|
0
|
|
|
|
|
if (exists($self->{id})) { |
40
|
0
|
|
|
|
|
|
$self->{arango}->_api('cursor_delete', { database => $self->{database}, id => $self->{id} }); |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
delete $self->{$_} for (keys %$self); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub has_more { |
46
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
47
|
0
|
|
|
|
|
|
return $self->{hasMore}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |