Hbase Scan 결과에 대해 디버깅을 하려 했다.


예전 쿼리를 Result에 대해서 keyvalue를 얻어오는 부분을 날 쿼리를 이용해 사용했다.


                    for (KeyValue kv : result.raw()) {

                        System.out.printf("row: %d, qualifier: %s, value: %s\n",

                                Bytes.toLong(Bytes.padHead(kv.getRow(), 8)),

                                new String(kv.getQualifier()),

                                new String(kv.getValue()));

                    }




그러나, CellUtil을 사용하면 좀 고급스럽게 디버깅할 수 있다.




import org.apache.hadoop.hbase.Cell;

import org.apache.hadoop.hbase.CellUtil;



                    List<Cell> cells = result.listCells();

                    final String TABS = "\t";

                    for (Cell cell : cells) {

                        System.out.printf("%s%scolumn=%s:%s, timestamp=%d, value=%s\n",

                                Bytes.toStringBinary(CellUtil.cloneRow(cell)),

                                TABS,

                                Bytes.toString(CellUtil.cloneFamily(cell)),

                                Bytes.toString(CellUtil.cloneQualifier(cell)),

                                cell.getTimestamp(),

                                Bytes.toString(CellUtil.cloneValue(cell)));

                    }

                    



Posted by '김용환'
,