hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yangzhe1...@apache.org
Subject hbase git commit: HBASE-15484 Correct the semantic of batch and partial - amend to fix bug and revise the JavaDoc for related APIs.
Date Tue, 07 Mar 2017 14:51:05 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 6afe696e5 -> f45d26190


HBASE-15484 Correct the semantic of batch and partial - amend to fix bug and revise the JavaDoc
for related APIs.


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

Branch: refs/heads/branch-1
Commit: f45d26190274c1f91418bb2ab440a3f8546096de
Parents: 6afe696
Author: Phil Yang <yangzhe1991@apache.org>
Authored: Tue Mar 7 22:27:06 2017 +0800
Committer: Phil Yang <yangzhe1991@apache.org>
Committed: Tue Mar 7 22:42:58 2017 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/client/ClientScanner.java      |  5 +++++
 .../org/apache/hadoop/hbase/client/Result.java  | 17 ++++++-----------
 .../org/apache/hadoop/hbase/client/Scan.java    | 20 +++++++++++---------
 .../hbase/TestPartialResultsFromClientSide.java | 18 +++++++++++++++++-
 4 files changed, 39 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f45d2619/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
index 9675182..01ea993 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
@@ -668,6 +668,11 @@ public abstract class ClientScanner extends AbstractClientScanner {
         }
       }
       partialResultsCellSizes -= scan.getBatch();
+      if (partialResultsCellSizes == 0) {
+        // We have nothing in partialResults, clear the flags to prevent returning empty
Result
+        // when next result belongs to the next row.
+        clearPartialResults();
+      }
       return Result.create(cells, null, stale,
           partialResultsCellSizes > 0 || result.mayHaveMoreCellsInRow());
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/f45d2619/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
index 2814c47..3483d26 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
@@ -968,10 +968,6 @@ public class Result implements CellScannable, CellScanner {
   }
 
   /**
-   * Whether or not the result is a partial result. Partial results contain a subset of the
cells
-   * for a row and should be combined with a result representing the remaining cells in that
row to
-   * form a complete (non-partial) result.
-   * @return Whether or not the result is a partial result
    * @deprecated the word 'partial' ambiguous, use {@link #mayHaveMoreCellsInRow()} instead.
    *             Deprecated since 1.4.0.
    * @see #mayHaveMoreCellsInRow()
@@ -982,13 +978,12 @@ public class Result implements CellScannable, CellScanner {
   }
 
   /**
-   * For scanning large rows, the RS may choose to return the cells chunk by chunk to prevent
OOM.
-   * This flag is used to tell you if the current Result is the last one of the current row.
False
-   * means this Result is the last one. True means there are be more cells for the current
row.
-   * <p>
-   * The Scan configuration used to control the result size on the server is
-   * {@link Scan#setMaxResultSize(long)} and the default value can be seen here:
-   * {@link HConstants#DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE}
+   * For scanning large rows, the RS may choose to return the cells chunk by chunk to prevent
OOM
+   * or timeout. This flag is used to tell you if the current Result is the last one of the
current
+   * row. False means this Result is the last one. True means there MAY be more cells belonging
to
+   * the current row.
+   * If you don't use {@link Scan#setAllowPartialResults(boolean)} or {@link Scan#setBatch(int)},
+   * this method will always return false because the Result must contains all cells in one
Row.
    */
   public boolean mayHaveMoreCellsInRow() {
     return mayHaveMoreCellsInRow;

http://git-wip-us.apache.org/repos/asf/hbase/blob/f45d2619/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java
index 70be1d1..1481e5f 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java
@@ -595,14 +595,13 @@ public class Scan extends Query {
   }
 
   /**
-   * Set the maximum number of values to return for each call to next().
-   * Callers should be aware that invoking this method with any value
-   * is equivalent to calling {@link #setAllowPartialResults(boolean)}
-   * with a value of {@code true}; partial results may be returned if
-   * this method is called. Use {@link #setMaxResultSize(long)}} to
-   * limit the size of a Scan's Results instead.
-   *
+   * Set the maximum number of cells to return for each call to next(). Callers should be
aware
+   * that this is not equivalent to calling {@link #setAllowPartialResults(boolean)}.
+   * If you don't allow partial results, the number of cells in each Result must equal to
your
+   * batch setting unless it is the last Result for current row. So this method is helpful
in paging
+   * queries. If you just want to prevent OOM at client, use setAllowPartialResults(true)
is better.
    * @param batch the maximum number of values
+   * @see Result#mayHaveMoreCellsInRow()
    */
   public Scan setBatch(int batch) {
     if (this.hasFilter() && this.filter.hasFilterRow()) {
@@ -847,11 +846,14 @@ public class Scan extends Query {
   }
 
   /**
-   * Setting whether the caller wants to see the partial results that may be returned from
the
-   * server. By default this value is false and the complete results will be assembled client
side
+   * Setting whether the caller wants to see the partial results when server returns
+   * less-than-expected cells. It is helpful while scanning a huge row to prevent OOM at
client.
+   * By default this value is false and the complete results will be assembled client side
    * before being delivered to the caller.
    * @param allowPartialResults
    * @return this
+   * @see Result#mayHaveMoreCellsInRow()
+   * @see #setBatch(int)
    */
   public Scan setAllowPartialResults(final boolean allowPartialResults) {
     this.allowPartialResults = allowPartialResults;

http://git-wip-us.apache.org/repos/asf/hbase/blob/f45d2619/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java
index 15f9079..bcf52fa 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java
@@ -1074,4 +1074,20 @@ public class TestPartialResultsFromClientSide {
     scanner.close();
   }
 
-}
+  @Test
+  public void testMayHaveMoreCellsInRowReturnsTrueAndSetBatch() throws IOException {
+    Table table = createTestTable(TableName.valueOf(
+        "testMayHaveMoreCellsInRowReturnsTrueAndSetBatch"), ROWS, FAMILIES,
+        QUALIFIERS, VALUE);
+    Scan scan = new Scan();
+    scan.setBatch(1);
+    scan.setFilter(new FirstKeyOnlyFilter());
+    ResultScanner scanner = table.getScanner(scan);
+    Result result;
+    while ((result = scanner.next()) != null) {
+      assertTrue(result.rawCells() != null);
+      assertEquals(1, result.rawCells().length);
+    }
+  }
+
+}
\ No newline at end of file


Mime
View raw message