| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.apache.hadoop.hive.hbase; |
| 20 |
|
|
| 21 |
|
import java.util.ArrayList; |
| 22 |
|
import java.util.Collection; |
| 23 |
|
import java.util.HashMap; |
| 24 |
|
import java.util.List; |
| 25 |
|
import java.util.Map; |
| 26 |
|
|
| 27 |
|
import org.apache.hadoop.hbase.util.Bytes; |
| 28 |
|
import org.apache.hadoop.hive.ql.stats.StatsSetupConst; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 11 |
Complexity Density: 0.58 |
|
| 32 |
|
public class HBaseStatsUtils { |
| 33 |
|
|
| 34 |
|
private static final List<String> supportedStats = new ArrayList<String>(); |
| 35 |
|
private static final Map<String, String> columnNameMapping = new HashMap<String, String>(); |
| 36 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 37 |
0
|
static {... |
| 38 |
|
|
| 39 |
0
|
supportedStats.add(StatsSetupConst.ROW_COUNT); |
| 40 |
0
|
supportedStats.add(StatsSetupConst.RAW_DATA_SIZE); |
| 41 |
|
|
| 42 |
|
|
| 43 |
0
|
columnNameMapping.put(StatsSetupConst.ROW_COUNT, |
| 44 |
|
HBaseStatsSetupConstants.PART_STAT_ROW_COUNT_COLUMN_NAME); |
| 45 |
|
|
| 46 |
|
|
| 47 |
0
|
columnNameMapping.put(StatsSetupConst.RAW_DATA_SIZE, |
| 48 |
|
HBaseStatsSetupConstants.PART_STAT_RAW_DATA_SIZE_COLUMN_NAME); |
| 49 |
|
|
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 55 |
0
|
public static List<String> getSupportedStatistics() {... |
| 56 |
0
|
return supportedStats; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
@param |
| 63 |
|
|
| 64 |
|
@param |
| 65 |
|
|
| 66 |
|
@return |
| 67 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 68 |
0
|
public static String getStatFromMap(String statType, Map<String, String> stats) {... |
| 69 |
0
|
String value = stats.get(statType); |
| 70 |
0
|
if (value == null) { |
| 71 |
0
|
return "0"; |
| 72 |
|
} |
| 73 |
0
|
return value; |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
@param |
| 81 |
|
|
| 82 |
|
@return |
| 83 |
|
|
| 84 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 85 |
0
|
public static boolean isValidStatisticSet(Collection<String> stats) {... |
| 86 |
0
|
if(!stats.contains(getBasicStat())) { |
| 87 |
0
|
return false; |
| 88 |
|
} |
| 89 |
0
|
for (String stat : stats) { |
| 90 |
0
|
if (!supportedStats.contains(stat)) { |
| 91 |
0
|
return false; |
| 92 |
|
} |
| 93 |
|
} |
| 94 |
0
|
return true; |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
@param |
| 101 |
|
|
| 102 |
|
@return |
| 103 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 104 |
0
|
public static boolean isValidStatistic(String statType) {... |
| 105 |
0
|
return supportedStats.contains(statType); |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
@param |
| 112 |
|
|
| 113 |
|
@return |
| 114 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 115 |
0
|
public static byte[] getColumnName(String statType) {... |
| 116 |
0
|
return Bytes.toBytes(columnNameMapping.get(statType)); |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 122 |
0
|
public static byte[] getFamilyName() {... |
| 123 |
0
|
return Bytes.toBytes(HBaseStatsSetupConstants.PART_STAT_COLUMN_FAMILY); |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 131 |
0
|
public static String getBasicStat() {... |
| 132 |
0
|
return supportedStats.get(0); |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
} |