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 58c204b6739..f20f7274ca2 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(); } /** 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 185753367d1..b60cbde32fa 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 { 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 { * 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(); } /** 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 2b88ffcf85c..138a0fec463 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 @@ -83,6 +83,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; @@ -507,6 +509,23 @@ public abstract class Mutation extends OperationWithAttributes implements Row, C return this; } + /** + * @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).