HBASE-5997 Fix concerns raised in HBASE-5922 related to HalfStoreFileReader; REVERT

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1377483 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2012-08-26 18:59:25 +00:00
parent 70f7608afa
commit 638529d93b
3 changed files with 3 additions and 30 deletions

View File

@ -54,10 +54,6 @@ public class HalfStoreFileReader extends StoreFile.Reader {
// This is the key we split around. Its the first possible entry on a row:
// i.e. empty column and a timestamp of LATEST_TIMESTAMP.
protected final byte [] splitkey;
private byte[] firstKey = null;
private boolean firstKeySeeked = false;
/**
* @param fs
@ -147,11 +143,8 @@ public class HalfStoreFileReader extends StoreFile.Reader {
public boolean seekBefore(byte [] key, int offset, int length)
throws IOException {
if (top) {
byte[] fk = getFirstKey();
// This will be null when the file is empty in which we can not seekBefore to any key
if (fk == null) return false;
if (getComparator().compare(key, offset, length, fk, 0,
fk.length) <= 0) {
if (getComparator().compare(key, offset, length, splitkey, 0,
splitkey.length) < 0) {
return false;
}
} else {
@ -280,20 +273,4 @@ public class HalfStoreFileReader extends StoreFile.Reader {
// Returns null to indicate file is not splitable.
return null;
}
@Override
public byte[] getFirstKey() {
if (!firstKeySeeked) {
HFileScanner scanner = getScanner(true, true, false);
try {
if (scanner.seekTo()) {
this.firstKey = Bytes.toBytes(scanner.getKey());
}
firstKeySeeked = true;
} catch (IOException e) {
LOG.warn("Failed seekTo first KV in the file", e);
}
}
return this.firstKey;
}
}

View File

@ -1698,7 +1698,6 @@ public class HStore extends SchemaConfigured implements Store {
}
// TODO: Cache these keys rather than make each time?
byte [] fk = r.getFirstKey();
if (fk == null) return;
KeyValue firstKV = KeyValue.createKeyValueFromKey(fk, 0, fk.length);
byte [] lk = r.getLastKey();
KeyValue lastKV = KeyValue.createKeyValueFromKey(lk, 0, lk.length);
@ -1712,7 +1711,7 @@ public class HStore extends SchemaConfigured implements Store {
firstOnRow = new KeyValue(lastKV.getRow(), HConstants.LATEST_TIMESTAMP);
}
// Get a scanner that caches blocks and that uses pread.
HFileScanner scanner = r.getScanner(true, true, false);
HFileScanner scanner = r.getHFileReader().getScanner(true, true, false);
// Seek scanner. If can't seek it, return.
if (!seekToScanner(scanner, firstOnRow, firstKV)) return;
// If we found candidate on firstOnRow, just return. THIS WILL NEVER HAPPEN!

View File

@ -195,9 +195,6 @@ public class TestHalfStoreFileReader {
foundKeyValue = doTestOfSeekBefore(p, fs, bottom, items.get(1), cacheConf);
assertEquals(items.get(0), foundKeyValue);
// Try to seek before the splitKey in the top file
foundKeyValue = doTestOfSeekBefore(p, fs, top, midKV, cacheConf);
assertNull(foundKeyValue);
}
private KeyValue doTestOfSeekBefore(Path p, FileSystem fs, Reference bottom, KeyValue seekBefore,