HBASE-998 Narrow getClosestRowBefore by passing column family

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@713886 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-11-14 00:43:48 +00:00
parent 67fc6fdb02
commit 8e24a9fa03
6 changed files with 46 additions and 32 deletions

View File

@ -116,6 +116,7 @@ Release 0.19.0 - Unreleased
MR Jobs (Billy Pearson via Stack)
HBASE-993 Turn of logging of every catalog table row entry on every scan
HBASE-992 Up the versions kept by catalog tables; currently 1. Make it 10?
HBASE-998 Narrow getClosestRowBefore by passing column family
NEW FEATURES
HBASE-875 Use MurmurHash instead of JenkinsHash [in bloomfilters]

View File

@ -493,9 +493,10 @@ public class HConnectionManager implements HConstants {
HRegionInterface server =
getHRegionConnection(metaLocation.getServerAddress());
// query the root region for the location of the meta region
// Query the root region for the location of the meta region
RowResult regionInfoRow = server.getClosestRowBefore(
metaLocation.getRegionInfo().getRegionName(), metaKey);
metaLocation.getRegionInfo().getRegionName(), metaKey,
HConstants.COLUMN_FAMILY);
if (regionInfoRow == null) {
throw new TableNotFoundException(Bytes.toString(tableName));

View File

@ -60,8 +60,9 @@ public interface HBaseRPCProtocolVersion extends VersionedProtocol {
* <p>Unified RPC version number history:
* <ul>
* <li>Version 10: initial version (had to be &gt all other RPC versions</li>
* <li>Version 11: Changed getClosestRowBefore signature.
* </ul>
*/
public static final long versionID = 10L;
public static final long versionID = 11L;
}

View File

@ -70,11 +70,12 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion {
*
* @param regionName region name
* @param row row key
* @param columnFamily Column family to look for row in.
* @return map of values
* @throws IOException
*/
public RowResult getClosestRowBefore(final byte [] regionName,
final byte [] row)
final byte [] row, final byte [] columnFamily)
throws IOException;
/**

View File

@ -121,7 +121,8 @@ public class HRegion implements HConstants {
private final Map<Integer, TreeMap<HStoreKey, byte []>> targetColumns =
new ConcurrentHashMap<Integer, TreeMap<HStoreKey, byte []>>();
// Default access because read by tests.
protected final Map<Integer, HStore> stores = new ConcurrentHashMap<Integer, HStore>();
protected final Map<Integer, HStore> stores =
new ConcurrentHashMap<Integer, HStore>();
final AtomicLong memcacheSize = new AtomicLong(0);
final Path basedir;
@ -1025,7 +1026,23 @@ public class HRegion implements HConstants {
* @return map of values
* @throws IOException
*/
public RowResult getClosestRowBefore(final byte [] row)
RowResult getClosestRowBefore(final byte [] row)
throws IOException{
return getClosestRowBefore(row, HConstants.COLUMN_FAMILY);
}
/**
* Return all the data for the row that matches <i>row</i> exactly,
* or the one that immediately preceeds it, at or immediately before
* <i>ts</i>.
*
* @param row row key
* @param columnFamily
* @return map of values
* @throws IOException
*/
public RowResult getClosestRowBefore(final byte [] row,
final byte [] columnFamily)
throws IOException{
// look across all the HStores for this region and determine what the
// closest key is across all column families, since the data may be sparse
@ -1033,32 +1050,25 @@ public class HRegion implements HConstants {
checkRow(row);
splitsAndClosesLock.readLock().lock();
try {
// examine each column family for the preceeding or matching key
for (HStore store : stores.values()) {
// get the closest key
byte [] closestKey = store.getRowKeyAtOrBefore(row);
// if it happens to be an exact match, we can stop looping
if (HStoreKey.equalsTwoRowKeys(regionInfo,row, closestKey)) {
key = new HStoreKey(closestKey, this.regionInfo);
break;
}
// otherwise, we need to check if it's the max and move to the next
if (closestKey != null
&& (key == null || HStoreKey.compareTwoRowKeys(
HStore store = getStore(columnFamily);
// get the closest key
byte [] closestKey = store.getRowKeyAtOrBefore(row);
// If it happens to be an exact match, we can stop looping.
// Otherwise, we need to check if it's the max and move to the next
if (HStoreKey.equalsTwoRowKeys(regionInfo, row, closestKey)) {
key = new HStoreKey(closestKey, this.regionInfo);
} else if (closestKey != null &&
(key == null || HStoreKey.compareTwoRowKeys(
regionInfo,closestKey, key.getRow()) > 0) ) {
key = new HStoreKey(closestKey, this.regionInfo);
}
}
if (key == null) {
key = new HStoreKey(closestKey, this.regionInfo);
} else {
return null;
}
// now that we've found our key, get the values
// Now that we've found our key, get the values
HbaseMapWritable<byte [], Cell> cells =
new HbaseMapWritable<byte [], Cell>();
for (HStore s: stores.values()) {
s.getFull(key, null, cells);
}
store.getFull(key, null, cells);
return new RowResult(key.getRow(), cells);
} finally {
splitsAndClosesLock.readLock().unlock();

View File

@ -887,7 +887,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
if(e == null || stopRequested.get()) {
continue;
}
LOG.info(e.msg);
LOG.info("Worker: " + e.msg);
HRegionInfo info = e.msg.getRegionInfo();
switch(e.msg.getType()) {
@ -1185,7 +1185,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
}
public RowResult getClosestRowBefore(final byte [] regionName,
final byte [] row)
final byte [] row, final byte [] columnFamily)
throws IOException {
checkOpen();
requestCount.incrementAndGet();
@ -1193,7 +1193,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
// locate the region we're operating on
HRegion region = getRegion(regionName);
// ask the region for all the data
RowResult rr = region.getClosestRowBefore(row);
RowResult rr = region.getClosestRowBefore(row, columnFamily);
return rr;
} catch (IOException e) {
checkFileSystem();
@ -1898,8 +1898,8 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
if (cmd.equals("stop")) {
printUsageAndExit("To shutdown the regionserver run " +
"bin/hbase-daemon.sh stop regionserver or send a kill signal to" +
"the regionserver pid");
"bin/hbase-daemon.sh stop regionserver or send a kill signal to" +
"the regionserver pid");
}
// Print out usage if we get to here.
@ -1917,4 +1917,4 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
.getClass(HConstants.REGION_SERVER_IMPL, HRegionServer.class);
doMain(args, regionServerClass);
}
}
}