diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/Query.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/Query.java index 0d41934..69bb41c 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/Query.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/Query.java @@ -28,7 +28,6 @@ import org.apache.hadoop.hbase.security.access.AccessControlConstants; import org.apache.hadoop.hbase.security.access.Permission; import org.apache.hadoop.hbase.security.visibility.Authorizations; import org.apache.hadoop.hbase.security.visibility.VisibilityConstants; -import org.apache.hadoop.hbase.util.Bytes; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ListMultimap; @@ -36,6 +35,7 @@ import com.google.common.collect.ListMultimap; @InterfaceAudience.Public @InterfaceStability.Evolving public abstract class Query extends OperationWithAttributes { + private static final String ISOLATION_LEVEL = "_isolationlevel_"; protected Filter filter = null; /** @@ -118,4 +118,31 @@ public abstract class Query extends OperationWithAttributes { @Deprecated public void setACLStrategy(boolean cellFirstStrategy) { } + + /** + * Set the isolation level for this query. If the + * isolation level is set to READ_UNCOMMITTED, then + * this query will return data from committed and + * uncommitted transactions. If the isolation level + * is set to READ_COMMITTED, then this query will return + * data from committed transactions only. If a isolation + * level is not explicitly set on a Query, then it + * is assumed to be READ_COMMITTED. + * @param level IsolationLevel for this query + */ + public void setIsolationLevel(IsolationLevel level) { + setAttribute(ISOLATION_LEVEL, level.toBytes()); + } + + /** + * @return The isolation level of this scan. + * If no isolation level was set for this scan object, + * then it returns READ_COMMITTED. + * @return The IsolationLevel for this scan + */ + public IsolationLevel getIsolationLevel() { + byte[] attr = getAttribute(ISOLATION_LEVEL); + return attr == null ? IsolationLevel.READ_COMMITTED : + IsolationLevel.fromBytes(attr); + } } diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java index 4527d56..2d6f39b 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java @@ -87,7 +87,6 @@ public class Scan extends Query { private static final Log LOG = LogFactory.getLog(Scan.class); private static final String RAW_ATTR = "_raw_"; - private static final String ISOLATION_LEVEL = "_isolationlevel_"; /** * EXPERT ONLY. @@ -738,32 +737,6 @@ public class Scan extends Query { return attr == null ? false : Bytes.toBoolean(attr); } - /* - * Set the isolation level for this scan. If the - * isolation level is set to READ_UNCOMMITTED, then - * this scan will return data from committed and - * uncommitted transactions. If the isolation level - * is set to READ_COMMITTED, then this scan will return - * data from committed transactions only. If a isolation - * level is not explicitly set on a Scan, then it - * is assumed to be READ_COMMITTED. - * @param level IsolationLevel for this scan - */ - public void setIsolationLevel(IsolationLevel level) { - setAttribute(ISOLATION_LEVEL, level.toBytes()); - } - /* - * @return The isolation level of this scan. - * If no isolation level was set for this scan object, - * then it returns READ_COMMITTED. - * @return The IsolationLevel for this scan - */ - public IsolationLevel getIsolationLevel() { - byte[] attr = getAttribute(ISOLATION_LEVEL); - return attr == null ? IsolationLevel.READ_COMMITTED : - IsolationLevel.fromBytes(attr); - } - /** * Set whether this scan is a small scan *

@@ -794,5 +767,5 @@ public class Scan extends Query { */ public boolean isSmall() { return small; - } + } }