HBASE-1841 If multiple of same key in an hfile and they span blocks, may miss the earlier keys on a lookup
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@835757 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a6b7d95097
commit
efef11e2dc
|
@ -107,6 +107,9 @@ Release 0.21.0 - Unreleased
|
||||||
Java 5
|
Java 5
|
||||||
HBASE-1967 [Transactional] client.TestTransactions.testPutPutScan fails
|
HBASE-1967 [Transactional] client.TestTransactions.testPutPutScan fails
|
||||||
sometimes -- Temporary fix
|
sometimes -- Temporary fix
|
||||||
|
HBASE-1841 If multiple of same key in an hfile and they span blocks, may
|
||||||
|
miss the earlier keys on a lookup
|
||||||
|
(Schubert Zhang via Stack)
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
HBASE-1760 Cleanup TODOs in HTable
|
HBASE-1760 Cleanup TODOs in HTable
|
||||||
|
|
|
@ -475,9 +475,11 @@ public class HFile {
|
||||||
public void append(final byte [] key, final int koffset, final int klength,
|
public void append(final byte [] key, final int koffset, final int klength,
|
||||||
final byte [] value, final int voffset, final int vlength)
|
final byte [] value, final int voffset, final int vlength)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
checkKey(key, koffset, klength);
|
boolean dupKey = checkKey(key, koffset, klength);
|
||||||
checkValue(value, voffset, vlength);
|
checkValue(value, voffset, vlength);
|
||||||
|
if (!dupKey) {
|
||||||
checkBlockBoundary();
|
checkBlockBoundary();
|
||||||
|
}
|
||||||
// Write length of key and value and then actual key and value bytes.
|
// Write length of key and value and then actual key and value bytes.
|
||||||
this.out.writeInt(klength);
|
this.out.writeInt(klength);
|
||||||
this.keylength += klength;
|
this.keylength += klength;
|
||||||
|
@ -499,10 +501,13 @@ public class HFile {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @param key Key to check.
|
* @param key Key to check.
|
||||||
|
* @return the flag of duplicate Key or not
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void checkKey(final byte [] key, final int offset, final int length)
|
private boolean checkKey(final byte [] key, final int offset, final int length)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
boolean dupKey = false;
|
||||||
|
|
||||||
if (key == null || length <= 0) {
|
if (key == null || length <= 0) {
|
||||||
throw new IOException("Key cannot be null or empty");
|
throw new IOException("Key cannot be null or empty");
|
||||||
}
|
}
|
||||||
|
@ -511,14 +516,18 @@ public class HFile {
|
||||||
MAXIMUM_KEY_LENGTH);
|
MAXIMUM_KEY_LENGTH);
|
||||||
}
|
}
|
||||||
if (this.lastKeyBuffer != null) {
|
if (this.lastKeyBuffer != null) {
|
||||||
if (this.comparator.compare(this.lastKeyBuffer, this.lastKeyOffset,
|
int keyComp = this.comparator.compare(this.lastKeyBuffer, this.lastKeyOffset,
|
||||||
this.lastKeyLength, key, offset, length) > 0) {
|
this.lastKeyLength, key, offset, length);
|
||||||
|
if (keyComp > 0) {
|
||||||
throw new IOException("Added a key not lexically larger than" +
|
throw new IOException("Added a key not lexically larger than" +
|
||||||
" previous key=" + Bytes.toString(key, offset, length) +
|
" previous key=" + Bytes.toString(key, offset, length) +
|
||||||
", lastkey=" + Bytes.toString(this.lastKeyBuffer, this.lastKeyOffset,
|
", lastkey=" + Bytes.toString(this.lastKeyBuffer, this.lastKeyOffset,
|
||||||
this.lastKeyLength));
|
this.lastKeyLength));
|
||||||
|
} else if (keyComp == 0) {
|
||||||
|
dupKey = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return dupKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkValue(final byte [] value, final int offset,
|
private void checkValue(final byte [] value, final int offset,
|
||||||
|
|
Loading…
Reference in New Issue