line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one |
3
|
|
|
|
|
|
|
# or more contributor license agreements. See the NOTICE file |
4
|
|
|
|
|
|
|
# distributed with this work for additional information |
5
|
|
|
|
|
|
|
# regarding copyright ownership. The ASF licenses this file |
6
|
|
|
|
|
|
|
# to you under the Apache License, Version 2.0 (the |
7
|
|
|
|
|
|
|
# "License"); you may not use this file except in compliance |
8
|
|
|
|
|
|
|
# with the License. You may obtain a copy of the License at |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, |
13
|
|
|
|
|
|
|
# software distributed under the License is distributed on an |
14
|
|
|
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
15
|
|
|
|
|
|
|
# KIND, either express or implied. See the License for the |
16
|
|
|
|
|
|
|
# specific language governing permissions and limitations |
17
|
|
|
|
|
|
|
# under the License. |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
3
|
|
1224
|
use 5.10.0; |
|
3
|
|
|
|
|
11
|
|
21
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
72
|
|
22
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
70
|
|
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
|
15
|
use Thrift; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
87
|
|
25
|
3
|
|
|
3
|
|
750
|
use Thrift::Transport; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
147
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
package Thrift::MemoryBuffer; |
28
|
3
|
|
|
3
|
|
18
|
use base('Thrift::Transport'); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
295
|
|
29
|
3
|
|
|
3
|
|
18
|
use version 0.77; our $VERSION = version->declare("$Thrift::VERSION"); |
|
3
|
|
|
|
|
38
|
|
|
3
|
|
|
|
|
20
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new |
32
|
|
|
|
|
|
|
{ |
33
|
7
|
|
|
7
|
0
|
268
|
my $classname = shift; |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
100
|
|
|
31
|
my $bufferSize= shift || 1024; |
36
|
|
|
|
|
|
|
|
37
|
7
|
|
|
|
|
27
|
my $self = { |
38
|
|
|
|
|
|
|
buffer => '', |
39
|
|
|
|
|
|
|
bufferSize => $bufferSize, |
40
|
|
|
|
|
|
|
wPos => 0, |
41
|
|
|
|
|
|
|
rPos => 0, |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
7
|
|
|
|
|
22
|
return bless($self,$classname); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub isOpen |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
0
|
0
|
0
|
return 1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub open |
53
|
|
|
|
2
|
0
|
|
{ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub close |
58
|
|
|
|
0
|
0
|
|
{ |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub peek |
63
|
|
|
|
|
|
|
{ |
64
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
65
|
0
|
|
|
|
|
0
|
return($self->{rPos} < $self->{wPos}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub getBuffer |
70
|
|
|
|
|
|
|
{ |
71
|
4
|
|
|
4
|
0
|
91
|
my $self = shift; |
72
|
4
|
|
|
|
|
66
|
return $self->{buffer}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub resetBuffer |
76
|
|
|
|
|
|
|
{ |
77
|
2
|
|
|
2
|
0
|
9
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
2
|
|
50
|
|
|
9
|
my $new_buffer = shift || ''; |
80
|
|
|
|
|
|
|
|
81
|
2
|
|
|
|
|
6
|
$self->{buffer} = $new_buffer; |
82
|
2
|
|
|
|
|
6
|
$self->{bufferSize} = length($new_buffer); |
83
|
2
|
|
|
|
|
4
|
$self->{wPos} = length($new_buffer); |
84
|
2
|
|
|
|
|
5
|
$self->{rPos} = 0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub available |
88
|
|
|
|
|
|
|
{ |
89
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
90
|
0
|
|
|
|
|
0
|
return ($self->{wPos} - $self->{rPos}); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub read |
94
|
|
|
|
|
|
|
{ |
95
|
222
|
|
|
222
|
0
|
279
|
my $self = shift; |
96
|
222
|
|
|
|
|
270
|
my $len = shift; |
97
|
222
|
|
|
|
|
280
|
my $ret; |
98
|
|
|
|
|
|
|
|
99
|
222
|
|
|
|
|
388
|
my $avail = ($self->{wPos} - $self->{rPos}); |
100
|
222
|
50
|
|
|
|
390
|
return '' if $avail == 0; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#how much to give |
103
|
222
|
|
|
|
|
283
|
my $give = $len; |
104
|
222
|
50
|
|
|
|
344
|
$give = $avail if $avail < $len; |
105
|
|
|
|
|
|
|
|
106
|
222
|
|
|
|
|
416
|
$ret = substr($self->{buffer},$self->{rPos},$give); |
107
|
|
|
|
|
|
|
|
108
|
222
|
|
|
|
|
277
|
$self->{rPos} += $give; |
109
|
|
|
|
|
|
|
|
110
|
222
|
|
|
|
|
615
|
return $ret; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub readAll |
114
|
|
|
|
|
|
|
{ |
115
|
223
|
|
|
223
|
0
|
314
|
my $self = shift; |
116
|
223
|
|
|
|
|
275
|
my $len = shift; |
117
|
|
|
|
|
|
|
|
118
|
223
|
|
|
|
|
377
|
my $avail = ($self->{wPos} - $self->{rPos}); |
119
|
223
|
100
|
|
|
|
395
|
if ($avail < $len) { |
120
|
1
|
|
|
|
|
11
|
die Thrift::TTransportException->new("Attempt to readAll($len) found only $avail available", |
121
|
|
|
|
|
|
|
Thrift::TTransportException::END_OF_FILE); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
222
|
|
|
|
|
296
|
my $data = ''; |
125
|
222
|
|
|
|
|
266
|
my $got = 0; |
126
|
|
|
|
|
|
|
|
127
|
222
|
|
|
|
|
382
|
while (($got = length($data)) < $len) { |
128
|
222
|
|
|
|
|
407
|
$data .= $self->read($len - $got); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
222
|
|
|
|
|
584
|
return $data; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub write |
135
|
|
|
|
|
|
|
{ |
136
|
226
|
|
|
226
|
0
|
319
|
my $self = shift; |
137
|
226
|
|
|
|
|
296
|
my $buf = shift; |
138
|
|
|
|
|
|
|
|
139
|
226
|
|
|
|
|
372
|
$self->{buffer} .= $buf; |
140
|
226
|
|
|
|
|
397
|
$self->{wPos} += length($buf); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub flush |
144
|
|
|
|
26
|
0
|
|
{ |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |