RowKeyUtil { public static RowKey getEndRowKeyOfPrefix(RowKey prefixRowKey) { Util.checkRowKey(prefixRowKey); byte[] rowkeyBytes = prefixRowKey.toBytes(); Util.check(rowkeyBytes.length != 0); boolean isAllByteIsFF = true; for (byte b : rowkeyBytes) { if ((b & 0xFF) != 0xFF) { isAllByteIsFF = false; break; } } if (isAllByteIsFF) { throw new SimpleHBaseException( "the prefix row key is all of 0xFF. prefixRowKey=" + prefixRowKey); } return new BytesRowKey(BytesUtil.increaseLastByte(rowkeyBytes)); }  static RowKey appendZeroToRowKey(RowKey rowKey); static RowKey getEndRowKeyOfPrefix(RowKey prefixRowKey); static RowKey START_ROW; static RowKey END_ROW; }
@Test public void getEndRowKeyOfPrefix() { try { RowKeyUtil.getEndRowKeyOfPrefix(null); Assert.fail(); } catch (Exception e) { } try { RowKeyUtil.getEndRowKeyOfPrefix(new StringRowKey("")); Assert.fail(); } catch (Exception e) { } try { RowKeyUtil.getEndRowKeyOfPrefix(new BytesRowKey(new HexBytes("FF") .getData())); Assert.fail(); } catch (Exception e) { } try { RowKeyUtil.getEndRowKeyOfPrefix(new BytesRowKey(new HexBytes( "FF FF").getData())); Assert.fail(); } catch (Exception e) { } RowKey endRowKey = RowKeyUtil.getEndRowKeyOfPrefix(new BytesRowKey( new HexBytes("FF AB ").getData())); Assert.assertEquals("FF AC ", EncodingUtil.toHexString(endRowKey.toBytes())); }