HBASE-5591 ThiftServerRunner.HBaseHandler.toBytes() is identical to Bytes.getBytes() (Scott Chen)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1304047 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fa98df639e
commit
a379a41e3d
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
package org.apache.hadoop.hbase.regionserver;
|
||||
|
||||
import static org.apache.hadoop.hbase.thrift.ThriftServerRunner.HBaseHandler.toBytes;
|
||||
import static org.apache.hadoop.hbase.util.Bytes.getBytes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -121,9 +121,9 @@ public class HRegionThriftServer extends Thread {
|
|||
long timestamp,
|
||||
Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
|
||||
try {
|
||||
byte[] row = toBytes(rowb);
|
||||
byte[] row = getBytes(rowb);
|
||||
|
||||
HTable table = getTable(toBytes(tableName));
|
||||
HTable table = getTable(getBytes(tableName));
|
||||
HRegionLocation location = table.getRegionLocation(row, false);
|
||||
byte[] regionName = location.getRegionInfo().getRegionName();
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class HRegionThriftServer extends Thread {
|
|||
}
|
||||
Get get = new Get(row);
|
||||
for(ByteBuffer column : columns) {
|
||||
byte [][] famAndQf = KeyValue.parseColumn(toBytes(column));
|
||||
byte [][] famAndQf = KeyValue.parseColumn(getBytes(column));
|
||||
if (famAndQf.length == 1) {
|
||||
get.addFamily(famAndQf[0]);
|
||||
} else {
|
||||
|
|
|
@ -585,7 +585,7 @@ public class ThriftServerRunner implements Runnable {
|
|||
throws IOError {
|
||||
try{
|
||||
List<HRegionInfo> hris =
|
||||
this.getHBaseAdmin().getTableRegions(toBytes(tableName));
|
||||
this.getHBaseAdmin().getTableRegions(getBytes(tableName));
|
||||
List<TRegionInfo> regions = new ArrayList<TRegionInfo>();
|
||||
|
||||
if (hris != null) {
|
||||
|
@ -606,18 +606,6 @@ public class ThriftServerRunner implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert ByteBuffer to byte array. Note that this cannot be replaced by
|
||||
* Bytes.toBytes().
|
||||
*/
|
||||
public static byte[] toBytes(ByteBuffer bb) {
|
||||
byte[] result = new byte[bb.remaining()];
|
||||
// Make a duplicate so the position doesn't change
|
||||
ByteBuffer dup = bb.duplicate();
|
||||
dup.get(result, 0, result.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<TCell> get(
|
||||
|
@ -1349,7 +1337,7 @@ public class ThriftServerRunner implements Runnable {
|
|||
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
|
||||
try {
|
||||
HTable table = getTable(HConstants.META_TABLE_NAME);
|
||||
byte[] row = toBytes(searchRow);
|
||||
byte[] row = getBytes(searchRow);
|
||||
Result startRowResult = table.getRowOrBefore(
|
||||
row, HConstants.CATALOG_FAMILY);
|
||||
|
||||
|
|
Loading…
Reference in New Issue