HBaseUtils { public static byte[] exclusiveStopRow(byte[] startRow) { byte[] stopRow = startRow.clone(); for (int i = stopRow.length - 1; i >= 0; i--) { if (stopRow[i] < Byte.MAX_VALUE) { stopRow[i] += 1; return stopRow; } stopRow[i] = 0; if (i == 0) { return HConstants.EMPTY_BYTE_ARRAY; } } return stopRow; }  synchronized static Connection getConnection(Config config); static Configuration getHBaseConfiguration(Config config); static int batchSizeFor(Config config); static TableName tableInfoFor(Config config); static HBaseSerde getSerde(Config config); static byte[] rowKeySeparatorFor(Config config); static List<String> rowKeyFor(Config config); static Map<String, HBaseSerde.ColumnDef> columnsFor(Config config); static StructType buildSchema(Map<String, HBaseSerde.ColumnDef> columnDefinitions); static Scan mergeRangeScans(List<Scan> rangeScans); static byte[] exclusiveStopRow(byte[] startRow); static Validations getValidations(); static final String ZK_QUORUM_PROPERTY; static final String TABLE_NAME_PROPERTY; static final String ROWKEY_PROPERTY; static final String KEY_SEPARATOR; static final String COLUMNS_PROPERTY; static final String SERDE_PROPERTY; static final String HBASE_PASSTHRU_PREFIX; static final String HBASE_BATCH_SIZE; static final int DEFAULT_HBASE_BATCH_SIZE; static final String DEFAULT_SERDE_PROPERTY; static final String DEFAULT_KEY_SEPARATOR; }
@Test public void testExclusiveStopRowForLowestStartRow() { byte[] startRow = {0, 0, 0}; byte[] stopRow = HBaseUtils.exclusiveStopRow(startRow); assertEquals(ByteBuffer.wrap(stopRow), ByteBuffer.wrap(new byte[] {0, 0, 1})); }
@Test public void testExclusiveStopRowForTypicalStartRow() { byte[] startRow = Bytes.toBytes("hello"); byte[] stopRow = HBaseUtils.exclusiveStopRow(startRow); assertEquals(ByteBuffer.wrap(stopRow), ByteBuffer.wrap(Bytes.toBytes("hellp"))); }
@Test public void testExclusiveStopRowForFinalHighByteStartRow() { byte[] startRow = {64, 96, 127}; byte[] stopRow = HBaseUtils.exclusiveStopRow(startRow); assertEquals(ByteBuffer.wrap(stopRow), ByteBuffer.wrap(new byte[] {64, 97, 0})); }
@Test public void testExclusiveStopRowForHighestStartRow() { byte[] startRow = {127, 127, 127}; byte[] stopRow = HBaseUtils.exclusiveStopRow(startRow); assertEquals(ByteBuffer.wrap(stopRow), ByteBuffer.wrap(HConstants.EMPTY_BYTE_ARRAY)); }