HBASE-18113 Handle old client without include_stop_row flag when startRow equals endRow
This commit is contained in:
parent
109e0d5485
commit
d5838c78fc
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -307,11 +307,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -406,7 +403,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;
|
||||
}
|
||||
|
@ -466,7 +463,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;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ import org.apache.hadoop.hbase.TableName;
|
|||
import org.apache.hadoop.hbase.Tag;
|
||||
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.Consistency;
|
||||
import org.apache.hadoop.hbase.client.Delete;
|
||||
import org.apache.hadoop.hbase.client.Durability;
|
||||
|
@ -1084,6 +1085,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);
|
||||
|
|
Loading…
Reference in New Issue