You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by an...@apache.org on 2021/03/10 07:53:39 UTC

[hbase] branch branch-2 updated: HBASE-25582 Support setting scan ReadType to be STREAM at cluster level (#3040)

This is an automated email from the ASF dual-hosted git repository.

anoopsamjohn pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 29d771f  HBASE-25582 Support setting scan ReadType to be STREAM at cluster level (#3040)
29d771f is described below

commit 29d771fab91a32bcff4788ff4e40c17dba215dd7
Author: Anoop Sam John <an...@gmail.com>
AuthorDate: Wed Mar 10 13:23:15 2021 +0530

    HBASE-25582 Support setting scan ReadType to be STREAM at cluster level (#3040)
    
    Signed-off-by: zhangduo <zh...@apache.org>
    Signed-off-by: Viraj Jasani <vj...@apache.org>
---
 .../apache/hadoop/hbase/regionserver/StoreScanner.java  | 14 +++++++++++---
 .../apache/hadoop/hbase/regionserver/TestHStore.java    | 17 +++++++++++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
index 8ea4cd2..a5317e1 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
@@ -132,9 +132,11 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
   public static final long DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK = 10000;
 
   /**
-   * If the read type if Scan.ReadType.DEFAULT, we will start with pread, and if the kvs we scanned
+   * If the read type is Scan.ReadType.DEFAULT, we will start with pread, and if the kvs we scanned
    * reaches this limit, we will reopen the scanner with stream. The default value is 4 times of
    * block size for this store.
+   * If configured with a value <0, for all scans with ReadType DEFAULT, we will open scanner with
+   * stream mode itself.
    */
   public static final String STORESCANNER_PREAD_MAX_BYTES = "hbase.storescanner.pread.max.bytes";
 
@@ -180,6 +182,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
     this.useRowColBloom = numColumns > 1 || (!get && numColumns == 1)
         && (store == null || store.getColumnFamilyDescriptor().getBloomFilterType() == BloomType.ROWCOL);
     this.maxRowSize = scanInfo.getTableMaxRowSize();
+    this.preadMaxBytes = scanInfo.getPreadMaxBytes();
     if (get) {
       this.readType = Scan.ReadType.PREAD;
       this.scanUsePread = true;
@@ -190,7 +193,13 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
       this.scanUsePread = false;
     } else {
       if (scan.getReadType() == Scan.ReadType.DEFAULT) {
-        this.readType = scanInfo.isUsePread() ? Scan.ReadType.PREAD : Scan.ReadType.DEFAULT;
+        if (scanInfo.isUsePread()) {
+          this.readType = Scan.ReadType.PREAD;
+        } else if (this.preadMaxBytes < 0) {
+          this.readType = Scan.ReadType.STREAM;
+        } else {
+          this.readType = Scan.ReadType.DEFAULT;
+        }
       } else {
         this.readType = scan.getReadType();
       }
@@ -198,7 +207,6 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
       // readType is default if the scan keeps running for a long time.
       this.scanUsePread = this.readType != Scan.ReadType.STREAM;
     }
-    this.preadMaxBytes = scanInfo.getPreadMaxBytes();
     this.cellsPerHeartbeatCheck = scanInfo.getCellsPerTimeoutCheck();
     // Parallel seeking is on if the config allows and more there is more than one store file.
     if (store != null && store.getStorefilesCount() > 1) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java
index 68f9add..3972bc6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java
@@ -78,6 +78,7 @@ import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.RegionInfo;
 import org.apache.hadoop.hbase.client.RegionInfoBuilder;
 import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Scan.ReadType;
 import org.apache.hadoop.hbase.client.TableDescriptor;
 import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
 import org.apache.hadoop.hbase.exceptions.IllegalArgumentIOException;
@@ -1665,6 +1666,22 @@ public class TestHStore {
   }
 
   @Test
+  public void testMaxPreadBytesConfiguredToBeLessThanZero() throws Exception {
+    Configuration conf = HBaseConfiguration.create();
+    conf.set("hbase.hstore.engine.class", DummyStoreEngine.class.getName());
+    // Set 'hbase.storescanner.pread.max.bytes' < 0, so that StoreScanner will be a STREAM type.
+    conf.setLong(StoreScanner.STORESCANNER_PREAD_MAX_BYTES, -1);
+    MyStore store = initMyStore(name.getMethodName(), conf, new MyStoreHook() {});
+    Scan scan = new Scan();
+    scan.addFamily(family);
+    // ReadType on Scan is still DEFAULT only.
+    assertEquals(ReadType.DEFAULT, scan.getReadType());
+    StoreScanner storeScanner = (StoreScanner) store.getScanner(scan,
+        scan.getFamilyMap().get(family), Long.MAX_VALUE);
+    assertFalse(storeScanner.isScanUsePread());
+  }
+
+  @Test
   public void testInMemoryCompactionTypeWithLowerCase() throws IOException, InterruptedException {
     Configuration conf = HBaseConfiguration.create();
     conf.set("hbase.systemtables.compacting.memstore.type", "eager");