hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [08/22] hbase git commit: HBASE-15285 Forward-port respect for isReturnResult from HBASE-15095
Date Mon, 22 Feb 2016 22:20:36 GMT
HBASE-15285 Forward-port respect for isReturnResult from HBASE-15095


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

Branch: refs/heads/hbase-12439
Commit: 4b1acead42ffc625e398f0cd1cdec9e50f756fa9
Parents: e0fa176
Author: stack <stack@apache.org>
Authored: Wed Feb 17 19:26:17 2016 -0800
Committer: stack <stack@apache.org>
Committed: Wed Feb 17 19:26:17 2016 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/client/Append.java   |  7 +++----
 .../apache/hadoop/hbase/client/Increment.java    | 11 ++++-------
 .../org/apache/hadoop/hbase/client/Mutation.java | 19 +++++++++++++++++++
 .../hadoop/hbase/regionserver/HRegion.java       |  6 ++++--
 4 files changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/4b1acead/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Append.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Append.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Append.java
index d5a4552..45f1e46 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Append.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Append.java
@@ -47,7 +47,6 @@ import org.apache.hadoop.hbase.util.Bytes;
 @InterfaceAudience.Public
 @InterfaceStability.Stable
 public class Append extends Mutation {
-  private static final String RETURN_RESULTS = "_rr_";
   /**
    * @param returnResults
    *          True (default) if the append operation should return the results.
@@ -55,16 +54,16 @@ public class Append extends Mutation {
    *          bandwidth setting this to false.
    */
   public Append setReturnResults(boolean returnResults) {
-    setAttribute(RETURN_RESULTS, Bytes.toBytes(returnResults));
+    super.setReturnResults(returnResults);
     return this;
   }
 
   /**
    * @return current setting for returnResults
    */
+  // This method makes public the superclasses's protected method.
   public boolean isReturnResults() {
-    byte[] v = getAttribute(RETURN_RESULTS);
-    return v == null ? true : Bytes.toBoolean(v);
+    return super.isReturnResults();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/4b1acead/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
index d37cf82..187c077 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
@@ -52,9 +52,6 @@ import org.apache.hadoop.hbase.util.ClassSize;
 @InterfaceStability.Stable
 public class Increment extends Mutation implements Comparable<Row> {
   private static final long HEAP_OVERHEAD =  ClassSize.REFERENCE + ClassSize.TIMERANGE;
-
-  private static final String RETURN_RESULTS = "_rr_";
-
   private TimeRange tr = new TimeRange();
 
   /**
@@ -170,16 +167,16 @@ public class Increment extends Mutation implements Comparable<Row>
{
    *          to false.
    */
   public Increment setReturnResults(boolean returnResults) {
-    setAttribute(RETURN_RESULTS, Bytes.toBytes(returnResults));
+    super.setReturnResults(returnResults);
     return this;
   }
 
   /**
-   * @return current value for returnResults
+   * @return current setting for returnResults
    */
+  // This method makes public the superclasses's protected method.
   public boolean isReturnResults() {
-    byte[] v = getAttribute(RETURN_RESULTS);
-    return v == null ? true : Bytes.toBoolean(v);
+    return super.isReturnResults();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/4b1acead/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java
index 9a550f9..06e0224 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java
@@ -82,6 +82,8 @@ public abstract class Mutation extends OperationWithAttributes implements
Row, C
    */
   private static final String OP_ATTRIBUTE_TTL = "_ttl";
 
+  private static final String RETURN_RESULTS = "_rr_";
+
   protected byte [] row = null;
   protected long ts = HConstants.LATEST_TIMESTAMP;
   protected Durability durability = Durability.USE_DEFAULT;
@@ -452,6 +454,23 @@ public abstract class Mutation extends OperationWithAttributes implements
Row, C
   }
 
   /**
+   * @return current value for returnResults
+   */
+  // Used by Increment and Append only.
+  @InterfaceAudience.Private
+  protected boolean isReturnResults() {
+    byte[] v = getAttribute(RETURN_RESULTS);
+    return v == null ? true : Bytes.toBoolean(v);
+  }
+
+  @InterfaceAudience.Private
+  // Used by Increment and Append only.
+  protected Mutation setReturnResults(boolean returnResults) {
+    setAttribute(RETURN_RESULTS, Bytes.toBytes(returnResults));
+    return this;
+  }
+
+  /**
    * Subclasses should override this method to add the heap size of their own fields.
    * @return the heap size to add (will be aligned).
    */

http://git-wip-us.apache.org/repos/asf/hbase/blob/4b1acead/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 3e6c092..0d5a71e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -6972,7 +6972,9 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver,
Regi
       lock(this.updatesLock.readLock());
       try {
         Result cpResult = doCoprocessorPreCall(op, mutation);
-        if (cpResult != null) return cpResult;
+        if (cpResult != null) {
+          return returnResults? cpResult: null;
+        }
         Durability effectiveDurability = getEffectiveDurability(mutation.getDurability());
         Map<Store, List<Cell>> forMemStore =
             new HashMap<Store, List<Cell>>(mutation.getFamilyCellMap().size());
@@ -7000,7 +7002,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver,
Regi
         this.updatesLock.readLock().unlock();
       }
       // If results is null, then client asked that we not return the calculated results.
-      return results !=  null? Result.create(results): null;
+      return results != null && returnResults? Result.create(results): null;
     } finally {
       // Call complete always, even on success. doDelta is doing a Get READ_UNCOMMITTED when
it goes
       // to get current value under an exclusive lock so no need so no need to wait to return
to


Mime
View raw message