HBASE-15285 Forward-port respect for isReturnResult from HBASE-15095
This commit is contained in:
parent
e0fa176f0b
commit
4b1acead42
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
@ -451,6 +453,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).
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user