1
1
package com .navercorp .pinpoint .plugin .hbase .interceptor .data ;
2
2
3
+ import com .navercorp .pinpoint .common .util .ArrayUtils ;
3
4
import org .apache .hadoop .hbase .Cell ;
4
5
import org .apache .hadoop .hbase .client .Mutation ;
5
6
import org .apache .hadoop .hbase .client .Result ;
6
7
8
+ import java .util .Collection ;
7
9
import java .util .List ;
8
10
import java .util .Map ;
9
11
import java .util .NavigableMap ;
@@ -24,11 +26,11 @@ private DataSizeUtils() {
24
26
}
25
27
26
28
public static int sizeOfMutation (Mutation mutation ) {
27
- return mutation .getRow (). length + sumOfFamilyCellMap (mutation .getFamilyCellMap ());
29
+ return ArrayUtils . getLength ( mutation .getRow ()) + sumOfFamilyCellMap (mutation .getFamilyCellMap ());
28
30
}
29
31
30
32
public static int sizeOfResult (Result result ) {
31
- return result .getRow (). length + sumOfResultFamilyMap (result .getNoVersionMap ());
33
+ return ArrayUtils . getLength ( result .getRow ()) + sumOfResultFamilyMap (result .getNoVersionMap ());
32
34
}
33
35
34
36
public static int sumOfFamilyCellMap (NavigableMap <byte [], List <Cell >> map ) {
@@ -37,7 +39,7 @@ public static int sumOfFamilyCellMap(NavigableMap<byte[], List<Cell>> map) {
37
39
}
38
40
int sizeInByte = 0 ;
39
41
for (Map .Entry <byte [], List <Cell >> e : map .entrySet ()) {
40
- sizeInByte += e .getKey (). length ;
42
+ sizeInByte += ArrayUtils . getLength ( e .getKey ()) ;
41
43
for (Cell cell : e .getValue ()) {
42
44
sizeInByte += lengthOfCell (cell );
43
45
}
@@ -48,10 +50,10 @@ public static int sumOfFamilyCellMap(NavigableMap<byte[], List<Cell>> map) {
48
50
public static int sumOfResultFamilyMap (NavigableMap <byte [], NavigableMap <byte [], byte []>> map ) {
49
51
int sizeInByte = 0 ;
50
52
for (Map .Entry <byte [], NavigableMap <byte [], byte []>> familyToRest : map .entrySet ()) {
51
- sizeInByte += familyToRest .getKey (). length ;
53
+ sizeInByte += ArrayUtils . getLength ( familyToRest .getKey ()) ;
52
54
for (Map .Entry <byte [], byte []> qualifierToValue : familyToRest .getValue ().entrySet ()) {
53
- sizeInByte += qualifierToValue .getKey (). length ;
54
- sizeInByte += qualifierToValue .getValue (). length ;
55
+ sizeInByte += ArrayUtils . getLength ( qualifierToValue .getKey ()) ;
56
+ sizeInByte += ArrayUtils . getLength ( qualifierToValue .getValue ()) ;
55
57
}
56
58
}
57
59
return sizeInByte ;
0 commit comments