为什么这样处理会有问题

天池番薯 发布于 2015/10/28 18:45
阅读 148
收藏 0
public static  String scan(String  hTable ,byte[] startRow, byte[] stopRow,byte[] family,byte[] qualifier) {
		   init();
		try {
		HTablePool pool = new HTablePool(conf, 10);
		HTableInterface table = pool.getTable(hTable);
		 //byte[] startRow, byte[] stopRow
		Scan scan = new Scan(startRow, stopRow);
		scan.addFamily(family);
		ResultScanner scanner = table.getScanner(scan);
		StringBuffer json=new StringBuffer("[");
		 for(Result r : scanner){
				byte[] logo = r.getValue(Bytes.toBytes("json"), Bytes.toBytes("json"));
				json=json.append(new StringBuffer(new String(logo)));
			}
//		 json= (String) json.subSequence(0, json.length()-1);
		 json=(StringBuffer) json.subSequence(0, json.length()-1);
		 json=json.append("]");
		  pool.close();
	        log.info("hbase testScan successed");
			return json.toString();	
	   } catch (Exception e) {
		   log.error("hbase testGet 异常" +e);
		   return null;
    	 }
	}



加载中
返回顶部
顶部