hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gokul Balakrishnan <royal...@gmail.com>
Subject Re: Iteration in ResultScanner
Date Wed, 20 Jan 2016 06:53:18 GMT
Yes. You can use result.rawCells() to get the array of Cell instances
backing your query, if you need to retrieve all columns in your row at
once. You can then retrieve column values in the same way as above from
each Cell instance.

Alternatively, if your requirement is to process each column one by one,
you can use result.cellScanner() to get a CellScanner instance (say
"cellScanner"), and then iterate over each cell through
cellScanner.current().

Please see [1] for all operations supported by
org.apache.hadoop.hbase.client.Result.

[1]
https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Result.html

On 20 January 2016 at 12:02, Rajeshkumar J <rajeshkumarit8292@gmail.com>
wrote:

> Hi,
>
>  I want to get all the column values for a given row-key.
>
> Row-key     col1     col2 col3 col4 col5
>
> id100          XXX    YY    ZZZ   AAA   BBB
>
> is there any option available to get all the column values for given
> row-key. Here for id100 I want to have XX,YY, ZZZ ,AAA,BBB
>
> Thanks
>
>
>
> On Wed, Jan 20, 2016 at 11:30 AM, Gokul Balakrishnan <royalgok@gmail.com>
> wrote:
>
> > There are various ways, one of which is as follows:
> >
> > Result result = table.get(new Get("id100".**getBytes()));
> > Cell dataCell
> > = result.getColumnLatestCell("some_column_family","some_qualifier");
> > byte[] data = CellUtil.cloneValue(dataCell);
> >
> > The byte array "data" will represent the value of the column you've
> > retrieved. Note that this code returns the latest version of the cell
> > you've specified, and you'll have to do the necessary null checks for
> > "dataCell".
> >
> > On 20 January 2016 at 11:09, Rajeshkumar J <rajeshkumarit8292@gmail.com>
> > wrote:
> >
> > > Hi solomon,
> > >
> > >    The statement you have given is of
> > org.apache.hadoop.hbase.client.Result
> > > type. How to get all the column values from this??
> > >
> > > Thanks
> > >
> > > On Tue, Jan 19, 2016 at 6:45 PM, Solomon Duskis <sduskis@gmail.com>
> > wrote:
> > >
> > > > It sounds like you want a Get rathe than a scan.  *table.get(new
> > > > Get("id100".**getBytes()));* should do the trick.
> > > >
> > > > On Tue, Jan 19, 2016 at 7:17 AM, Rajeshkumar J <
> > > > rajeshkumarit8292@gmail.com>
> > > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > >  I have implemented Range scan using Java API as shown below
> > > > >
> > > > >             Scan scan = new Scan();
> > > > >             Configuration config = HBaseConfiguration.create();
> > > > >             HTable table = new HTable(config, "tablename");
> > > > >             scan.setStartRow("id100".getBytes());
> > > > >             scan.setStopRow("id100".getBytes());
> > > > >             ResultScanner scanner = table.getScanner(scan);
> > > > >
> > > > > Is there any option like so that i can get all the column values
> only
> > > > for a
> > > > > particular row-key without iteration.
> > > > >
> > > > > For ex : I have used id100 which is a row-key. After the scan
> > completed
> > > > how
> > > > > to get all the column values  of id100 row key without iteration.
> > > > >
> > > > > Thanks,
> > > > > Rajeshkumar J
> > > > >
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message