Skip to content

Instantly share code, notes, and snippets.

@yujuwon
Created November 9, 2017 10:46
Show Gist options
  • Select an option

  • Save yujuwon/078ea9ee58467706c57af836905fb287 to your computer and use it in GitHub Desktop.

Select an option

Save yujuwon/078ea9ee58467706c57af836905fb287 to your computer and use it in GitHub Desktop.
public static void main(String[] args) throws Exception {
Configuration hconf = HBaseConfiguration.create();
hconf.set("hbase.rootdir", "hbase root 경로");
hconf.set("hbase.zookeeper.quorum", "hbase zookeeper 주소");
hconf.set("hbase.zookeeper.property.clientPort", "zookeeper port");
HBaseAdmin ha = new HBaseAdmin(hconf);
for (int i = 0; i < ha.listTableNames().length; i++){
System.out.println(ha.listTableNames()[i]);
}
HTable hTable = new HTable(conf, "테이블명");
Scan s = new Scan();
ResultScanner rs = hTable.getScanner(s);
for(Result r: rs){
for (KeyValue kv : r.raw()){
System.out.println("row : " + new String(kv.getRow()));
System.out.println("family : " + new String(kv.getFamily()));
System.out.println("qualifier : " + new String(kv.getQualifier()));
System.out.println("value : " + new String(kv.getValue()));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment