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
|
|
1005
|
use 5.10.0; |
|
3
|
|
|
|
|
8
|
|
21
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
59
|
|
22
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
59
|
|
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
|
10
|
use Thrift; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
70
|
|
25
|
3
|
|
|
3
|
|
629
|
use Thrift::Transport; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
84
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
package Thrift::MemoryBuffer; |
28
|
3
|
|
|
3
|
|
14
|
use base('Thrift::Transport'); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
245
|
|
29
|
3
|
|
|
3
|
|
15
|
use version 0.77; our $VERSION = version->declare("$Thrift::VERSION"); |
|
3
|
|
|
|
|
31
|
|
|
3
|
|
|
|
|
13
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new |
32
|
|
|
|
|
|
|
{ |
33
|
7
|
|
|
7
|
0
|
224
|
my $classname = shift; |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
100
|
|
|
26
|
my $bufferSize= shift || 1024; |
36
|
|
|
|
|
|
|
|
37
|
7
|
|
|
|
|
22
|
my $self = { |
38
|
|
|
|
|
|
|
buffer => '', |
39
|
|
|
|
|
|
|
bufferSize => $bufferSize, |
40
|
|
|
|
|
|
|
wPos => 0, |
41
|
|
|
|
|
|
|
rPos => 0, |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
7
|
|
|
|
|
17
|
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
|
79
|
my $self = shift; |
72
|
4
|
|
|
|
|
45
|
return $self->{buffer}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub resetBuffer |
76
|
|
|
|
|
|
|
{ |
77
|
2
|
|
|
2
|
0
|
7
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
2
|
|
50
|
|
|
9
|
my $new_buffer = shift || ''; |
80
|
|
|
|
|
|
|
|
81
|
2
|
|
|
|
|
4
|
$self->{buffer} = $new_buffer; |
82
|
2
|
|
|
|
|
3
|
$self->{bufferSize} = length($new_buffer); |
83
|
2
|
|
|
|
|
5
|
$self->{wPos} = length($new_buffer); |
84
|
2
|
|
|
|
|
4
|
$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
|
224
|
my $self = shift; |
96
|
222
|
|
|
|
|
222
|
my $len = shift; |
97
|
222
|
|
|
|
|
217
|
my $ret; |
98
|
|
|
|
|
|
|
|
99
|
222
|
|
|
|
|
260
|
my $avail = ($self->{wPos} - $self->{rPos}); |
100
|
222
|
50
|
|
|
|
315
|
return '' if $avail == 0; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#how much to give |
103
|
222
|
|
|
|
|
221
|
my $give = $len; |
104
|
222
|
50
|
|
|
|
284
|
$give = $avail if $avail < $len; |
105
|
|
|
|
|
|
|
|
106
|
222
|
|
|
|
|
310
|
$ret = substr($self->{buffer},$self->{rPos},$give); |
107
|
|
|
|
|
|
|
|
108
|
222
|
|
|
|
|
226
|
$self->{rPos} += $give; |
109
|
|
|
|
|
|
|
|
110
|
222
|
|
|
|
|
496
|
return $ret; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub readAll |
114
|
|
|
|
|
|
|
{ |
115
|
223
|
|
|
223
|
0
|
234
|
my $self = shift; |
116
|
223
|
|
|
|
|
219
|
my $len = shift; |
117
|
|
|
|
|
|
|
|
118
|
223
|
|
|
|
|
280
|
my $avail = ($self->{wPos} - $self->{rPos}); |
119
|
223
|
100
|
|
|
|
318
|
if ($avail < $len) { |
120
|
1
|
|
|
|
|
8
|
die Thrift::TTransportException->new("Attempt to readAll($len) found only $avail available", |
121
|
|
|
|
|
|
|
Thrift::TTransportException::END_OF_FILE); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
222
|
|
|
|
|
242
|
my $data = ''; |
125
|
222
|
|
|
|
|
217
|
my $got = 0; |
126
|
|
|
|
|
|
|
|
127
|
222
|
|
|
|
|
313
|
while (($got = length($data)) < $len) { |
128
|
222
|
|
|
|
|
306
|
$data .= $self->read($len - $got); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
222
|
|
|
|
|
477
|
return $data; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub write |
135
|
|
|
|
|
|
|
{ |
136
|
226
|
|
|
226
|
0
|
242
|
my $self = shift; |
137
|
226
|
|
|
|
|
251
|
my $buf = shift; |
138
|
|
|
|
|
|
|
|
139
|
226
|
|
|
|
|
290
|
$self->{buffer} .= $buf; |
140
|
226
|
|
|
|
|
310
|
$self->{wPos} += length($buf); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub flush |
144
|
|
|
|
26
|
0
|
|
{ |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |