From 1be3aeda3861e4974d87d6d7a7159209191654b9 Mon Sep 17 00:00:00 2001 From: larsh Date: Mon, 14 Oct 2013 03:57:15 +0000 Subject: [PATCH] HBASE-9751 Excessive readpoints checks in StoreFileScanner git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1531790 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/hadoop/hbase/io/hfile/HFile.java | 2 ++ .../apache/hadoop/hbase/io/hfile/HFileReaderV2.java | 5 +++++ .../apache/hadoop/hbase/regionserver/StoreFile.java | 2 +- .../hadoop/hbase/regionserver/StoreFileScanner.java | 11 +++++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java index 255339016da..e3b114528b5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java @@ -497,6 +497,8 @@ public class HFile { void close(boolean evictOnClose) throws IOException; DataBlockEncoding getEncodingOnDisk(); + + boolean hasMVCCInfo(); } /** diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java index f767ed1cd31..0e22ca820af 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java @@ -387,6 +387,11 @@ public class HFileReaderV2 extends AbstractHFileReader { return dataBlockEncoder.diskToCacheFormat(hfileBlock, isCompaction); } + @Override + public boolean hasMVCCInfo() { + return includesMemstoreTS && decodeMemstoreTS; + } + /** * Compares the actual type of a block retrieved from cache or disk with its * expected type and throws an exception in case of a mismatch. Expected diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java index fd812d210b3..1f874019fa2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java @@ -1070,7 +1070,7 @@ public class StoreFile { boolean isCompaction) { return new StoreFileScanner(this, getScanner(cacheBlocks, pread, - isCompaction), !isCompaction); + isCompaction), !isCompaction, reader.hasMVCCInfo()); } /** diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java index 867f96f60a8..4837ca5542d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java @@ -53,6 +53,7 @@ public class StoreFileScanner implements KeyValueScanner { private KeyValue delayedSeekKV; private boolean enforceMVCC = false; + private boolean hasMVCCInfo = false; private static AtomicLong seekCount; @@ -62,10 +63,11 @@ public class StoreFileScanner implements KeyValueScanner { * Implements a {@link KeyValueScanner} on top of the specified {@link HFileScanner} * @param hfs HFile scanner */ - public StoreFileScanner(StoreFile.Reader reader, HFileScanner hfs, boolean useMVCC) { + public StoreFileScanner(StoreFile.Reader reader, HFileScanner hfs, boolean useMVCC, boolean hasMVCC) { this.reader = reader; this.hfs = hfs; this.enforceMVCC = useMVCC; + this.hasMVCCInfo = hasMVCC; } /** @@ -126,7 +128,8 @@ public class StoreFileScanner implements KeyValueScanner { if (cur != null) { hfs.next(); cur = hfs.getKeyValue(); - skipKVsNewerThanReadpoint(); + if (hasMVCCInfo) + skipKVsNewerThanReadpoint(); } } catch(IOException e) { throw new IOException("Could not iterate " + this, e); @@ -146,7 +149,7 @@ public class StoreFileScanner implements KeyValueScanner { cur = hfs.getKeyValue(); - return skipKVsNewerThanReadpoint(); + return !hasMVCCInfo ? true : skipKVsNewerThanReadpoint(); } finally { realSeekDone = true; } @@ -166,7 +169,7 @@ public class StoreFileScanner implements KeyValueScanner { } cur = hfs.getKeyValue(); - return skipKVsNewerThanReadpoint(); + return !hasMVCCInfo ? true : skipKVsNewerThanReadpoint(); } finally { realSeekDone = true; }