HBASE-686 MemcacheScanner didn't return the first row(if it exists), because HScannerInterface's output incorrect (LN via Jim Kellerman)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@668822 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b58c15a6d7
commit
132a644260
|
@ -52,6 +52,8 @@ Hbase Change Log
|
|||
(LN via Stack)
|
||||
HBASE-682 Unnecessary iteration in HMemcache.internalGet? got much better
|
||||
reading performance after break it (LN via Stack)
|
||||
HBASE-686 MemcacheScanner didn't return the first row(if it exists),
|
||||
because HScannerInterface's output incorrect (LN via Jim Kellerman)
|
||||
|
||||
IMPROVEMENTS
|
||||
HBASE-559 MR example job to count table rows
|
||||
|
|
|
@ -421,8 +421,7 @@ class Memcache {
|
|||
// take note of the row of this candidate so that we'll know when
|
||||
// we cross the row boundary into the previous row.
|
||||
if (!HLogEdit.isDeleted(headMap.get(thisKey))) {
|
||||
if (ttl == HConstants.FOREVER ||
|
||||
now < found_key.getTimestamp() + ttl) {
|
||||
if (ttl == HConstants.FOREVER) {
|
||||
lastRowFound = thisKey.getRow();
|
||||
candidateKeys.put(stripTimestamp(thisKey),
|
||||
new Long(thisKey.getTimestamp()));
|
||||
|
@ -698,8 +697,7 @@ class Memcache {
|
|||
if (results.size() > 0) {
|
||||
results.clear();
|
||||
}
|
||||
while (results.size() <= 0 &&
|
||||
(this.currentRow = getNextRow(this.currentRow)) != null) {
|
||||
while (results.size() <= 0 && this.currentRow != null) {
|
||||
if (deletes.size() > 0) {
|
||||
deletes.clear();
|
||||
}
|
||||
|
@ -727,6 +725,8 @@ class Memcache {
|
|||
}
|
||||
results.put(column, c.getValue());
|
||||
}
|
||||
this.currentRow = getNextRow(this.currentRow);
|
||||
|
||||
}
|
||||
return results.size() > 0;
|
||||
}
|
||||
|
|
|
@ -304,4 +304,42 @@ public class TestHMemcache extends TestCase {
|
|||
private HStoreKey getHSKForRow(byte [] row) {
|
||||
return new HStoreKey(row, Bytes.toBytes("test_col:"), HConstants.LATEST_TIMESTAMP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test memcache scanner scanning cached rows, HBASE-686
|
||||
* @throws IOException
|
||||
*/
|
||||
public void testScanner_686() throws IOException {
|
||||
addRows(this.hmemcache);
|
||||
long timestamp = System.currentTimeMillis();
|
||||
byte[][] cols = new byte[COLUMNS_COUNT * ROW_COUNT][];
|
||||
for (int i = 0; i < ROW_COUNT; i++) {
|
||||
for (int ii = 0; ii < COLUMNS_COUNT; ii++) {
|
||||
cols[(ii + (i * COLUMNS_COUNT))] = getColumnName(i, ii);
|
||||
}
|
||||
}
|
||||
//starting from each row, validate results should contain the starting row
|
||||
for (int startRowId = 0; startRowId < ROW_COUNT; startRowId++) {
|
||||
InternalScanner scanner = this.hmemcache.getScanner(timestamp,
|
||||
cols, getRowName(startRowId));
|
||||
HStoreKey key = new HStoreKey();
|
||||
TreeMap<byte[], byte[]> results =
|
||||
new TreeMap<byte[], byte[]>(Bytes.BYTES_COMPARATOR);
|
||||
for (int i = 0; scanner.next(key, results); i++) {
|
||||
int rowId = startRowId + i;
|
||||
assertTrue("Row name",
|
||||
key.toString().startsWith(Bytes.toString(getRowName(rowId))));
|
||||
assertEquals("Count of columns", COLUMNS_COUNT, results.size());
|
||||
TreeMap<byte[], Cell> row =
|
||||
new TreeMap<byte[], Cell>(Bytes.BYTES_COMPARATOR);
|
||||
for (Map.Entry<byte[], byte[]> e : results.entrySet()) {
|
||||
row.put(e.getKey(),
|
||||
new Cell(e.getValue(), HConstants.LATEST_TIMESTAMP));
|
||||
}
|
||||
isExpectedRow(rowId, row);
|
||||
// Clear out set. Otherwise row results accumulate.
|
||||
results.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue