@Test public void testOneRow() { byte[] rowKey = Bytes.toBytes("row"); List<KeyOffset> responses = new ArrayList<>(); responses.add(KeyOffset.create(ByteString.copyFrom(rowKey), 0)); List<HRegionLocation> locations = adapter.adaptResponse(responses); Assert.assertEquals(2, locations.size()); HRegionLocation location = locations.get(0); Assert.assertArrayEquals(HConstants.EMPTY_START_ROW, location.getRegionInfo().getStartKey()); Assert.assertArrayEquals(rowKey, location.getRegionInfo().getEndKey()); location = locations.get(1); Assert.assertArrayEquals(rowKey, location.getRegionInfo().getStartKey()); Assert.assertArrayEquals(HConstants.EMPTY_END_ROW, location.getRegionInfo().getEndKey()); }
public List<HRegionLocation> adaptResponse(List<KeyOffset> responses) { List<HRegionLocation> regions = new ArrayList<>(); byte[] startKey = HConstants.EMPTY_START_ROW; for (KeyOffset response : responses) { byte[] endKey = response.getKey().toByteArray(); if (Bytes.equals(startKey, endKey)) { continue; } regions.add(createRegionLocation(startKey, endKey)); startKey = endKey; } byte[] endKey = HConstants.EMPTY_END_ROW; if (regions.isEmpty() || !Bytes.equals(startKey, endKey)) { regions.add(createRegionLocation(startKey, endKey)); } return regions; }
SampledRowKeysAdapter { public List<HRegionLocation> adaptResponse(List<KeyOffset> responses) { List<HRegionLocation> regions = new ArrayList<>(); byte[] startKey = HConstants.EMPTY_START_ROW; for (KeyOffset response : responses) { byte[] endKey = response.getKey().toByteArray(); if (Bytes.equals(startKey, endKey)) { continue; } regions.add(createRegionLocation(startKey, endKey)); startKey = endKey; } byte[] endKey = HConstants.EMPTY_END_ROW; if (regions.isEmpty() || !Bytes.equals(startKey, endKey)) { regions.add(createRegionLocation(startKey, endKey)); } return regions; } }
SampledRowKeysAdapter { public List<HRegionLocation> adaptResponse(List<KeyOffset> responses) { List<HRegionLocation> regions = new ArrayList<>(); byte[] startKey = HConstants.EMPTY_START_ROW; for (KeyOffset response : responses) { byte[] endKey = response.getKey().toByteArray(); if (Bytes.equals(startKey, endKey)) { continue; } regions.add(createRegionLocation(startKey, endKey)); startKey = endKey; } byte[] endKey = HConstants.EMPTY_END_ROW; if (regions.isEmpty() || !Bytes.equals(startKey, endKey)) { regions.add(createRegionLocation(startKey, endKey)); } return regions; } SampledRowKeysAdapter(TableName tableName, ServerName serverName); }
SampledRowKeysAdapter { public List<HRegionLocation> adaptResponse(List<KeyOffset> responses) { List<HRegionLocation> regions = new ArrayList<>(); byte[] startKey = HConstants.EMPTY_START_ROW; for (KeyOffset response : responses) { byte[] endKey = response.getKey().toByteArray(); if (Bytes.equals(startKey, endKey)) { continue; } regions.add(createRegionLocation(startKey, endKey)); startKey = endKey; } byte[] endKey = HConstants.EMPTY_END_ROW; if (regions.isEmpty() || !Bytes.equals(startKey, endKey)) { regions.add(createRegionLocation(startKey, endKey)); } return regions; } SampledRowKeysAdapter(TableName tableName, ServerName serverName); List<HRegionLocation> adaptResponse(List<KeyOffset> responses); }
SampledRowKeysAdapter { public List<HRegionLocation> adaptResponse(List<KeyOffset> responses) { List<HRegionLocation> regions = new ArrayList<>(); byte[] startKey = HConstants.EMPTY_START_ROW; for (KeyOffset response : responses) { byte[] endKey = response.getKey().toByteArray(); if (Bytes.equals(startKey, endKey)) { continue; } regions.add(createRegionLocation(startKey, endKey)); startKey = endKey; } byte[] endKey = HConstants.EMPTY_END_ROW; if (regions.isEmpty() || !Bytes.equals(startKey, endKey)) { regions.add(createRegionLocation(startKey, endKey)); } return regions; } SampledRowKeysAdapter(TableName tableName, ServerName serverName); List<HRegionLocation> adaptResponse(List<KeyOffset> responses);  }