line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Couchbase::Client; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
BEGIN { |
4
|
4
|
|
|
4
|
|
33157
|
require XSLoader; |
5
|
4
|
|
|
|
|
8
|
our $VERSION = '2.0.0_1'; |
6
|
4
|
|
|
|
|
3974
|
XSLoader::load(__PACKAGE__, $VERSION); |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
104
|
|
10
|
4
|
|
|
4
|
|
15
|
use warnings; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
96
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
1482
|
use Couchbase::Client::Errors; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
468
|
|
13
|
4
|
|
|
4
|
|
1540
|
use Couchbase::Client::IDXConst; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
922
|
|
14
|
4
|
|
|
4
|
|
1975
|
use Couchbase::Client::Return; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
152
|
|
15
|
4
|
|
|
4
|
|
1841
|
use Couchbase::Client::Iterator; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
141
|
|
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
1376
|
my $have_storable = eval "use Storable; 1;"; |
|
4
|
|
|
|
|
5572
|
|
|
4
|
|
|
|
|
260
|
|
18
|
4
|
|
|
4
|
|
2582
|
my $have_zlib = eval "use Compress::Zlib; 1;"; |
|
4
|
|
|
|
|
206696
|
|
|
4
|
|
|
|
|
990
|
|
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
4
|
|
2007
|
use Array::Assign; |
|
4
|
|
|
|
|
2842
|
|
|
4
|
|
|
|
|
245
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
4
|
|
|
4
|
|
19
|
no warnings 'once'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
259
|
|
24
|
|
|
|
|
|
|
*gets = \&get; |
25
|
|
|
|
|
|
|
*gets_multi = \&get_multi; |
26
|
|
|
|
|
|
|
*gets_multi_A = \&get_multi_A; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
*delete_multi = \&remove_multi; |
29
|
|
|
|
|
|
|
*delete_multi_A = \&remove_multi_A; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Get the CouchDB (2.0) API |
33
|
4
|
|
|
4
|
|
1754
|
use Couchbase::Couch::Base; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
133
|
|
34
|
4
|
|
|
4
|
|
19
|
use base qw(Couchbase::Couch::Base); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
3585
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#this function converts hash options for compression and serialization |
37
|
|
|
|
|
|
|
#to something suitable for construct() |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _make_conversion_settings { |
40
|
0
|
|
|
0
|
|
|
my ($arglist,$options) = @_; |
41
|
0
|
|
|
|
|
|
my $flags = 0; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
0
|
|
0
|
|
|
|
$arglist->[CTORIDX_MYFLAGS] ||= 0; |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if($options->{dereference_scalar_ref}) { |
47
|
0
|
|
|
|
|
|
$arglist->[CTORIDX_MYFLAGS] |= fDEREF_RVPV; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if(exists $options->{deconversion}) { |
51
|
0
|
0
|
|
|
|
|
if(! delete $options->{deconversion}) { |
52
|
0
|
|
|
|
|
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} else { |
55
|
0
|
|
|
|
|
|
$flags |= fDECONVERT; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
if(exists $options->{compress_threshold}) { |
59
|
0
|
|
|
|
|
|
my $compress_threshold = delete $options->{compress_threshold}; |
60
|
0
|
0
|
0
|
|
|
|
$compress_threshold = |
61
|
|
|
|
|
|
|
(!$compress_threshold || $compress_threshold < 0) |
62
|
|
|
|
|
|
|
? 0 : $compress_threshold; |
63
|
0
|
|
|
|
|
|
$arglist->[CTORIDX_COMP_THRESHOLD] = $compress_threshold; |
64
|
0
|
0
|
|
|
|
|
if($compress_threshold) { |
65
|
0
|
|
|
|
|
|
$flags |= fUSE_COMPRESSION; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $meth_comp; |
70
|
0
|
0
|
|
|
|
|
if(exists $options->{compress_methods}) { |
|
|
0
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$meth_comp = delete $options->{compress_methods}; |
72
|
|
|
|
|
|
|
} elsif($have_zlib) { |
73
|
0
|
|
|
0
|
|
|
$meth_comp = [ sub { ${$_[1]} = Compress::Zlib::memGzip(${$_[0]}) }, |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
74
|
0
|
|
|
0
|
|
|
sub { ${$_[1]} = Compress::Zlib::memGunzip(${$_[0]}) }] |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
if(defined $meth_comp) { |
78
|
0
|
|
|
|
|
|
$arglist->[CTORIDX_COMP_METHODS] = $meth_comp; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $meth_serialize = 0; |
82
|
0
|
0
|
|
|
|
|
if(exists $options->{serialize_methods}) { |
83
|
0
|
|
|
|
|
|
$meth_serialize = delete $options->{serialize_methods}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
0
|
|
|
|
if($meth_serialize == 0 && $have_storable) { |
87
|
0
|
|
|
|
|
|
$meth_serialize = [ \&Storable::freeze, \&Storable::thaw ]; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
if($meth_serialize) { |
91
|
0
|
|
|
|
|
|
$flags |= fUSE_STORABLE; |
92
|
0
|
|
|
|
|
|
$arglist->[CTORIDX_SERIALIZE_METHODS] = $meth_serialize; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
$arglist->[CTORIDX_MYFLAGS] |= $flags; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _MkCtorIDX { |
99
|
0
|
|
|
0
|
|
|
my $opts = shift; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my @arglist; |
102
|
0
|
0
|
|
|
|
|
my $server = delete $opts->{server} or die "Must have server"; |
103
|
0
|
|
|
|
|
|
arry_assign_i(@arglist, |
104
|
|
|
|
|
|
|
CTORIDX_SERVERS, $server, |
105
|
|
|
|
|
|
|
CTORIDX_USERNAME, delete $opts->{username}, |
106
|
|
|
|
|
|
|
CTORIDX_PASSWORD, delete $opts->{password}, |
107
|
|
|
|
|
|
|
CTORIDX_BUCKET, delete $opts->{bucket}); |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
_make_conversion_settings(\@arglist, $opts); |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
0
|
|
|
|
my $tmp = delete $opts->{io_timeout} || |
112
|
|
|
|
|
|
|
delete $opts->{select_timeout} || |
113
|
|
|
|
|
|
|
delete $opts->{connect_timeout} || |
114
|
|
|
|
|
|
|
delete $opts->{timeout}; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
0
|
|
|
|
$tmp ||= 2.5; |
117
|
0
|
0
|
|
|
|
|
$arglist[CTORIDX_TIMEOUT] = $tmp if defined $tmp; |
118
|
0
|
|
|
|
|
|
$arglist[CTORIDX_NO_CONNECT] = delete $opts->{no_init_connect}; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
if(keys %$opts) { |
122
|
0
|
|
|
|
|
|
warn sprintf("Unused keys (%s) in constructor", |
123
|
|
|
|
|
|
|
join(", ", keys %$opts)); |
124
|
|
|
|
|
|
|
} |
125
|
0
|
|
|
|
|
|
__PACKAGE__->_CouchCtorInit(\@arglist); |
126
|
0
|
|
|
|
|
|
return \@arglist; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub new { |
130
|
0
|
|
|
0
|
1
|
|
my ($pkg,$opts) = @_; |
131
|
0
|
|
|
|
|
|
my $server_str; |
132
|
0
|
|
0
|
|
|
|
my $server_spec = $opts->{servers} || $opts->{server}; |
133
|
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
if (ref $server_spec eq 'ARRAY') { |
135
|
0
|
|
|
|
|
|
$server_str = join(";", @$server_spec); |
136
|
|
|
|
|
|
|
} else { |
137
|
0
|
|
|
|
|
|
$server_str = $server_spec; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
0
|
0
|
|
|
|
|
if (!$server_str) { |
141
|
0
|
|
|
|
|
|
die("Must have 'servers' or 'server'"); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
my $privopts = { %$opts }; |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
$privopts->{server} = $server_str; |
147
|
0
|
|
|
|
|
|
delete $privopts->{servers}; |
148
|
0
|
|
|
|
|
|
my $arglist = _MkCtorIDX($privopts); |
149
|
0
|
|
|
|
|
|
my $self = $pkg->construct($arglist); |
150
|
0
|
|
|
|
|
|
return $self; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
#This is called from within C to record our stats: |
154
|
|
|
|
|
|
|
sub _stats_helper { |
155
|
0
|
|
|
0
|
|
|
my ($hash,$server,$key,$data) = @_; |
156
|
|
|
|
|
|
|
#printf("Got server %s, key%s\n", $server, $key); |
157
|
0
|
|
0
|
|
|
|
$key ||= "__default__"; |
158
|
0
|
|
0
|
|
|
|
($hash->{$server}->{$key} ||= "") .= $data; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
__END__ |