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:
Zhihong Yu 2012-03-22 20:43:55 +00:00
parent fa98df639e
commit a379a41e3d
2 changed files with 6 additions and 18 deletions

View File

@ -19,7 +19,7 @@
*/ */
package org.apache.hadoop.hbase.regionserver; 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.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -121,9 +121,9 @@ public class HRegionThriftServer extends Thread {
long timestamp, long timestamp,
Map<ByteBuffer, ByteBuffer> attributes) throws IOError { Map<ByteBuffer, ByteBuffer> attributes) throws IOError {
try { 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); HRegionLocation location = table.getRegionLocation(row, false);
byte[] regionName = location.getRegionInfo().getRegionName(); byte[] regionName = location.getRegionInfo().getRegionName();
@ -135,7 +135,7 @@ public class HRegionThriftServer extends Thread {
} }
Get get = new Get(row); Get get = new Get(row);
for(ByteBuffer column : columns) { for(ByteBuffer column : columns) {
byte [][] famAndQf = KeyValue.parseColumn(toBytes(column)); byte [][] famAndQf = KeyValue.parseColumn(getBytes(column));
if (famAndQf.length == 1) { if (famAndQf.length == 1) {
get.addFamily(famAndQf[0]); get.addFamily(famAndQf[0]);
} else { } else {

View File

@ -585,7 +585,7 @@ public class ThriftServerRunner implements Runnable {
throws IOError { throws IOError {
try{ try{
List<HRegionInfo> hris = List<HRegionInfo> hris =
this.getHBaseAdmin().getTableRegions(toBytes(tableName)); this.getHBaseAdmin().getTableRegions(getBytes(tableName));
List<TRegionInfo> regions = new ArrayList<TRegionInfo>(); List<TRegionInfo> regions = new ArrayList<TRegionInfo>();
if (hris != null) { 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 @Deprecated
@Override @Override
public List<TCell> get( public List<TCell> get(
@ -1349,7 +1337,7 @@ public class ThriftServerRunner implements Runnable {
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError { public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
try { try {
HTable table = getTable(HConstants.META_TABLE_NAME); HTable table = getTable(HConstants.META_TABLE_NAME);
byte[] row = toBytes(searchRow); byte[] row = getBytes(searchRow);
Result startRowResult = table.getRowOrBefore( Result startRowResult = table.getRowOrBefore(
row, HConstants.CATALOG_FAMILY); row, HConstants.CATALOG_FAMILY);