1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.transport;
12
13 import org.eclipse.jgit.lib.Constants;
14
15
16
17
18
19
20 public class ReceivedPackStatistics {
21 private long numBytesRead;
22 private long numBytesDuplicated;
23
24 private long numWholeCommit;
25 private long numWholeTree;
26 private long numWholeBlob;
27 private long numWholeTag;
28 private long numOfsDelta;
29 private long numRefDelta;
30 private long numObjectsDuplicated;
31
32 private long numDeltaCommit;
33 private long numDeltaTree;
34 private long numDeltaBlob;
35 private long numDeltaTag;
36
37
38
39
40
41
42 public long getNumBytesRead() {
43 return numBytesRead;
44 }
45
46
47
48
49
50
51
52
53 public long getNumBytesDuplicated() {
54 return numBytesDuplicated;
55 }
56
57
58
59
60
61
62 public long getNumWholeCommit() {
63 return numWholeCommit;
64 }
65
66
67
68
69
70
71 public long getNumWholeTree() {
72 return numWholeTree;
73 }
74
75
76
77
78
79
80 public long getNumWholeBlob() {
81 return numWholeBlob;
82 }
83
84
85
86
87
88
89 public long getNumWholeTag() {
90 return numWholeTag;
91 }
92
93
94
95
96
97
98 public long getNumOfsDelta() {
99 return numOfsDelta;
100 }
101
102
103
104
105
106
107 public long getNumRefDelta() {
108 return numRefDelta;
109 }
110
111
112
113
114
115
116
117
118 public long getNumObjectsDuplicated() {
119 return numObjectsDuplicated;
120 }
121
122
123
124
125
126
127 public long getNumDeltaCommit() {
128 return numDeltaCommit;
129 }
130
131
132
133
134
135
136 public long getNumDeltaTree() {
137 return numDeltaTree;
138 }
139
140
141
142
143
144
145 public long getNumDeltaBlob() {
146 return numDeltaBlob;
147 }
148
149
150
151
152
153
154 public long getNumDeltaTag() {
155 return numDeltaTag;
156 }
157
158
159 public static class Builder {
160 private long numBytesRead;
161 private long numBytesDuplicated;
162
163 private long numWholeCommit;
164 private long numWholeTree;
165 private long numWholeBlob;
166 private long numWholeTag;
167 private long numOfsDelta;
168 private long numRefDelta;
169 private long numObjectsDuplicated;
170
171 private long numDeltaCommit;
172 private long numDeltaTree;
173 private long numDeltaBlob;
174 private long numDeltaTag;
175
176
177
178
179
180 public Builder setNumBytesRead(long numBytesRead) {
181 this.numBytesRead = numBytesRead;
182 return this;
183 }
184
185
186
187
188
189
190
191 Builder incrementNumBytesDuplicated(long size) {
192 numBytesDuplicated += size;
193 return this;
194 }
195
196
197
198
199
200
201
202 public Builder addWholeObject(int type) {
203 switch (type) {
204 case Constants.OBJ_COMMIT:
205 numWholeCommit++;
206 break;
207 case Constants.OBJ_TREE:
208 numWholeTree++;
209 break;
210 case Constants.OBJ_BLOB:
211 numWholeBlob++;
212 break;
213 case Constants.OBJ_TAG:
214 numWholeTag++;
215 break;
216 default:
217 throw new IllegalArgumentException(
218 type + " cannot be a whole object");
219 }
220 return this;
221 }
222
223
224 public Builder addOffsetDelta() {
225 numOfsDelta++;
226 return this;
227 }
228
229
230 public Builder addRefDelta() {
231 numRefDelta++;
232 return this;
233 }
234
235
236
237
238
239
240
241 Builder incrementObjectsDuplicated() {
242 numObjectsDuplicated++;
243 return this;
244 }
245
246
247
248
249
250
251
252 public Builder addDeltaObject(int type) {
253 switch (type) {
254 case Constants.OBJ_COMMIT:
255 numDeltaCommit++;
256 break;
257 case Constants.OBJ_TREE:
258 numDeltaTree++;
259 break;
260 case Constants.OBJ_BLOB:
261 numDeltaBlob++;
262 break;
263 case Constants.OBJ_TAG:
264 numDeltaTag++;
265 break;
266 default:
267 throw new IllegalArgumentException(
268 "delta should be a delta to a whole object. " +
269 type + " cannot be a whole object");
270 }
271 return this;
272 }
273
274 ReceivedPackStatistics build() {
275 ReceivedPackStatistics s = new ReceivedPackStatistics();
276 s.numBytesRead = numBytesRead;
277 s.numBytesDuplicated = numBytesDuplicated;
278 s.numWholeCommit = numWholeCommit;
279 s.numWholeTree = numWholeTree;
280 s.numWholeBlob = numWholeBlob;
281 s.numWholeTag = numWholeTag;
282 s.numOfsDelta = numOfsDelta;
283 s.numRefDelta = numRefDelta;
284 s.numDeltaCommit = numDeltaCommit;
285 s.numDeltaTree = numDeltaTree;
286 s.numDeltaBlob = numDeltaBlob;
287 s.numDeltaTag = numDeltaTag;
288 s.numObjectsDuplicated = numObjectsDuplicated;
289 return s;
290 }
291 }
292 }