hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [17/50] [abbrv] hbase git commit: HBASE-14643 - Avoid Splits from once again opening a closed reader for fetching the first and last key (Heng Chen)
Date Fri, 23 Oct 2015 22:49:37 GMT
HBASE-14643 - Avoid Splits from once again opening a closed reader for
fetching the first and last key (Heng Chen)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6e3b7af0
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6e3b7af0
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6e3b7af0

Branch: refs/heads/hbase-12439
Commit: 6e3b7af0efced7351163a5011a44bfc18851fce0
Parents: 5a5b854
Author: ramkrishna <ramkrishna.s.vasudevan@gmail.com>
Authored: Wed Oct 21 10:12:38 2015 +0530
Committer: ramkrishna <ramkrishna.s.vasudevan@gmail.com>
Committed: Wed Oct 21 10:12:38 2015 +0530

----------------------------------------------------------------------
 .../hbase/regionserver/HRegionFileSystem.java   |  8 +++----
 .../hadoop/hbase/regionserver/StoreFile.java    | 23 ++++++++++++++++++++
 .../hbase/regionserver/TestStoreFile.java       |  5 ++++-
 3 files changed, 31 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/6e3b7af0/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
index b16738f..412f9b3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
@@ -587,23 +587,23 @@ public class HRegionFileSystem {
         if (top) {
           //check if larger than last key.
           KeyValue splitKey = KeyValueUtil.createFirstOnRow(splitRow);
-          Cell lastKey = f.createReader().getLastKey();
+          Cell lastKey = f.getLastKey();
           // If lastKey is null means storefile is empty.
           if (lastKey == null) {
             return null;
           }
-          if (f.getReader().getComparator().compare(splitKey, lastKey) > 0) {
+          if (f.getComparator().compare(splitKey, lastKey) > 0) {
             return null;
           }
         } else {
           //check if smaller than first key
           KeyValue splitKey = KeyValueUtil.createLastOnRow(splitRow);
-          Cell firstKey = f.createReader().getFirstKey();
+          Cell firstKey = f.getFirstKey();
           // If firstKey is null means storefile is empty.
           if (firstKey == null) {
             return null;
           }
-          if (f.getReader().getComparator().compare(splitKey, firstKey) < 0) {
+          if (f.getComparator().compare(splitKey, firstKey) < 0) {
             return null;
           }
         }

http://git-wip-us.apache.org/repos/asf/hbase/blob/6e3b7af0/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
----------------------------------------------------------------------
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 11d71cf..88aa151 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
@@ -129,6 +129,25 @@ public class StoreFile {
   // Set when we obtain a Reader.
   private long maxMemstoreTS = -1;
 
+  // firstKey, lastkey and cellComparator will be set when openReader.
+  private Cell firstKey;
+
+  private Cell lastKey;
+
+  private Comparator comparator;
+
+  public Cell getFirstKey() {
+    return firstKey;
+  }
+
+  public Cell getLastKey() {
+    return lastKey;
+  }
+
+  public Comparator getComparator() {
+    return comparator;
+  }
+
   public long getMaxMemstoreTS() {
     return maxMemstoreTS;
   }
@@ -475,6 +494,10 @@ public class StoreFile {
           "proceeding without", e);
       this.reader.timeRangeTracker = null;
     }
+    // initialize so we can reuse them after reader closed.
+    firstKey = reader.getFirstKey();
+    lastKey = reader.getLastKey();
+    comparator = reader.getComparator();
     return this.reader;
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/6e3b7af0/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
index b763a22..85e4439 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
@@ -175,6 +175,8 @@ public class TestStoreFile extends HBaseTestCase {
     byte [] midRow = CellUtil.cloneRow(kv);
     kv = reader.getLastKey();
     byte [] finalRow = CellUtil.cloneRow(kv);
+    hsf.closeReader(true);
+
     // Make a reference
     HRegionInfo splitHri = new HRegionInfo(hri.getTable(), null, midRow);
     Path refPath = splitStoreFile(regionFs, splitHri, TEST_FAMILY, hsf, midRow, true);
@@ -275,9 +277,10 @@ public class TestStoreFile extends HBaseTestCase {
     HRegionInfo splitHriA = new HRegionInfo(hri.getTable(), null, SPLITKEY);
     HRegionInfo splitHriB = new HRegionInfo(hri.getTable(), SPLITKEY, null);
     StoreFile f = new StoreFile(fs, linkFilePath, testConf, cacheConf, BloomType.NONE);
+    f.createReader();
     Path pathA = splitStoreFile(cloneRegionFs, splitHriA, TEST_FAMILY, f, SPLITKEY, true);
// top
     Path pathB = splitStoreFile(cloneRegionFs, splitHriB, TEST_FAMILY, f, SPLITKEY, false);//
bottom
-
+    f.closeReader(true);
     // OK test the thing
     FSUtils.logFileSystemState(fs, testDir, LOG);
 


Mime
View raw message