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:
parent
70f7608afa
commit
638529d93b
|
@ -55,10 +55,6 @@ public class HalfStoreFileReader extends StoreFile.Reader {
|
|||
// i.e. empty column and a timestamp of LATEST_TIMESTAMP.
|
||||
protected final byte [] splitkey;
|
||||
|
||||
private byte[] firstKey = null;
|
||||
|
||||
private boolean firstKeySeeked = false;
|
||||
|
||||
/**
|
||||
* @param fs
|
||||
* @param p
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue