From fb22f0d63815550db4e428bc8b65a53b4ec8793a Mon Sep 17 00:00:00 2001 From: Phil Yang Date: Thu, 25 May 2017 19:00:12 +0800 Subject: [PATCH] HBASE-18113 Handle old client without include_stop_row flag when startRow equals endRow --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java | 2 +- .../java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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 7bc78d45dc..a936fa7661 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 @@ -308,7 +308,7 @@ public class Scan extends Query { return includeStartRow && includeStopRow && areStartRowAndStopRowEqual(startRow, stopRow); } - private static boolean areStartRowAndStopRowEqual(byte[] startRow, byte[] stopRow) { + public static boolean areStartRowAndStopRowEqual(byte[] startRow, byte[] stopRow) { return startRow != null && startRow.length > 0 && Bytes.equals(startRow, stopRow); } 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 108646aeae..eaf68cf905 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 @@ -1124,6 +1124,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 (Scan.areStartRowAndStopRowEqual(startRow, stopRow)) { + includeStopRow = true; + } } Scan scan = new Scan().withStartRow(startRow, includeStartRow).withStopRow(stopRow, includeStopRow); -- 2.11.0 (Apple Git-81)