private boolean locateFinished(RegionInfo region, byte[] endKey, boolean endKeyInclusive) { if (isEmptyStopRow(endKey)) { if (isEmptyStopRow(region.getEndKey())) { return true; } return false; } else { if (isEmptyStopRow(region.getEndKey())) { return true; } int c = Bytes.compareTo(endKey, region.getEndKey()); // 1. if the region contains endKey // 2. endKey is equal to the region's endKey and we do not want to include endKey. return c < 0 || c == 0 && !endKeyInclusive; } }
static boolean noMoreResultsForScan(Scan scan, RegionInfo info) { if (isEmptyStopRow(info.getEndKey())) { return true; } if (isEmptyStopRow(scan.getStopRow())) { return false; } int c = Bytes.compareTo(info.getEndKey(), scan.getStopRow()); // 1. if our stop row is less than the endKey of the region // 2. if our stop row is equal to the endKey of the region and we do not include the stop row // for scan. return c > 0 || (c == 0 && !scan.includeStopRow()); }
private RegionLocations locateRowInCache(TableCache tableCache, TableName tableName, byte[] row, int replicaId) { Map.Entry<byte[], RegionLocations> entry = tableCache.cache.floorEntry(row); if (entry == null) { return null; } RegionLocations locs = entry.getValue(); HRegionLocation loc = locs.getRegionLocation(replicaId); if (loc == null) { return null; } byte[] endKey = loc.getRegion().getEndKey(); if (isEmptyStopRow(endKey) || Bytes.compareTo(row, endKey) < 0) { if (LOG.isTraceEnabled()) { LOG.trace("Found {} in cache for {}, row='{}', locateType={}, replicaId={}", loc, tableName, Bytes.toStringBinary(row), RegionLocateType.CURRENT, replicaId); } return locs; } else { return null; } }
private RegionLocations locateRowBeforeInCache(TableCache tableCache, TableName tableName, byte[] row, int replicaId) { boolean isEmptyStopRow = isEmptyStopRow(row); Map.Entry<byte[], RegionLocations> entry = isEmptyStopRow ? tableCache.cache.lastEntry() : tableCache.cache.lowerEntry(row); if (entry == null) { return null; } RegionLocations locs = entry.getValue(); HRegionLocation loc = locs.getRegionLocation(replicaId); if (loc == null) { return null; } if (isEmptyStopRow(loc.getRegion().getEndKey()) || (!isEmptyStopRow && Bytes.compareTo(loc.getRegion().getEndKey(), row) >= 0)) { if (LOG.isTraceEnabled()) { LOG.trace("Found {} in cache for {}, row='{}', locateType={}, replicaId={}", loc, tableName, Bytes.toStringBinary(row), RegionLocateType.BEFORE, replicaId); } return locs; } else { return null; } }
static boolean noMoreResultsForReverseScan(Scan scan, RegionInfo info) { if (isEmptyStartRow(info.getStartKey())) { return true; } if (isEmptyStopRow(scan.getStopRow())) { return false; } // no need to test the inclusive of the stop row as the start key of a region is included in // the region. return Bytes.compareTo(info.getStartKey(), scan.getStopRow()) <= 0; }
private void assertLocs(List<CompletableFuture<RegionLocations>> futures) throws InterruptedException, ExecutionException { assertEquals(256, futures.size()); for (int i = 0; i < futures.size(); i++) { HRegionLocation loc = futures.get(i).get().getDefaultRegionLocation(); if (i == 0) { assertTrue(isEmptyStartRow(loc.getRegion().getStartKey())); } else { assertEquals(String.format("%02x", i), Bytes.toString(loc.getRegion().getStartKey())); } if (i == futures.size() - 1) { assertTrue(isEmptyStopRow(loc.getRegion().getEndKey())); } else { assertEquals(String.format("%02x", i + 1), Bytes.toString(loc.getRegion().getEndKey())); } } }
if (isEmptyStopRow(req.row)) { byte[] binaryTableName = tableName.getName(); metaStartKey = Arrays.copyOf(binaryTableName, binaryTableName.length + 1);
private boolean locateFinished(RegionInfo region, byte[] endKey, boolean endKeyInclusive) { if (isEmptyStopRow(endKey)) { if (isEmptyStopRow(region.getEndKey())) { return true; } return false; } else { if (isEmptyStopRow(region.getEndKey())) { return true; } int c = Bytes.compareTo(endKey, region.getEndKey()); // 1. if the region contains endKey // 2. endKey is equal to the region's endKey and we do not want to include endKey. return c < 0 || c == 0 && !endKeyInclusive; } }
static boolean noMoreResultsForScan(Scan scan, RegionInfo info) { if (isEmptyStopRow(info.getEndKey())) { return true; } if (isEmptyStopRow(scan.getStopRow())) { return false; } int c = Bytes.compareTo(info.getEndKey(), scan.getStopRow()); // 1. if our stop row is less than the endKey of the region // 2. if our stop row is equal to the endKey of the region and we do not include the stop row // for scan. return c > 0 || (c == 0 && !scan.includeStopRow()); }
private HRegionLocation locateRowInCache(TableCache tableCache, TableName tableName, byte[] row) { Map.Entry<byte[], HRegionLocation> entry = tableCache.cache.floorEntry(row); if (entry == null) { return null; } HRegionLocation loc = entry.getValue(); byte[] endKey = loc.getRegion().getEndKey(); if (isEmptyStopRow(endKey) || Bytes.compareTo(row, endKey) < 0) { if (LOG.isTraceEnabled()) { LOG.trace("Found " + loc + " in cache for '" + tableName + "', row='" + Bytes.toStringBinary(row) + "', locateType=" + RegionLocateType.CURRENT); } return loc; } else { return null; } }
private HRegionLocation locateRowBeforeInCache(TableCache tableCache, TableName tableName, byte[] row) { boolean isEmptyStopRow = isEmptyStopRow(row); Map.Entry<byte[], HRegionLocation> entry = isEmptyStopRow ? tableCache.cache.lastEntry() : tableCache.cache.lowerEntry(row); if (entry == null) { return null; } HRegionLocation loc = entry.getValue(); if (isEmptyStopRow(loc.getRegion().getEndKey()) || (!isEmptyStopRow && Bytes.compareTo(loc.getRegion().getEndKey(), row) >= 0)) { if (LOG.isTraceEnabled()) { LOG.trace("Found " + loc + " in cache for '" + tableName + "', row='" + Bytes.toStringBinary(row) + "', locateType=" + RegionLocateType.BEFORE); } return loc; } else { return null; } }
static boolean noMoreResultsForReverseScan(Scan scan, RegionInfo info) { if (isEmptyStartRow(info.getStartKey())) { return true; } if (isEmptyStopRow(scan.getStopRow())) { return false; } // no need to test the inclusive of the stop row as the start key of a region is included in // the region. return Bytes.compareTo(info.getStartKey(), scan.getStopRow()) <= 0; }
if (isEmptyStopRow(req.row)) { byte[] binaryTableName = tableName.getName(); metaStartKey = Arrays.copyOf(binaryTableName, binaryTableName.length + 1);
private boolean locateFinished(RegionInfo region, byte[] endKey, boolean endKeyInclusive) { if (isEmptyStopRow(endKey)) { if (isEmptyStopRow(region.getEndKey())) { return true; } return false; } else { if (isEmptyStopRow(region.getEndKey())) { return true; } int c = Bytes.compareTo(endKey, region.getEndKey()); // 1. if the region contains endKey // 2. endKey is equal to the region's endKey and we do not want to include endKey. return c < 0 || c == 0 && !endKeyInclusive; } }
static boolean noMoreResultsForScan(Scan scan, RegionInfo info) { if (isEmptyStopRow(info.getEndKey())) { return true; } if (isEmptyStopRow(scan.getStopRow())) { return false; } int c = Bytes.compareTo(info.getEndKey(), scan.getStopRow()); // 1. if our stop row is less than the endKey of the region // 2. if our stop row is equal to the endKey of the region and we do not include the stop row // for scan. return c > 0 || (c == 0 && !scan.includeStopRow()); }
private HRegionLocation locateRowInCache(TableCache tableCache, TableName tableName, byte[] row) { Map.Entry<byte[], HRegionLocation> entry = tableCache.cache.floorEntry(row); if (entry == null) { return null; } HRegionLocation loc = entry.getValue(); byte[] endKey = loc.getRegion().getEndKey(); if (isEmptyStopRow(endKey) || Bytes.compareTo(row, endKey) < 0) { if (LOG.isTraceEnabled()) { LOG.trace("Found " + loc + " in cache for '" + tableName + "', row='" + Bytes.toStringBinary(row) + "', locateType=" + RegionLocateType.CURRENT); } return loc; } else { return null; } }
private HRegionLocation locateRowBeforeInCache(TableCache tableCache, TableName tableName, byte[] row) { Map.Entry<byte[], HRegionLocation> entry = isEmptyStopRow(row) ? tableCache.cache.lastEntry() : tableCache.cache.lowerEntry(row); if (entry == null) { return null; } HRegionLocation loc = entry.getValue(); if (isEmptyStopRow(loc.getRegion().getEndKey()) || Bytes.compareTo(loc.getRegion().getEndKey(), row) >= 0) { if (LOG.isTraceEnabled()) { LOG.trace("Found " + loc + " in cache for '" + tableName + "', row='" + Bytes.toStringBinary(row) + "', locateType=" + RegionLocateType.BEFORE); } return loc; } else { return null; } }
static boolean noMoreResultsForReverseScan(Scan scan, RegionInfo info) { if (isEmptyStartRow(info.getStartKey())) { return true; } if (isEmptyStopRow(scan.getStopRow())) { return false; } // no need to test the inclusive of the stop row as the start key of a region is included in // the region. return Bytes.compareTo(info.getStartKey(), scan.getStopRow()) <= 0; }
private void assertLocs(List<CompletableFuture<HRegionLocation>> futures) throws InterruptedException, ExecutionException { assertEquals(256, futures.size()); for (int i = 0; i < futures.size(); i++) { HRegionLocation loc = futures.get(i).get(); if (i == 0) { assertTrue(isEmptyStartRow(loc.getRegion().getStartKey())); } else { assertEquals(String.format("%02x", i), Bytes.toString(loc.getRegion().getStartKey())); } if (i == futures.size() - 1) { assertTrue(isEmptyStopRow(loc.getRegion().getEndKey())); } else { assertEquals(String.format("%02x", i + 1), Bytes.toString(loc.getRegion().getEndKey())); } } }
if (isEmptyStopRow(req.row)) { byte[] binaryTableName = tableName.getName(); metaStartKey = Arrays.copyOf(binaryTableName, binaryTableName.length + 1);