Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # dev >> how to use HBase Shell formatter?


Copy link to this message
-
Re: how to use HBase Shell formatter?
Looking at the following from formatter.rb:
            col1width = (not widths or widths.length == 0) ? @max_width / 4
: @max_width * widths[0] / 100
            col2width = (not widths or widths.length < 2) ? @max_width -
col1width - 2 : @max_width * widths[1] / 100 - 2

It seems the widths argument only expects two fields which should be
percentage of widths for columns 1 and 2, respectively.

If you want 3 columns to be displayed, you should enhance formatter.rb

Cheers

On Sun, Jun 2, 2013 at 10:30 AM, N Dm <[EMAIL PROTECTED]> wrote:

> hi, folks,
>
> Can someone point me to a sample about how to use 'formatter.rb' inside
> hbase ruby code? The version I am using is 94.3
>
> I am trying to implement a 'list_replicated_table' command on hbase shell,
> and leveraging 'formatter" to lay out the output. The code segement is
> like:
>
>         formatter.header(["TABLE","COLUMNFAMILY", "TARGET_CLUSTER"])
>         ......
>         list.each do |e|
>           formatter.row([e[0],e[1],e[2]])
>         end
>         .....
>         formatter.footer(now)
>
> where e[0],e[1], and e[2] are entries from a String array. I was hoping to
> have a nice output with column aligned. However, I got the output with a
> blank as delimiter.
> hbase(main):002:0> list_replicated_tables
>  TABLE COLUMNFAMILY TARGET_CLUSTER
>  scores course hdtest017.svl.ibm.com:2181:/hbase
>  t3_dn cf1 hdtest017.svl.ibm.com:2181:/hbase
>  usertable family hdtest017.svl.ibm.com:2181:/hbase
>
> I am looking for something like:
> TABLE          COLUMNFAMILY  TARGET_CLUSTER
> scores         course        hdtest017.svl.ibm.com:2181:/hbase
>
> I was following the way 'list_peers' did, seems don't work over there
> either.
>
> I also changed the formatter input as:
> formatter.header(["TABLE","COLUMNFAMILY", "TARGET_CLUSTER"],[18,18,48])
> formatter.row([e[0],e[1],e[2]],true,[18,18,48])
> which doesn't change the output either.
>
>
> The 'scan.rb' works fine, however, I can't tell what's the differnce.
>
> Any suggestion is really appreciated. Thanks!
>
> Demai
>