HBASE-621 Make MAX_VERSIONS work like TTL: In scans and gets, check MAX_VERSIONs setting and return that many only rather than wait on compaction
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@658419 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7bbe456b0f
commit
bf4536f713
|
@ -40,6 +40,9 @@ Hbase Change Log
|
||||||
and HConnectionManager (Jean-Daniel Cryans via Stack)
|
and HConnectionManager (Jean-Daniel Cryans via Stack)
|
||||||
HBASE-23 UI listing regions should be sorted by address and show additional
|
HBASE-23 UI listing regions should be sorted by address and show additional
|
||||||
region state (Jean-Daniel Cryans via Stack)
|
region state (Jean-Daniel Cryans via Stack)
|
||||||
|
HBASE-621 Make MAX_VERSIONS work like TTL: In scans and gets, check
|
||||||
|
MAX_VERSIONs setting and return that many only rather than wait on
|
||||||
|
compaction (Jean-Daniel Cryans via Stack)
|
||||||
|
|
||||||
Release 0.1.2 - 05/13/2008
|
Release 0.1.2 - 05/13/2008
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,7 @@ public interface HConstants {
|
||||||
/**
|
/**
|
||||||
* Define for 'return-all-versions'.
|
* Define for 'return-all-versions'.
|
||||||
*/
|
*/
|
||||||
static final int ALL_VERSIONS = -1;
|
static final int ALL_VERSIONS = Integer.MAX_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlimited time-to-live.
|
* Unlimited time-to-live.
|
||||||
|
|
|
@ -1230,7 +1230,7 @@ public class HStore implements HConstants {
|
||||||
* Get the value for the indicated HStoreKey. Grab the target value and the
|
* Get the value for the indicated HStoreKey. Grab the target value and the
|
||||||
* previous 'numVersions-1' values, as well.
|
* previous 'numVersions-1' values, as well.
|
||||||
*
|
*
|
||||||
* If 'numVersions' is negative, the method returns all available versions.
|
* Use {@link HConstants.ALL_VERSIONS} to retrieve all versions.
|
||||||
* @param key
|
* @param key
|
||||||
* @param numVersions Number of versions to fetch. Must be > 0.
|
* @param numVersions Number of versions to fetch. Must be > 0.
|
||||||
* @return values for the specified versions
|
* @return values for the specified versions
|
||||||
|
@ -1246,7 +1246,7 @@ public class HStore implements HConstants {
|
||||||
try {
|
try {
|
||||||
// Check the memcache
|
// Check the memcache
|
||||||
List<Cell> results = this.memcache.get(key, numVersions);
|
List<Cell> results = this.memcache.get(key, numVersions);
|
||||||
// If we got sufficient versions from memcache, return.
|
// If we got sufficient versions from memcache, return.
|
||||||
if (results.size() == numVersions) {
|
if (results.size() == numVersions) {
|
||||||
return results.toArray(new Cell[results.size()]);
|
return results.toArray(new Cell[results.size()]);
|
||||||
}
|
}
|
||||||
|
@ -1323,9 +1323,18 @@ public class HStore implements HConstants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Small method to check if we are over the max number of versions
|
||||||
|
* or we acheived this family max versions.
|
||||||
|
* The later happens when we have the situation described in HBASE-621.
|
||||||
|
* @param numVersions
|
||||||
|
* @param results
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private boolean hasEnoughVersions(final int numVersions,
|
private boolean hasEnoughVersions(final int numVersions,
|
||||||
final List<Cell> results) {
|
final List<Cell> results) {
|
||||||
return numVersions > 0 && results.size() >= numVersions;
|
return (results.size() >= numVersions || results.size() >= family
|
||||||
|
.getMaxVersions());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1345,8 +1354,9 @@ public class HStore implements HConstants {
|
||||||
*/
|
*/
|
||||||
List<HStoreKey> getKeys(final HStoreKey origin, final int versions)
|
List<HStoreKey> getKeys(final HStoreKey origin, final int versions)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
List<HStoreKey> keys = this.memcache.getKeys(origin, versions);
|
List<HStoreKey> keys = this.memcache.getKeys(origin, versions);
|
||||||
if (versions != ALL_VERSIONS && keys.size() >= versions) {
|
if (keys.size() >= versions) {
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1391,7 +1401,7 @@ public class HStore implements HConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we've collected enough versions, then exit the loop.
|
// if we've collected enough versions, then exit the loop.
|
||||||
if (versions != ALL_VERSIONS && keys.size() >= versions) {
|
if (keys.size() >= versions) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -610,7 +610,7 @@ class Memcache {
|
||||||
LOG.debug("internalGetKeys: " + key + ": expired, skipped");
|
LOG.debug("internalGetKeys: " + key + ": expired, skipped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (versions != HConstants.ALL_VERSIONS && result.size() >= versions) {
|
if (result.size() >= versions) {
|
||||||
// We have enough results. Return.
|
// We have enough results. Return.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,8 @@ public class TestCompaction extends HBaseTestCase {
|
||||||
addContent(new HRegionIncommon(r), Bytes.toString(COLUMN_FAMILY));
|
addContent(new HRegionIncommon(r), Bytes.toString(COLUMN_FAMILY));
|
||||||
Cell[] cellValues =
|
Cell[] cellValues =
|
||||||
r.get(STARTROW, COLUMN_FAMILY_TEXT, 100 /*Too many*/);
|
r.get(STARTROW, COLUMN_FAMILY_TEXT, 100 /*Too many*/);
|
||||||
// Assert that I can get > 5 versions (Should be at least 5 in there).
|
// Assert that I can get 3 versions since it is the max I should get
|
||||||
assertTrue(cellValues.length >= 5);
|
assertTrue(cellValues.length == 3);
|
||||||
r.flushcache();
|
r.flushcache();
|
||||||
r.compactStores();
|
r.compactStores();
|
||||||
// Now assert that there are 4 versions of a record only: thats the
|
// Now assert that there are 4 versions of a record only: thats the
|
||||||
|
|
Loading…
Reference in New Issue