Given name of a region, returns its start key @throws IllegalArgumentException if the name of the region is malformed @param region_name Full region_name created in the constructor @return byte Array of the start key
(final byte[] region_name)
| 232 | * @return byte Array of the start key |
| 233 | */ |
| 234 | static byte[] startKeyFromRegionName(final byte[] region_name){ |
| 235 | int key_begin = 0; |
| 236 | int key_end= 1; |
| 237 | int comma = 0; |
| 238 | for (/**/; key_end < region_name.length; key_end++) { |
| 239 | if (region_name[key_end] == ',') { |
| 240 | comma++; |
| 241 | if (comma == 1){ |
| 242 | key_begin = key_end+1; |
| 243 | } |
| 244 | if (comma == 2){ |
| 245 | break; |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | // If reached the end and the string being returned is not empty |
| 251 | if (key_end == region_name.length && (comma == 2)) { |
| 252 | throw new IllegalArgumentException("Malformed region name, not enough" |
| 253 | + " commas: " + Bytes.pretty(region_name)); |
| 254 | } |
| 255 | |
| 256 | // Only return the string if region length is greater than 0 |
| 257 | if (key_end - key_begin > 0 && region_name.length > 0){ |
| 258 | return Arrays.copyOfRange(region_name, key_begin, key_end); |
| 259 | } |
| 260 | // Otherwise, return an empty string as start key aka this is the |
| 261 | // start key for the first region in the table. |
| 262 | else { |
| 263 | return EMPTY_ARRAY; |
| 264 | } |
| 265 | |
| 266 | } |
| 267 | |
| 268 | @Override |
| 269 | public int compareTo(final RegionInfo other) { |
no test coverage detected