Hi all~
I need to get all column families from specified table,When I look into the
class "org.apache.hadoop.hbase.HTableDescriptor",I found that
there are more than three methods can be used.
See the code below,there are method1,method2,method3 to do the same thing:
/*___________code begin___________*/
HTable table = new HTable(config, "mytable");
HTableDescriptor htd = table.getTableDescriptor();
//method 1
TimeCounter tc = new TimeCounter().run();
HColumnDescriptor[] cfs = htd.getColumnFamilies();
for(int i=0;i< cfs.length;i++){
System.out.println("column family:"+new String(cfs[i].getName()));
}
System.out.println("time with
getColumnFamilies-->"+tc.stop().getMicroSeconds());
//method2
TimeCounter tc2 = new TimeCounter().run();
Set<byte[]> family_keys = htd.getFamiliesKeys();
for(byte[] _f :family_keys){
System.out.println("column family:"+new String(_f));
}
System.out.println("time with getFamiliesKeys-->"+tc2.stop().getMicroSeconds());
//method3
TimeCounter tc3 = new TimeCounter().run();
Collection<HColumnDescriptor> family_co = htd.getFamilies();
for(HColumnDescriptor family_co_entry :family_co){
System.out.println("column family:"+new String(family_co_entry.getName()));
}
System.out.println("time with getFamilies-->"+tc3.stop().getMicroSeconds());
/*___________________code end_____________________*/
I found that the efficience of method 1 and method 3 are the same,about 120 us.
but the method2 is lagging,about 500us.
I just need to retieve the column families' names.So method2 is just meet my
need.
but why is it so lag?
Thanks.
Jack Chan.
A new Apache-Camel rider.
sina-weibo:@for-each