[유치수] [NOBTS] add bytes to long[2]

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-commons/trunk@696 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Chisu Yu
2012-09-24 04:57:59 +00:00
parent d93a187895
commit b8ea061be6
3 changed files with 45 additions and 31 deletions
@@ -233,8 +233,6 @@ public class HBaseClient {
HTableInterface htable = getHTable(tableName);
if (query.isSingleRow()) {
System.out.println("Query single row");
Get get = new Get(startRow);
if (columns != null) {
@@ -247,9 +245,7 @@ public class HBaseClient {
List<Result> resultList = new ArrayList<Result>(1);
resultList.add(result);
resultIterator = resultList.iterator();
} else {
System.out.println("Query multiple rows");
Scan scan = new Scan();
if (startRow != null) {
@@ -269,19 +265,10 @@ public class HBaseClient {
LOG.debug("Executing scanner: " + query);
System.out.println("executing scanner:" + query);
long start = System.currentTimeMillis();
resultScanner = htable.getScanner(scan);
System.out.println("result scanner:" + resultScanner);
Iterator<Result> it = resultScanner.iterator();
while (it.hasNext()) {
System.out.println("R=" + it.next());
}
LOG.trace("Time taken for scanner: " + (System.currentTimeMillis() - start));
resultIterator = resultScanner.iterator();
@@ -8,6 +8,29 @@ public class BytesUtils {
return buffer;
}
public static final long[] bytesToLongLong(byte[] b) {
long[] result = new long[2];
result[0] = byteToLong(b, 0);
result[1] = byteToLong(b, 8);
return result;
}
public static final long byteToLong(byte[] b, int offset) {
if (b.length < offset + 8) {
throw new IllegalArgumentException("Illegal bytes or offset.");
}
long rv = 0;
for (int index = offset; index < offset + 8; index++) {
byte i = b[index];
rv = (rv << 8) | (i < 0 ? 256 + i : i);
}
return rv;
}
private static void writeLong(long value, byte[] buf, int offset) {
// for (int i = offset + 7; i > offset; i--) {
// buf [i]= (byte) val;