You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ya...@apache.org on 2017/05/26 05:43:50 UTC

hbase git commit: HBASE-18113 Handle old client without include_stop_row flag when startRow equals endRow

Repository: hbase
Updated Branches:
  refs/heads/master f441ca045 -> b74474dfc


HBASE-18113 Handle old client without include_stop_row flag when startRow equals endRow


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

Branch: refs/heads/master
Commit: b74474dfc9ba0aef237016737adee95e55c637f6
Parents: f441ca0
Author: Phil Yang <ya...@apache.org>
Authored: Thu May 25 19:00:12 2017 +0800
Committer: Phil Yang <ya...@apache.org>
Committed: Fri May 26 13:38:56 2017 +0800

----------------------------------------------------------------------
 .../apache/hadoop/hbase/client/ClientUtil.java  | 30 ++++++++++++++++++++
 .../org/apache/hadoop/hbase/client/Scan.java    | 11 +++----
 .../hbase/shaded/protobuf/ProtobufUtil.java     |  6 ++++
 3 files changed, 40 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/b74474df/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientUtil.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientUtil.java
new file mode 100644
index 0000000..e4a84d5
--- /dev/null
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientUtil.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.client;
+
+import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.util.Bytes;
+
+@InterfaceAudience.Private
+public class ClientUtil {
+
+
+  public static boolean areScanStartRowAndStopRowEqual(byte[] startRow, byte[] stopRow) {
+    return startRow != null && startRow.length > 0 && Bytes.equals(startRow, stopRow);
+  }
+}

http://git-wip-us.apache.org/repos/asf/hbase/blob/b74474df/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 7bc78d4..2746263 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
@@ -305,11 +305,8 @@ public class Scan extends Query {
   }
 
   public boolean isGetScan() {
-    return includeStartRow && includeStopRow && areStartRowAndStopRowEqual(startRow, stopRow);
-  }
-
-  private static boolean areStartRowAndStopRowEqual(byte[] startRow, byte[] stopRow) {
-    return startRow != null && startRow.length > 0 && Bytes.equals(startRow, stopRow);
+    return includeStartRow && includeStopRow
+        && ClientUtil.areScanStartRowAndStopRowEqual(this.startRow, this.stopRow);
   }
 
   /**
@@ -418,7 +415,7 @@ public class Scan extends Query {
   @Deprecated
   public Scan setStartRow(byte[] startRow) {
     withStartRow(startRow);
-    if (areStartRowAndStopRowEqual(startRow, stopRow)) {
+    if (ClientUtil.areScanStartRowAndStopRowEqual(this.startRow, this.stopRow)) {
       // for keeping the old behavior that a scan with the same start and stop row is a get scan.
       this.includeStopRow = true;
     }
@@ -478,7 +475,7 @@ public class Scan extends Query {
   @Deprecated
   public Scan setStopRow(byte[] stopRow) {
     withStopRow(stopRow);
-    if (areStartRowAndStopRowEqual(startRow, stopRow)) {
+    if (ClientUtil.areScanStartRowAndStopRowEqual(this.startRow, this.stopRow)) {
       // for keeping the old behavior that a scan with the same start and stop row is a get scan.
       this.includeStopRow = true;
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/b74474df/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
index 108646a..a002f74 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
@@ -62,6 +62,7 @@ import org.apache.hadoop.hbase.Tag;
 import org.apache.hadoop.hbase.TagUtil;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.client.Append;
+import org.apache.hadoop.hbase.client.ClientUtil;
 import org.apache.hadoop.hbase.client.CompactionState;
 import org.apache.hadoop.hbase.client.Consistency;
 import org.apache.hadoop.hbase.client.Delete;
@@ -1124,6 +1125,11 @@ public final class ProtobufUtil {
     }
     if (proto.hasIncludeStopRow()) {
       includeStopRow = proto.getIncludeStopRow();
+    } else {
+      // old client without this flag, we should consider start=end as a get.
+      if (ClientUtil.areScanStartRowAndStopRowEqual(startRow, stopRow)) {
+        includeStopRow = true;
+      }
     }
     Scan scan =
         new Scan().withStartRow(startRow, includeStartRow).withStopRow(stopRow, includeStopRow);