You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Vaibhav Puranik <vp...@gmail.com> on 2009/03/27 21:28:45 UTC

Iterating over all cells in HBase

Hi all,

One more newbie question.

Is there any way to iterate over all the cells (values of all column
families:all columns) of a given table without knowing what columns there
are?
(I am still struggling with whether a column is data or metadata)

I looked into apis for HTable, HTableDescriptor, HColumnDescriptor but
couldn't find anything to get columns.

tables.each {tableDescriptor ->
    families = tableDescriptor.getFamilies()
    families.each {family ->
        print family.getNameAsString()
    }
}

Can anyone suggest a method in HColumnDescriptor that can give me all the
column names?

Is it unusual to iterate over all column, all rows in a given HBase table?
We were thinking of doing that to populate memcached.

Regards,
Vaibhav

Re: Iterating over all cells in HBase

Posted by Vaibhav Puranik <vp...@gmail.com>.
Ryan,

The entrySet worked, Thanks!

Vaibhav

On Fri, Mar 27, 2009 at 1:40 PM, Ryan Rawson <ry...@gmail.com> wrote:

> The RowResult class contains what you are looking for...
>
> you want 'entrySet()' which contains byte[] -> Cell, where byte[] = column
> name, Cell = value & timestamp of the data.
>
> Good luck!
> -ryan
>
> On Fri, Mar 27, 2009 at 1:28 PM, Vaibhav Puranik <vp...@gmail.com>
> wrote:
>
> > Hi all,
> >
> > One more newbie question.
> >
> > Is there any way to iterate over all the cells (values of all column
> > families:all columns) of a given table without knowing what columns there
> > are?
> > (I am still struggling with whether a column is data or metadata)
> >
> > I looked into apis for HTable, HTableDescriptor, HColumnDescriptor but
> > couldn't find anything to get columns.
> >
> > tables.each {tableDescriptor ->
> >    families = tableDescriptor.getFamilies()
> >    families.each {family ->
> >        print family.getNameAsString()
> >    }
> > }
> >
> > Can anyone suggest a method in HColumnDescriptor that can give me all the
> > column names?
> >
> > Is it unusual to iterate over all column, all rows in a given HBase
> table?
> > We were thinking of doing that to populate memcached.
> >
> > Regards,
> > Vaibhav
> >
>

Re: Iterating over all cells in HBase

Posted by Ryan Rawson <ry...@gmail.com>.
The RowResult class contains what you are looking for...

you want 'entrySet()' which contains byte[] -> Cell, where byte[] = column
name, Cell = value & timestamp of the data.

Good luck!
-ryan

On Fri, Mar 27, 2009 at 1:28 PM, Vaibhav Puranik <vp...@gmail.com> wrote:

> Hi all,
>
> One more newbie question.
>
> Is there any way to iterate over all the cells (values of all column
> families:all columns) of a given table without knowing what columns there
> are?
> (I am still struggling with whether a column is data or metadata)
>
> I looked into apis for HTable, HTableDescriptor, HColumnDescriptor but
> couldn't find anything to get columns.
>
> tables.each {tableDescriptor ->
>    families = tableDescriptor.getFamilies()
>    families.each {family ->
>        print family.getNameAsString()
>    }
> }
>
> Can anyone suggest a method in HColumnDescriptor that can give me all the
> column names?
>
> Is it unusual to iterate over all column, all rows in a given HBase table?
> We were thinking of doing that to populate memcached.
>
> Regards,
> Vaibhav
>