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:
parent
e38dcba6c3
commit
e91edde428
|
@ -54,6 +54,7 @@ public class HFileReaderV2 extends AbstractHFileReader {
|
||||||
private static int KEY_VALUE_LEN_SIZE = 2 * Bytes.SIZEOF_INT;
|
private static int KEY_VALUE_LEN_SIZE = 2 * Bytes.SIZEOF_INT;
|
||||||
|
|
||||||
private boolean includesMemstoreTS = false;
|
private boolean includesMemstoreTS = false;
|
||||||
|
private boolean decodeMemstoreTS = false;
|
||||||
|
|
||||||
private boolean shouldIncludeMemstoreTS() {
|
private boolean shouldIncludeMemstoreTS() {
|
||||||
return includesMemstoreTS;
|
return includesMemstoreTS;
|
||||||
|
@ -147,6 +148,9 @@ public class HFileReaderV2 extends AbstractHFileReader {
|
||||||
Bytes.toInt(keyValueFormatVersion) ==
|
Bytes.toInt(keyValueFormatVersion) ==
|
||||||
HFileWriterV2.KEY_VALUE_VER_WITH_MEMSTORE;
|
HFileWriterV2.KEY_VALUE_VER_WITH_MEMSTORE;
|
||||||
fsBlockReaderV2.setIncludesMemstoreTS(includesMemstoreTS);
|
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.
|
// Read data block encoding algorithm name from file info.
|
||||||
dataBlockEncoder = HFileDataBlockEncoderImpl.createFromFileInfo(fileInfo,
|
dataBlockEncoder = HFileDataBlockEncoderImpl.createFromFileInfo(fileInfo,
|
||||||
|
@ -769,15 +773,20 @@ public class HFileReaderV2 extends AbstractHFileReader {
|
||||||
currValueLen = blockBuffer.getInt();
|
currValueLen = blockBuffer.getInt();
|
||||||
blockBuffer.reset();
|
blockBuffer.reset();
|
||||||
if (this.reader.shouldIncludeMemstoreTS()) {
|
if (this.reader.shouldIncludeMemstoreTS()) {
|
||||||
try {
|
if (this.reader.decodeMemstoreTS) {
|
||||||
int memstoreTSOffset = blockBuffer.arrayOffset()
|
try {
|
||||||
+ blockBuffer.position() + KEY_VALUE_LEN_SIZE + currKeyLen
|
int memstoreTSOffset = blockBuffer.arrayOffset()
|
||||||
+ currValueLen;
|
+ blockBuffer.position() + KEY_VALUE_LEN_SIZE + currKeyLen
|
||||||
currMemstoreTS = Bytes.readVLong(blockBuffer.array(),
|
+ currValueLen;
|
||||||
memstoreTSOffset);
|
currMemstoreTS = Bytes.readVLong(blockBuffer.array(),
|
||||||
currMemstoreTSLen = WritableUtils.getVIntSize(currMemstoreTS);
|
memstoreTSOffset);
|
||||||
} catch (Exception e) {
|
currMemstoreTSLen = WritableUtils.getVIntSize(currMemstoreTS);
|
||||||
throw new RuntimeException("Error reading memstore timestamp", e);
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Error reading memstore timestamp", e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currMemstoreTS = 0;
|
||||||
|
currMemstoreTSLen = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,14 +825,19 @@ public class HFileReaderV2 extends AbstractHFileReader {
|
||||||
vlen = blockBuffer.getInt();
|
vlen = blockBuffer.getInt();
|
||||||
blockBuffer.reset();
|
blockBuffer.reset();
|
||||||
if (this.reader.shouldIncludeMemstoreTS()) {
|
if (this.reader.shouldIncludeMemstoreTS()) {
|
||||||
try {
|
if (this.reader.decodeMemstoreTS) {
|
||||||
int memstoreTSOffset = blockBuffer.arrayOffset()
|
try {
|
||||||
+ blockBuffer.position() + KEY_VALUE_LEN_SIZE + klen + vlen;
|
int memstoreTSOffset = blockBuffer.arrayOffset()
|
||||||
memstoreTS = Bytes.readVLong(blockBuffer.array(),
|
+ blockBuffer.position() + KEY_VALUE_LEN_SIZE + klen + vlen;
|
||||||
memstoreTSOffset);
|
memstoreTS = Bytes.readVLong(blockBuffer.array(),
|
||||||
memstoreTSLen = WritableUtils.getVIntSize(memstoreTS);
|
memstoreTSOffset);
|
||||||
} catch (Exception e) {
|
memstoreTSLen = WritableUtils.getVIntSize(memstoreTS);
|
||||||
throw new RuntimeException("Error reading memstore timestamp", e);
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Error reading memstore timestamp", e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
memstoreTS = 0;
|
||||||
|
memstoreTSLen = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue