HBase性能調整:一般模式

2018-09-25 15:07 更新

HBase一般模式

常量

當人們開始使用HBase時,他們傾向于編寫如下所示的代碼:

Get get = new Get(rowkey);
Result r = table.get(get);
byte[] b = r.getValue(Bytes.toBytes("cf"), Bytes.toBytes("attr"));  // returns current version of value

但是特別是當內部循環(huán)(和MapReduce作業(yè))時,將columnFamily和column-names重復轉換為字節(jié)數組的成本非常高。最好對字節(jié)數組使用常量,如下所示:

public static final byte[] CF = "cf".getBytes();
public static final byte[] ATTR = "attr".getBytes();
...
Get get = new Get(rowkey);
Result r = table.get(get);
byte[] b = r.getValue(CF, ATTR);  // returns current version of value
以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號