HBASE-8151 Decode memstoreTS in HFileReaderV2 only when necessary

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1459433 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
larsh 2013-03-21 18:13:30 +00:00
parent e38dcba6c3
commit e91edde428
1 changed files with 31 additions and 17 deletions

View File

@ -54,6 +54,7 @@ public class HFileReaderV2 extends AbstractHFileReader {
private static int KEY_VALUE_LEN_SIZE = 2 * Bytes.SIZEOF_INT;
private boolean includesMemstoreTS = false;
private boolean decodeMemstoreTS = false;
private boolean shouldIncludeMemstoreTS() {
return includesMemstoreTS;
@ -147,6 +148,9 @@ public class HFileReaderV2 extends AbstractHFileReader {
Bytes.toInt(keyValueFormatVersion) ==
HFileWriterV2.KEY_VALUE_VER_WITH_MEMSTORE;
fsBlockReaderV2.setIncludesMemstoreTS(includesMemstoreTS);
if (includesMemstoreTS) {
decodeMemstoreTS = Bytes.toLong(fileInfo.get(HFileWriterV2.MAX_MEMSTORE_TS_KEY)) > 0;
}
// Read data block encoding algorithm name from file info.
dataBlockEncoder = HFileDataBlockEncoderImpl.createFromFileInfo(fileInfo,
@ -769,6 +773,7 @@ public class HFileReaderV2 extends AbstractHFileReader {
currValueLen = blockBuffer.getInt();
blockBuffer.reset();
if (this.reader.shouldIncludeMemstoreTS()) {
if (this.reader.decodeMemstoreTS) {
try {
int memstoreTSOffset = blockBuffer.arrayOffset()
+ blockBuffer.position() + KEY_VALUE_LEN_SIZE + currKeyLen
@ -779,6 +784,10 @@ public class HFileReaderV2 extends AbstractHFileReader {
} catch (Exception e) {
throw new RuntimeException("Error reading memstore timestamp", e);
}
} else {
currMemstoreTS = 0;
currMemstoreTSLen = 1;
}
}
if (currKeyLen < 0 || currValueLen < 0
@ -816,6 +825,7 @@ public class HFileReaderV2 extends AbstractHFileReader {
vlen = blockBuffer.getInt();
blockBuffer.reset();
if (this.reader.shouldIncludeMemstoreTS()) {
if (this.reader.decodeMemstoreTS) {
try {
int memstoreTSOffset = blockBuffer.arrayOffset()
+ blockBuffer.position() + KEY_VALUE_LEN_SIZE + klen + vlen;
@ -825,6 +835,10 @@ public class HFileReaderV2 extends AbstractHFileReader {
} catch (Exception e) {
throw new RuntimeException("Error reading memstore timestamp", e);
}
} else {
memstoreTS = 0;
memstoreTSLen = 1;
}
}
int keyOffset = blockBuffer.arrayOffset() + blockBuffer.position()